Routines to modify species parameter table or model input objects
modifySpParams(SpParams, customParams, subsetSpecies = TRUE)
modifyCohortParams(x, customParams, verbose = TRUE)
modifyInputParams(x, customParams, verbose = TRUE)
A species parameter data frame, typically SpParamsMED
.
A data frame or a named vector with new parameter values (see details).
A logical flag to indicate that the output data frame should include only those species mentioned in customParams
.
A model input object of class spwbInput
or growthInput
.
A logical flag to indicate that messages should be printed on the console.
Function modifySpParams
returns a modified species parameter data frame.
Functions modifyCohortParams
and modifyInputParams
return a modified spwbInput
or growthInput
object. Note that modifications may affect other parameters beyond those indicated in customParams
, as a result of parameter dependencies (see examples).
When calling function modifySpParams
, customParams
should be a data frame with as many rows as species
and as many columns as parameters to modify, plus a column called 'SpIndex' or 'Species' to match species between the two tables.
When calling modifyCohortParams
, customParams
can be a data frame with as many rows as cohorts
and as many columns as parameters to modify, plus a column called 'Cohort' which will be matched with the cohort names
given by spwbInput
or growthInput
.
Alternatively, customParams
can be a named list or named numeric vector as for modifyInputParams
.
When calling modifyInputParams
, customParams
must be either a named list or a named numeric vector.
Cohort parameters are specified using the syntax "<cohortName>/<paramName>" for names (e.g. "T2_176/Z50" to modify parameter 'Z50' of cohort 'T2_176').
Soil layer parameters are specified using the syntax "<paramName>@#layer" for names, where #layer is the layer index (e.g. "rfc@1" will modify the rock fragment content of soil layer 1).
Control parameters are specified using either "<paramName>" (e.g "phloemConductanceFactor") or "<paramName>$<subParamName>" (e.g "maximumRelativeGrowthRates$leaf").
It may seem unnecessary to modify soil or control parameters via a function, but modifyInputParams
is called from optimization functions (see optimization
).
#Load example daily meteorological data
data(examplemeteo)
#Load example plot plant data
data(exampleforest)
#Default species parameterization
data(SpParamsMED)
#Initialize soil with default soil params (4 layers)
examplesoil = soil(defaultSoilParams(4))
#Initialize control parameters
control = defaultControl("Granier")
#Initialize input
x1 = forest2spwbInput(exampleforest,examplesoil, SpParamsMED, control)
# Cohort name for Pinus halepensis
PH_coh = paste0("T1_", SpParamsMED$SpIndex[SpParamsMED$Name=="Pinus halepensis"])
PH_coh
#> [1] "T1_148"
# Modify Z50 and Z95 of Pinus halepensis cohort
customParams <- c(200,2000)
names(customParams) <- paste0(PH_coh,c("/Z50", "/Z95"))
x1m <- modifyInputParams(x1, customParams)
# Inspect original and modified objects
x1$below
#> Z50 Z95
#> T1_148 100 600
#> T2_168 300 1000
#> S1_165 200 1000
x1m$below
#> Z50 Z95 fineRootBiomass coarseRootSoilVolume
#> T1_148 200 2000 NA 5.887882
#> T2_168 300 1000 NA 7.526346
#> S1_165 200 1000 NA 5.544086
# Inspect dependencies: fine root distribution across soil layers
x1$belowLayers$V
#> 1 2 3 4
#> T1_148 0.8604899 0.1194556 0.01511005 0.004944476
#> T2_168 0.5008953 0.4505941 0.04064831 0.007862284
#> S1_165 0.6799879 0.2737911 0.03567632 0.010544678
x1m$belowLayers$V
#> 1 2 3 4
#> T1_148 0.6402830 0.2655064 0.06472163 0.029488953
#> T2_168 0.5008953 0.4505941 0.04064831 0.007862284
#> S1_165 0.6799879 0.2737911 0.03567632 0.010544678
# Modify rock fragment content and sand proportion of soil layer 1
x1s <- modifyInputParams(x1, c("rfc@1" = 5, "sand@1" = 10))
# Inspect original and modified soils
x1$soil
#> Soil depth (mm): 4000
#>
#> Layer 1 [ 0 to 300 mm ]
#> clay (%): 25 silt (%): 50 sand (%): 25 organic matter (%): NA [ Silt loam ]
#> Rock fragment content (%): 25 Macroporosity (%): 5
#> Theta WP (%): 14 Theta FC (%): 30 Theta SAT (%): 49 Theta current (%) 30
#> Vol. WP (mm): 32 Vol. FC (mm): 68 Vol. SAT (mm): 111 Vol. current (mm): 68
#> Temperature (Celsius): NA
#>
#> Layer 2 [ 300 to 1000 mm ]
#> clay (%): 25 silt (%): 50 sand (%): 25 organic matter (%): NA [ Silt loam ]
#> Rock fragment content (%): 45 Macroporosity (%): 5
#> Theta WP (%): 14 Theta FC (%): 30 Theta SAT (%): 49 Theta current (%) 30
#> Vol. WP (mm): 55 Vol. FC (mm): 117 Vol. SAT (mm): 190 Vol. current (mm): 117
#> Temperature (Celsius): NA
#>
#> Layer 3 [ 1000 to 2000 mm ]
#> clay (%): 25 silt (%): 50 sand (%): 25 organic matter (%): NA [ Silt loam ]
#> Rock fragment content (%): 75 Macroporosity (%): 5
#> Theta WP (%): 14 Theta FC (%): 30 Theta SAT (%): 49 Theta current (%) 30
#> Vol. WP (mm): 36 Vol. FC (mm): 76 Vol. SAT (mm): 123 Vol. current (mm): 76
#> Temperature (Celsius): NA
#>
#> Layer 4 [ 2000 to 4000 mm ]
#> clay (%): 25 silt (%): 50 sand (%): 25 organic matter (%): NA [ Silt loam ]
#> Rock fragment content (%): 95 Macroporosity (%): 5
#> Theta WP (%): 14 Theta FC (%): 30 Theta SAT (%): 49 Theta current (%) 30
#> Vol. WP (mm): 14 Vol. FC (mm): 30 Vol. SAT (mm): 49 Vol. current (mm): 30
#> Temperature (Celsius): NA
#>
#> Total soil saturated capacity (mm): 473
#> Total soil water holding capacity (mm): 291
#> Total soil extractable water (mm): 183
#> Total soil current Volume (mm): 291
#>
#> Snow pack water equivalent (mm): 0
#> Saturated water depth (mm): NA
#>
x1s$soil
#> Soil depth (mm): 4000
#>
#> Layer 1 [ 0 to 300 mm ]
#> clay (%): 25 silt (%): 65 sand (%): 10 organic matter (%): NA [ Silt loam ]
#> Rock fragment content (%): 5 Macroporosity (%): 2
#> Theta WP (%): 14 Theta FC (%): 32 Theta SAT (%): 50 Theta current (%) 32
#> Vol. WP (mm): 40 Vol. FC (mm): 92 Vol. SAT (mm): 143 Vol. current (mm): 92
#> Temperature (Celsius): NA
#>
#> Layer 2 [ 300 to 1000 mm ]
#> clay (%): 25 silt (%): 50 sand (%): 25 organic matter (%): NA [ Silt loam ]
#> Rock fragment content (%): 45 Macroporosity (%): 5
#> Theta WP (%): 14 Theta FC (%): 30 Theta SAT (%): 49 Theta current (%) 30
#> Vol. WP (mm): 55 Vol. FC (mm): 117 Vol. SAT (mm): 190 Vol. current (mm): 117
#> Temperature (Celsius): NA
#>
#> Layer 3 [ 1000 to 2000 mm ]
#> clay (%): 25 silt (%): 50 sand (%): 25 organic matter (%): NA [ Silt loam ]
#> Rock fragment content (%): 75 Macroporosity (%): 5
#> Theta WP (%): 14 Theta FC (%): 30 Theta SAT (%): 49 Theta current (%) 30
#> Vol. WP (mm): 36 Vol. FC (mm): 76 Vol. SAT (mm): 123 Vol. current (mm): 76
#> Temperature (Celsius): NA
#>
#> Layer 4 [ 2000 to 4000 mm ]
#> clay (%): 25 silt (%): 50 sand (%): 25 organic matter (%): NA [ Silt loam ]
#> Rock fragment content (%): 95 Macroporosity (%): 5
#> Theta WP (%): 14 Theta FC (%): 30 Theta SAT (%): 49 Theta current (%) 30
#> Vol. WP (mm): 14 Vol. FC (mm): 30 Vol. SAT (mm): 49 Vol. current (mm): 30
#> Temperature (Celsius): NA
#>
#> Total soil saturated capacity (mm): 505
#> Total soil water holding capacity (mm): 315
#> Total soil extractable water (mm): 201
#> Total soil current Volume (mm): 315
#>
#> Snow pack water equivalent (mm): 0
#> Saturated water depth (mm): NA
#>
# When modifying growth input objects dependencies increase
x1 = forest2growthInput(exampleforest,examplesoil, SpParamsMED, control)
customParams <- c(2000,2)
names(customParams) <- paste0(PH_coh,c("/Al2As", "/LAI_live"))
x1m <- modifyInputParams(x1, customParams)