# Basic water balance simulation

#### 2020-05-17

The present document describes how to run the soil plant water balance model described in De Cáceres et al. (2015) using package medfate. The document indicates how to prepare the inputs, use the simulation functions and inspect the outputs. All the details of the model design and formulation can be found at https://vegmod.ctfc.cat/software/medfate. Because it introduces many basic features of package medfate, this document should be read before addressing advanced topics of water balance simulations or growth simulations.

## Preparing model inputs

Any forest water balance model needs information on climate, vegetation and soils of the forest stand to be simulated. Moreover, since the soil water balance in medfate differentiates between species, species-specific parameters are also needed. In this subsection we explain the different steps (including optional pathways) to prepare all the data needed to run function spwb().

### Soils

#### Required soil data

Simulation models in medfate require information on the physical attributes of soil, namely soil depth, texture, bulk density and rock fragment content. Soil information needs to be entered as a data frame with soil layers in rows and physical attributes in columns. The model accepts one to five soil layers with arbitrary widths. Soil physical attributes can be initialized to default values, for a given number of layers, using function defaultSoilParams():

spar = defaultSoilParams(2)
print(spar)
##   widths clay sand om  bd rfc
## 1    300   25   25 NA 1.5  20
## 2    700   25   25 NA 1.5  40

where widths are soil layer widths in mm; clay and sand are the percentage of clay and sand, in percent of dry weight, om stands for organic matter, bd is bulk density (in g·cm$$^{-3}$$) and rfc the percentage of rock fragments. Because soil properties vary strongly at fine spatial scales, ideally soil physical attributes should be measured on samples taken at the forest stand to be simulated. For those users lacking such data, soil properties modelled at larger scales are available via soilgrids.org (see function soilgridsParams()).

#### Soil input object

The soil input for function spwb() is actually a list of class soil that is created using a function with the same name:

examplesoil = soil(spar)
class(examplesoil)
## [1] "soil" "list"

The list contains the following elements:

names(examplesoil)
##  [1] "SoilDepth"    "W"            "SWE"          "Temp"         "Ksoil"
##  [6] "Gsoil"        "dVec"         "sand"         "clay"         "om"
## [11] "usda_Type"    "VG_alpha"     "VG_n"         "VG_theta_res" "VG_theta_sat"
## [16] "macro"        "rfc"

In addition to the physical soil description, this object contains soil parameters needed for soil water balance simulations. For example, macro specifies the macroporosity of each layer; Gsoil and Ksoil are parameters needed to model the process of water infiltration into the soil. The meaning of all elements in the soil object can be found in the help page for function soil().

Importantly, the soil object is used to store the degree of moisture of each soil layer. In particular, element W contains the state variable that represents moisture content - the proportion of moisture relative to field capacity - which is normally initialized to 1 for each layer:

examplesoil$W ## [1] 1 1 It is important to remember that, unlike normal objects in R, any water balance simulation will modify the moisture values in the input soil object. That is, the state of the soil at the end of the simulated process (i.e. W) will be stored. Hence, one can use the same object to simulate water balance sequentially and the final state of one simulation is the initial state of the next. #### Water retention curves At any time, one can show the characteristics and status of the soil object using its print function: print(examplesoil, model = "SX") ## Soil depth (mm): 1000 ## ## Layer 1 [ 0 to 300 mm ] ## clay (%): 25 silt (%): 50 sand (%): 25 organic matter (%): NA [ Silt loam ] ## Rock fragment content (%): 20 Macroporosity (%): 5 ## Theta WP (%): 14 Theta FC (%): 30 Theta SAT (%): 49 Theta current (%) 30 ## Vol. WP (mm): 34 Vol. FC (mm): 73 Vol. SAT (mm): 118 Vol. current (mm): 73 ## Temperature (Celsius): NA ## ## Layer 2 [ 300 to 1000 mm ] ## clay (%): 25 silt (%): 50 sand (%): 25 organic matter (%): NA [ Silt loam ] ## Rock fragment content (%): 40 Macroporosity (%): 5 ## Theta WP (%): 14 Theta FC (%): 30 Theta SAT (%): 49 Theta current (%) 30 ## Vol. WP (mm): 60 Vol. FC (mm): 127 Vol. SAT (mm): 207 Vol. current (mm): 127 ## Temperature (Celsius): NA ## ## Total soil saturated capacity (mm): 325 ## Total soil water holding capacity (mm): 200 ## Total soil extractable water (mm): 126 ## Total soil current Volume (mm): 200 ## Water table depth (mm): 1000 ## ## Snow pack water equivalent (mm): 0 The modelled moisture content of the soil depends on the water retention curve used to represent the relationship between soil volumetric water content ($$\theta$$; %) and soil water potential ($$\Psi$$; MPa). By default the Saxton (model = "SX") equations are used to model the water retention curve, but the user may choose to follow Van Genuchten - Mualem equations, which will give slightly different values for the same texture: print(examplesoil, model="VG") ## Soil depth (mm): 1000 ## ## Layer 1 [ 0 to 300 mm ] ## clay (%): 25 silt (%): 50 sand (%): 25 organic matter (%): NA [ Silt loam ] ## Rock fragment content (%): 20 Macroporosity (%): 5 ## Theta WP (%): 13 Theta FC (%): 29 Theta SAT (%): 42 Theta current (%) 29 ## Vol. WP (mm): 32 Vol. FC (mm): 68 Vol. SAT (mm): 102 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 (%): 40 Macroporosity (%): 5 ## Theta WP (%): 13 Theta FC (%): 30 Theta SAT (%): 42 Theta current (%) 30 ## Vol. WP (mm): 54 Vol. FC (mm): 127 Vol. SAT (mm): 178 Vol. current (mm): 127 ## Temperature (Celsius): NA ## ## Total soil saturated capacity (mm): 280 ## Total soil water holding capacity (mm): 196 ## Total soil extractable water (mm): 128 ## Total soil current Volume (mm): 196 ## Water table depth (mm): 1000 ## ## Snow pack water equivalent (mm): 0 While Saxton equations use texture and organic matter as inputs, the Van Genuchten-Mualem equations need other parameters, which are estimated using pedotransfer functions and their names start with VG_ (two alternative options are provided in function soil to estimate Van Genuchten parameters). The following code calls function soil_retentionCurvePlot() to illustrate the difference between the two water retention models in this soil: soil_retentionCurvePlot(examplesoil, model="both") Low-level functions, such as soil_psi2thetaSX() and soil_psi2thetaVG() (and their counterparts soil_theta2psiSX() and soil_theta2psiVG()), can be used to calculate volumetric soil moisture from the water potential (and viceversa) using the two models. When simulating soil water balance, the user can choose among the two models (see control parameters below). ### Species-specific parameters Simulation models in medfate require a data frame with species parameter values. The package provides a default data set of parameter values for 89 Mediterranean species (rows), resulting from bibliographic search, fit to empirical data or expert-based guesses: data("SpParamsMED") These species commonly occur in the Spanish forest inventory of Catalonia, but may not be sufficient for other areas. A large number of parameters (columns) can be found in SpParamsMED: names(SpParamsMED) ## [1] "Name" "IFNcodes" "SpIndex" ## [4] "Group" "Order" "Family" ## [7] "GrowthForm" "Hmed" "Hmax" ## [10] "Z50" "Z95" "Zmax" ## [13] "a_ash" "a_bsh" "b_bsh" ## [16] "cr" "a_fbt" "b_fbt" ## [19] "c_fbt" "d_fbt" "a_cr" ## [22] "b_1cr" "b_2cr" "b_3cr" ## [25] "c_1cr" "c_2cr" "a_cw" ## [28] "b_cw" "PhenologyType" "LeafDuration" ## [31] "Sgdd" "SLA" "LeafDensity" ## [34] "r635" "pDead" "Al2As" ## [37] "WoodDensity" "LeafWidth" "minFMC" ## [40] "maxFMC" "LeafPI0" "LeafEPS" ## [43] "LeafAF" "StemPI0" "StemEPS" ## [46] "StemAF" "LigninPercent" "ParticleDensity" ## [49] "LeafLitterFuelType" "Flammability" "SAV" ## [52] "HeatContent" "gammaSWR" "alphaSWR" ## [55] "kPAR" "g" "Psi_Extract" ## [58] "Psi_Critic" "WUE" "pRootDisc" ## [61] "Gwmin" "Gwmax" "VCleaf_kmax" ## [64] "VCleaf_c" "VCleaf_d" "Kmax_stemxylem" ## [67] "VCstem_c" "VCstem_d" "Kmax_rootxylem" ## [70] "VCroot_c" "VCroot_d" "Narea" ## [73] "Vmax298" "Jmax298" "WoodC" ## [76] "RGRmax" "fHDmin" "fHDmax" Not all parameters are needed for all models. The user can find parameter definitions in the help page of this data set. However, to fully understand the role of parameters in the model, the user should read the details of model design and formulation (http://vegmod.ctfc.cat/software/medfate). ### Vegetation #### Forest plot data Models included in medfate were primarily designed to be ran on forest inventory plots. In this kind of data, the vegetation of a sampled area is described in terms of woody plants (trees and shrubs) along with their size and species identity. Forest plots in medfate are assumed to be in a format that follows closely the Spanish forest inventory. Each forest plot is represented in an object of class forest, a list that contains several elements. Among them, the most important items are two data frames, treeData (for trees) and shrubData for shrubs: data(exampleforestMED) exampleforestMED ##$ID
## [1] "1"
##
## $patchsize ## [1] 10000 ## ##$treeData
##   Species   N   DBH Height Z50  Z95
## 1      54 168 37.55    800 750 3000
## 2      68 384 14.60    660 750 3000
##
## $shrubData ## Species Cover Height Z50 Z95 ## 1 65 3.75 30 300 1500 ## ##$herbCover
## [1] 10
##
## $herbHeight ## [1] 20 ## ## attr(,"class") ## [1] "forest" "list" Trees are expected to be primarily described in terms of species, diameter (DBH) and height, whereas shrubs are described in terms of species, percent cover and mean height. #### Aboveground and belowground data Because the forest plot format is rather specific, simulation functions in medfate allow starting in a more general way using two data frames, one with aboveground information (i.e. the leave area and size of plants) and the other with belowground information (i.e. root distribution). The aboveground data frame does not distinguish between trees and shrubs. It includes, for each plant cohort to be considered in rows, its species identity, height and leaf area index (LAI). While users can build their input data themselves, we use function forest2aboveground() on the object exampleforestMED to show how should the data look like: above = forest2aboveground(exampleforestMED, SpParamsMED) above ## SP N DBH Cover H CR LAI_live LAI_expanded LAI_dead ## T1_54 54 168.000 37.55 NA 800 0.7150421 0.81670117 0.81670117 0 ## T2_68 68 384.000 14.60 NA 660 0.6055642 0.79779523 0.79779523 0 ## S1_65 65 5503.456 NA 3.75 30 0.9738889 0.08913325 0.08913325 0 Note that the call to forest2aboveground() included species parameters, because species-specific values are needed to calculate leaf area from tree diameters or shrub cover. Columns N, DBH and Cover are required for simulating growth, but not for soil water balance, which only requires columns SP, H (in cm), CR (i.e. the crown ratio), LAI_live, LAI_expanded and LAI_dead. Here plant cohorts are given unique codes that tell us whether they correspond to trees or shrubs, but the user can use other row identifiers as long as they are unique. In practice, the user only needs to worry to calculate the values for LAI_live. LAI_live and LAI_expanded can contain the same LAI values, and LAI_dead is normally zero. This is so because models update LAI_expanded and LAI_dead according to the leaf phenology of species. Aboveground leaf area distribution (with or without distinguishing among cohorts) can be examined by calling function vprofile_leafAreaDensity(): vprofile_leafAreaDensity(above, byCohorts = F) vprofile_leafAreaDensity(above, byCohorts = T) Regarding belowground information, a matrix describing for each plant cohort, the proportion of fine roots in each soil layer. As before, we use function forest2belowground() on the object exampleforestMED to show how should the data look like: below = forest2belowground(exampleforestMED, examplesoil, SpParamsMED) below ## 1 2 ## T1_54 0.1933638 0.8066362 ## T2_68 0.1933638 0.8066362 ## S1_65 0.5554389 0.4445611 Function forest2belowground() internally takes values of Z50 and Z95 and calls function root_ldrDistribution() to estimate the distribution of fine roots according to the linear dose response model. For example the first row is: root_ldrDistribution(exampleforestMED$treeData$Z50[1], exampleforestMED$treeData$Z95[1], examplesoil$dVec)
##           [,1]      [,2]
## [1,] 0.1933638 0.8066362

An analogous function root_conicDistribution() can be used to estimate fine root distribution according to a cone. The user is free to build any numeric matrix for root distribution, as long as values in rows sum always one (i.e. we have proportions). Otherwise, functions root_conicDistribution() and root_ldrDistribution() can be used to calculate root distribution under specific assumptions.

Users can visually inspect the distribution of fine roots of forest objects by calling function vprofile_rootDistribution():

vprofile_rootDistribution(exampleforestMED, SpParamsMED)

### Meteorological forcing

Soil water simulations require daily weather inputs. The weather variables that are required depend on the complexity of the soil water balance model we are using. In the simplest case, only mean temperature, precipitation and potential evapotranspiration is required, but the more complex simulation model also requires radiation, wind speed, min/max temparature and relative humitidy. Here we show an example of meteorological forcing data.

data(examplemeteo)
head(examplemeteo)
##            MeanTemperature MinTemperature MaxTemperature Precipitation
## 2001-01-01      3.57668969     -0.5934215       6.287950      4.869109
## 2001-01-02      1.83695972     -2.3662458       4.569737      2.498292
## 2001-01-03      0.09462563     -3.8541036       2.661951      0.000000
## 2001-01-04      1.13866156     -1.8744860       3.097705      5.796973
## 2001-01-05      4.70578690      0.3288287       7.551532      1.884401
## 2001-01-06      4.57036721      0.5461322       7.186784     13.359801
##            MeanRelativeHumidity MinRelativeHumidity MaxRelativeHumidity
## 2001-01-01             78.73709            65.15411           100.00000
## 2001-01-02             69.70800            57.43761            94.71780
## 2001-01-03             70.69610            58.77432            94.66823
## 2001-01-04             76.89156            66.84256            95.80950
## 2001-01-05             76.67424            62.97656           100.00000
## 2001-01-06             89.01940            74.25754           100.00000
## 2001-01-01  12.89251  2.000000           172 1.3212770
## 2001-01-02  13.03079  7.662544           278 2.2185985
## 2001-01-03  16.90722  2.000000           141 1.8045176
## 2001-01-04  11.07275  2.000000           172 0.9200627
## 2001-01-05  13.45205  7.581347           321 2.2914449
## 2001-01-06  12.84841  6.570501           141 1.7255058

Simulation models in medfate have been designed to work along with data generated from package meteoland. The user is strongly recommended to resort to this package to obtain suitable weather input for soil water balance simulations.

### Simulation control

Apart from data inputs, the behaviour of simulation models can be controlled using a set of global parameters. The default parameterization is obtained using function defaultControl():

control = defaultControl()
control
## $verbose ## [1] TRUE ## ##$subdailyResults
## [1] FALSE
##
## $defaultWindSpeed ## [1] 2.5 ## ##$soilFunctions
## [1] "SX"
##
## $snowpack ## [1] TRUE ## ##$drainage
## [1] TRUE
##
## $unlimitedSoilWater ## [1] FALSE ## ##$plantWaterPools
## [1] FALSE
##
## $poolOverlapFactor ## [1] 0.5 ## ##$leafPhenology
## [1] TRUE
##
## $unfoldingDD ## [1] 300 ## ##$transpirationMode
## [1] "Granier"
##
## $cavitationRefill ## [1] "total" ## ##$refillMaximumRate
## [1] 0.05
##
## $verticalLayerSize ## [1] 100 ## ##$gainModifier
## [1] 1
##
## $costModifier ## [1] 1 ## ##$costWater
## [1] "dEdP"
##
## $cochard ## [1] FALSE ## ##$capacitance
## [1] FALSE
##
## $klatstem ## [1] 0.01 ## ##$klatleaf
## [1] 0.01
##
## $taper ## [1] TRUE ## ##$numericParams
## $numericParams$maxNsteps
## [1] 400
##
## $numericParams$ntrial
## [1] 200
##
## $numericParams$psiTol
## [1] 1e-04
##
## $numericParams$ETol
## [1] 1e-07
##
##
## $fracLeafResistance ## [1] NA ## ##$fracRootResistance
## [1] 0.4
##
## $averageFracRhizosphereResistance ## [1] 0.15 ## ##$Catm
## [1] 386
##
## $ndailysteps ## [1] 24 ## ##$thermalCapacityLAI
## [1] 1e+06
##
## $allocationStrategy ## [1] "Plant_kmax" ## ##$nonStomatalPhotosynthesisLimitation
## [1] TRUE
##
## $k_floem ## [1] 3e-05 ## ##$nonSugarConc
## [1] 0.3
##
## $minimumSugarConc ## [1] 0.3 ## ##$equilibriumLeafTotalConc
## [1] 0.8
##
## $equilibriumSapwoodTotalConc ## [1] 0.6 Most of these parameters should normally be left to their default value. However, there are three that deserve explanation here: 1. Console output can be turned off by setting verbose = FALSE. 2. The soil water retention curves can be switched between Saxton’s and Van Genuchten’s using parameter soilFunctions. 3. The complexity of the soil water balance calculations will be very different if we set transpirationMode = "Sperry". Most of the other options apply in the case of advanced soil water balance only. ### Water balance input object A last step is needed before calling simulation functions. It consists in the compilation of all aboveground and belowground parameters and the specification of additional parameter values for each plant cohort, such as their light extinction coefficient or their response to drought. This is done by calling function spwbInput() and taking species parameter values from species parameter data: x = spwbInput(above, below, examplesoil, SpParamsMED, control) Different parameter variables will be drawn depending on the value of transpirationMode. For the simple water balance model (transpirationMode = "Granier"), relatively few parameters are needed. All the input information for forest data and species parameter values can be inspected by accessing the different elements of this object, whose names are. names(x) ## [1] "control" "canopy" "cohorts" ## [4] "above" "below" "paramsPhenology" ## [7] "paramsInterception" "paramsTranspiration" "internalPhenology" ## [10] "internalWater" As with the soil input object, the spwbInput object will be modified during simulations. In the case of soil water balance, these modifications are small, for example concerning LAI_expanded, but in the case of growth simulations the object is used to store the status of vegetation during and at the end of simulations. If one has a forest object, the spwbInput object can be generated in directly from it, avoiding the need to explicitly build aboveground and belowground data frames: x = forest2spwbInput(exampleforestMED, examplesoil, SpParamsMED, control) Finally, note that one can play with plant-specific parameters for soil water balance (instead of using species-level values) by modifying manually the parameter values in this object. ## Executing the soil water balance model ### Water balance for a single day Soil water balance simulations will normally span periods of several months or years, but since the model operates at a daily temporal scale, it is possible to perform soil water balance for one day only. This is done using function spwb_day(). In the following code we select day 100 from the meteorological input data and perform soil water balance for that day only: d = 100 sd1<-spwb_day(x, examplesoil, rownames(examplemeteo)[d], examplemeteo$MinTemperature[d], examplemeteo$MaxTemperature[d], examplemeteo$MinRelativeHumidity[d], examplemeteo$MaxRelativeHumidity[d], examplemeteo$Radiation[d], examplemeteo$WindSpeed[d], latitude = 41.82592, elevation = 100, slope= 0, aspect = 0, prec = examplemeteo$Precipitation[d])

Function spwb_day() is most useful when working with the complex transpiration model. This is why so many meteorological variables are required. The output of spwb_day() is a list with five elements:

names(sd1)
## [1] "cohorts"      "WaterBalance" "Soil"         "Stand"        "Plants"
• cohorts: Table with the species code and species name of each cohort.
• WaterBalance: Contains the soil water balance flows (precipitation, infiltration, transpiration, …)
• Soil: Contains output values by soil layer (i.e. water evaporated from each soil layer, water transpired from each soil layer and the final soil water potential).
• Stand: A list with stand LAI (expanded and dead leaves), canopy water retention capacity and the proportion of light (SWR or PAR) reaching the ground.
• Plants: Contains output values by plant cohort (i.e. LAI values, transpiration, water potential, drought stress index, …).
sd1
## $cohorts ## SP Name ## T1_54 54 Pinus halepensis ## T2_68 68 Quercus ilex ## S1_65 65 Quercus coccifera ## ##$WaterBalance
##             PET            Rain            Snow         NetRain        Snowmelt
##        5.023347        0.000000        0.000000        0.000000        0.000000
##           Runon    Infiltration          Runoff    DeepDrainage SoilEvaporation
##        0.000000        0.000000        0.000000        0.000000        0.500000
## PlantExtraction   Transpiration
##        1.059282        1.059282
##
## $Soil ## SoilEvaporation PlantExtraction psi ## 1 4.999998e-01 0.2198806 -0.03470558 ## 2 1.529512e-07 0.8394017 -0.03412495 ## ##$Stand
##         LAI     LAIlive LAIexpanded     LAIdead          Cm  LgroundPAR
##   1.7036297   1.7036297   1.7036297   0.0000000   1.2378821   0.4081334
##  LgroundSWR
##   0.5148791
##
## $Plants ## LAI AbsorbedSWRFraction Transpiration Photosynthesis PlantPsi ## T1_54 0.81670117 0.23326063 0.50933402 0.95230789 -0.03323346 ## T2_68 0.79779523 0.23281954 0.50837202 0.95050922 -0.03323346 ## S1_65 0.08913325 0.01904071 0.04157628 0.07773567 -0.03366199 ## DDS StemPLC ## T1_54 3.180250e-06 1.873538e-07 ## T2_68 9.422974e-07 7.019131e-08 ## S1_65 4.131091e-07 5.289597e-08 ## ## attr(,"class") ## [1] "spwb_day" "list" ### Water balance for multiple days Most often, users will use function spwb() to run the soil water balance model. This function requires the spwbInput object, the soil object and the meteorological data frame. However, function spwb_day() modified the state variables of the input objects. In particular, the values of soil moisture are now: examplesoil$W
## [1] 0.9901135 0.9934126

We simply reset state variables to their default values so that new simulations are not affected by the end state of the previous simulation:

resetInputs(x, examplesoil)
examplesoil$W ## [1] 1 1 Now we are ready to call function spwb(): S = spwb(x, examplesoil, examplemeteo, latitude = 41.82592, elevation = 100) ## Initial soil water content (mm): 200.239 ## Initial snowpack content (mm): 0 ## Performing daily simulations .....................................done. ## Final soil water content (mm): 180.074 ## Final snowpack content (mm): 0 ## Change in soil water content (mm): -20.1648 ## Soil water balance result (mm): -20.1648 ## Change in snowpack water content (mm): 0 ## Snowpack water balance result (mm): 7.10543e-15 ## Water balance components: ## Precipitation (mm) 513 ## Rain (mm) 462 Snow (mm) 51 ## Interception (mm) 86 Net rainfall (mm) 376 ## Infiltration (mm) 419 Runoff (mm) 8 Deep drainage (mm) 102 ## Soil evaporation (mm) 40 Transpiration (mm) 297 Function spwb() returns an object of class with the same name, actually a list: class(S) ## [1] "spwb" "list" If we inspect its elements, we realize that the output is arranged differently than in spwb_day(): names(S) ## [1] "latitude" "topography" "spwbInput" "soilInput" "WaterBalance" ## [6] "Soil" "Stand" "Plants" "subdaily" In particular, element spwbInput contains a copy of the input parameters that were used to run the model: names(S$spwbInput)
##  [1] "control"             "canopy"              "cohorts"
##  [4] "above"               "below"               "paramsPhenology"
##  [7] "paramsInterception"  "paramsTranspiration" "internalPhenology"
## [10] "internalWater"

As before, WaterBalance contains water balance components, but in this case in form of a data frame with days in rows:

head(S$WaterBalance) ## PET Precipitation Rain Snow NetRain Snowmelt ## 2001-01-01 1.3212770 4.869109 4.869109 0 3.5484558 0 ## 2001-01-02 2.2185985 2.498292 2.498292 0 1.2082359 0 ## 2001-01-03 1.8045176 0.000000 0.000000 0 0.0000000 0 ## 2001-01-04 0.9200627 5.796973 5.796973 0 4.4873578 0 ## 2001-01-05 2.2914449 1.884401 1.884401 0 0.7690871 0 ## 2001-01-06 1.7255058 13.359801 13.359801 0 11.7730718 0 ## Infiltration Runoff DeepDrainage Evapotranspiration Interception ## 2001-01-01 3.5484558 0 3.5484558 2.0992731 1.320653 ## 2001-01-02 1.2082359 0 0.4296158 2.2578956 1.290056 ## 2001-01-03 0.0000000 0 0.0000000 0.5622185 0.000000 ## 2001-01-04 4.4873578 0 2.9572994 1.9773515 1.309615 ## 2001-01-05 0.7690871 0 0.1013507 2.0985155 1.115314 ## 2001-01-06 11.7730718 0 10.7898706 2.4505894 1.586729 ## SoilEvaporation PlantExtraction Transpiration ## 2001-01-01 0.5000000 0.2786201 0.2786201 ## 2001-01-02 0.5000000 0.4678399 0.4678399 ## 2001-01-03 0.1816966 0.3805219 0.3805219 ## 2001-01-04 0.4737211 0.1940153 0.1940153 ## 2001-01-05 0.5000000 0.4832012 0.4832012 ## 2001-01-06 0.5000000 0.3638606 0.3638606 Element Plants is in turn a list with several dataframes with plant output variables, for example plant water potentials are in: head(S$Plants\$PlantPsi)
##                  T1_54       T2_68       S1_65
## 2001-01-01 -0.03323346 -0.03323346 -0.03366199
## 2001-01-02 -0.03323346 -0.03323346 -0.03366199
## 2001-01-03 -0.03376257 -0.03376257 -0.03425914
## 2001-01-04 -0.03322061 -0.03322061 -0.03362600
## 2001-01-05 -0.03323346 -0.03323346 -0.03366199
## 2001-01-06 -0.03323346 -0.03323346 -0.03366199

## Inspecting model outputs

### Plots

Package medfate provides a simple plot function for objects of class spwb. It can be used to show meteorological inputs, snow dynamics, and different components of the water balance:

plot(S, type = "PET_Precipitation")

plot(S, type = "Snow")

plot(S, type = "Export")

plot(S, type = "Evapotranspiration")

Function plot is also allows displaying soil moisture dynamics by layer, which can be done in four different ways (the first two only imply a change in axis units):

plot(S, type="SoilTheta")

plot(S, type="SoilRWC")

plot(S, type="SoilPsi")

plot(S, type="SoilVol")

Finally, the same function can also be used to draw the dynamics of plant variables by cohorts, such as transpiration, photosynthesis, water potential or drought stress:

plot(S, type="PlantTranspiration")

plot(S, type="PlantPhotosynthesis")

plot(S, type="PlantPsi")

plot(S, type="PlantStress")

### General summaries

While the simulation model uses daily steps, users will normally be interested in outputs at larger time scales. The package provides a summary for objects of class spwb. This function can be used to summarize the model’s output at different temporal steps (i.e. weekly, annual, …). For example, to obtain the average soil moisture and water potentials by months one can use:

summary(S, freq="months",FUN=mean, output="Soil")
##                  W.1       W.2     ML.1      ML.2    MLTot  WTD        SWE
## 2001-01-01 0.9923595 0.9946380 72.25784 126.74155 198.9994 1000 1.65056874
## 2001-02-01 0.9722004 0.9490880 70.78997 120.93736 191.7273 1000 0.27480347
## 2001-03-01 0.9755743 0.9655497 71.03564 123.03498 194.0706 1000 0.01762496
## 2001-04-01 0.9565790 0.8594280 69.65251 109.51245 179.1650 1000 0.57895858
## 2001-05-01 0.9512671 0.8579857 69.26573 109.32866 178.5944 1000 0.00000000
## 2001-06-01 0.8417696 0.6307868 61.29276  80.37789 141.6707 1000 0.00000000
## 2001-07-01 0.9617828 0.6812872 70.03142  86.81289 156.8443 1000 0.00000000
## 2001-08-01 0.9650039 0.7572466 70.26596  96.49200 166.7580 1000 0.00000000
## 2001-09-01 0.9656532 0.7960595 70.31324 101.43773 171.7510 1000 0.00000000
## 2001-10-01 0.9776325 0.8191173 71.18551 104.37587 175.5614 1000 0.00000000
## 2001-11-01 0.9725404 0.9181768 70.81473 116.99850 187.8132 1000 2.59388333
## 2001-12-01 0.9420283 0.9279813 68.59302 118.24785 186.8409 1000 0.00000000
##            PlantExt.1 PlantExt.2       psi.1       psi.2
## 2001-01-01 0.06279442  0.2397198 -0.03442455 -0.03403850
## 2001-02-01 0.13098704  0.5000464 -0.03840637 -0.04442603
## 2001-03-01 0.13610495  0.5195848 -0.03738241 -0.03980571
## 2001-04-01 0.17368500  0.6630368 -0.04158021 -0.07383315
## 2001-05-01 0.20500680  0.7825939 -0.04372972 -0.07792979
## 2001-06-01 0.29226641  1.1049109 -0.08166422 -0.45297218
## 2001-07-01 0.24669859  0.9250461 -0.04097378 -0.41334200
## 2001-08-01 0.24924014  0.9512990 -0.03963392 -0.14518992
## 2001-09-01 0.19561083  0.7467052 -0.03971937 -0.10766906
## 2001-10-01 0.14031223  0.5356091 -0.03722651 -0.09935373
## 2001-11-01 0.10134938  0.3869015 -0.03820875 -0.05381694
## 2001-12-01 0.09479172  0.3618699 -0.04520289 -0.04946813

Parameter output is used to indicate the element of the spwb object for which we desire summaries. Similarly, it is possible to calculate the average stress of plant cohorts by months:

summary(S, freq="months",FUN=mean, output="PlantStress")
##                   T1_54        T2_68        S1_65
## 2001-01-01 3.358745e-06 9.951850e-07 4.273993e-07
## 2001-02-01 7.158922e-06 2.121169e-06 7.644482e-07
## 2001-03-01 5.328383e-06 1.578784e-06 6.176675e-07
## 2001-04-01 2.908813e-05 8.618828e-06 2.348265e-06
## 2001-05-01 4.149387e-05 1.229491e-05 3.276638e-06
## 2001-06-01 1.126754e-02 3.395177e-03 7.953414e-04
## 2001-07-01 2.173590e-02 6.692002e-03 1.571148e-03
## 2001-08-01 2.547518e-04 7.549746e-05 1.785116e-05
## 2001-09-01 8.835333e-05 2.618004e-05 6.391803e-06
## 2001-10-01 9.117433e-05 2.701640e-05 6.526256e-06
## 2001-11-01 1.464774e-05 4.340110e-06 1.283750e-06
## 2001-12-01 1.004267e-05 2.975618e-06 1.139216e-06

The summary function can be also used to aggregate the output by species. In this case, the values of plant cohorts belonging to the same species will be averaged using LAI values as weights. For example, we may average the daily drought stress across cohorts of the same species (here there is only one cohort by species, so this does not modify the output):

head(summary(S, freq="day", output="PlantStress", bySpecies = TRUE))
##            Pinus halepensis Quercus coccifera Quercus ilex
## 2001-01-01     3.180250e-06      4.131091e-07 9.422974e-07
## 2001-01-02     3.180250e-06      4.131091e-07 9.422974e-07
## 2001-01-03     3.334580e-06      4.354867e-07 9.880249e-07
## 2001-01-04     3.176564e-06      4.117855e-07 9.412052e-07
## 2001-01-05     3.180250e-06      4.131091e-07 9.422974e-07
## 2001-01-06     3.180250e-06      4.131091e-07 9.422974e-07

Or we can combine the aggregation by species with a temporal aggregation (here monthly averages):

summary(S, freq="month", FUN = mean, output="PlantStress", bySpecies = TRUE)
##            Pinus halepensis Quercus coccifera Quercus ilex
## 2001-01-01     3.358745e-06      4.273993e-07 9.951850e-07
## 2001-02-01     7.158922e-06      7.644482e-07 2.121169e-06
## 2001-03-01     5.328383e-06      6.176675e-07 1.578784e-06
## 2001-04-01     2.908813e-05      2.348265e-06 8.618828e-06
## 2001-05-01     4.149387e-05      3.276638e-06 1.229491e-05
## 2001-06-01     1.126754e-02      7.953414e-04 3.395177e-03
## 2001-07-01     2.173590e-02      1.571148e-03 6.692002e-03
## 2001-08-01     2.547518e-04      1.785116e-05 7.549746e-05
## 2001-09-01     8.835333e-05      6.391803e-06 2.618004e-05
## 2001-10-01     9.117433e-05      6.526256e-06 2.701640e-05
## 2001-11-01     1.464774e-05      1.283750e-06 4.340110e-06
## 2001-12-01     1.004267e-05      1.139216e-06 2.975618e-06

### Specific output functions

The package provides some functions to extract or transform specific outputs from soil plant water balance simulations. In particular, function spwb_stress() allows calculating several plant stress indices, such as the number of days with drought stress > 0.5 or the maximum drought stress:

spwb_stress(S, index = "NDD", freq = "years", draw=FALSE)
##            T1_54 T2_68 S1_65
## 2001-01-01     0     0     0
spwb_stress(S, index = "MDS", freq = "years", draw=FALSE)
##                T1_54      T2_68      S1_65
## 2001-01-01 0.1128189 0.03521686 0.00829781

As the general summary function, spwb_stress() allows calculating stress indices at several temporal scales. For example the water stress index (integral of water potential values) can be calculated and drawn for every month:

spwb_stress(S, index = "WSI", freq = "months", draw=TRUE)

Another specific summary function is spwb_waterUseEfficiency(). This is most useful with advanced water and energy balance modeling, but for simple water balance it calculates the ratio between photosynthesis and transpiration at the desired scale:

spwb_waterUseEfficiency(S, type = "Stand An/E", freq = "months", draw=FALSE)
## 2001-01-01 2001-02-01 2001-03-01 2001-04-01 2001-05-01 2001-06-01 2001-07-01
##  0.4831519  0.9739391  1.6897987  1.4888226  3.0347218  4.3449522  4.5352974
## 2001-08-01 2001-09-01 2001-10-01 2001-11-01 2001-12-01
##  5.0114097  3.2328888  3.2968806  1.0235078  0.8007527