Skip to contents

About this vignette

This document describes how to run a water and energy balance model that uses a more detailed approach for hydraulics and stomatal regulation described in De Cáceres et al. (2021) and Ruffault et al. (2022). We recommend reading vignette Basic water balance before this one for a more accessible introduction to soil water balance modelling. This vignette is meant to teach users to run the simulation model within R. All the details of the model design and formulation can be found at the medfatebook.

Preparing model inputs

Model inputs are explained in greater detail in vignettes Understanding model inputs and Preparing model inputs. Here we only review the different steps required to run function spwb().

Soil, vegetation, meteorology and species data

Soil information needs to be entered as a data frame with soil layers in rows and physical attributes in columns. Soil physical attributes can be initialized to default values, for a given number of layers, using function defaultSoilParams():

examplesoil <- defaultSoilParams(4)
examplesoil
##   widths clay sand om nitrogen  bd rfc
## 1    300   25   25 NA       NA 1.5  25
## 2    700   25   25 NA       NA 1.5  45
## 3   1000   25   25 NA       NA 1.5  75
## 4   2000   25   25 NA       NA 1.5  95

As explained in the package overview, models included in medfate were primarily designed to be ran on forest inventory plots. Here we use the example object provided with the package:

data(exampleforest)
exampleforest
## $treeData
##            Species   N   DBH Height Z50  Z95
## 1 Pinus halepensis 168 37.55    800 100  600
## 2     Quercus ilex 384 14.60    660 300 1000
## 
## $shrubData
##             Species Cover Height Z50  Z95
## 1 Quercus coccifera  3.75     80 200 1000
## 
## $herbCover
## [1] 10
## 
## $herbHeight
## [1] 20
## 
## $seedBank
## [1] Species Percent
## <0 rows> (or 0-length row.names)
## 
## attr(,"class")
## [1] "forest" "list"

Importantly, a data frame with daily weather for the period to be simulated is required. Here we use the default data frame included with the package:

data(examplemeteo)
head(examplemeteo)
##        dates MinTemperature MaxTemperature Precipitation MinRelativeHumidity
## 1 2001-01-01     -0.5934215       6.287950      4.869109            65.15411
## 2 2001-01-02     -2.3662458       4.569737      2.498292            57.43761
## 3 2001-01-03     -3.8541036       2.661951      0.000000            58.77432
## 4 2001-01-04     -1.8744860       3.097705      5.796973            66.84256
## 5 2001-01-05      0.3288287       7.551532      1.884401            62.97656
## 6 2001-01-06      0.5461322       7.186784     13.359801            74.25754
##   MaxRelativeHumidity Radiation WindSpeed
## 1           100.00000  12.89251  2.000000
## 2            94.71780  13.03079  7.662544
## 3            94.66823  16.90722  2.000000
## 4            95.80950  11.07275  2.000000
## 5           100.00000  13.45205  7.581347
## 6           100.00000  12.84841  6.570501

Finally, simulations in medfate require a data frame with species parameter values, which we load using defaults for Catalonia (NE Spain):

data("SpParamsMED")

Simulation control

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

control <- defaultControl("Sperry")

To use the advanced water balance model we must change the values of transpirationMode to switch from "Granier" to either "Sperry" or "Sureau".

Since we will be inspecting subdaily results, we need to set the flag to obtain subdaily output:

control$subdailyResults <- TRUE

Water balance input object

A last object is needed before calling simulation functions, called spwbInput. It consists in the compilation of aboveground, belowground parameters and the specification of additional parameter values for each plant cohort. This is done by calling function spwbInput():

x <- spwbInput(exampleforest, examplesoil, SpParamsMED, control)

The spwbInput object for advanced water and energy balance is similar to that of simple water balance simulations, but contains more elements. Information about the cohort species is found in element cohorts, i.e. the cohort code, the species index and species name:

x$cohorts
##         SP              Name
## T1_148 148  Pinus halepensis
## T2_168 168      Quercus ilex
## S1_165 165 Quercus coccifera

Element soil contains soil layer parameters and state variables (moisture and temperature):

x$soil
##   widths sand clay      usda om nitrogen  bd rfc  macro     Ksat VG_alpha
## 1    300   25   25 Silt loam NA       NA 1.5  25 0.0485 5401.471 89.16112
## 2    700   25   25 Silt loam NA       NA 1.5  45 0.0485 5401.471 89.16112
## 3   1000   25   25 Silt loam NA       NA 1.5  75 0.0485 5401.471 89.16112
## 4   2000   25   25 Silt loam NA       NA 1.5  95 0.0485 5401.471 89.16112
##       VG_n VG_theta_res VG_theta_sat W Temp
## 1 1.303861        0.041     0.423715 1   NA
## 2 1.303861        0.041     0.423715 1   NA
## 3 1.303861        0.041     0.423715 1   NA
## 4 1.303861        0.041     0.423715 1   NA

As an aside, the columns in x$soil that were not present in the input data frame examplesoil are created by an internal call to a soil initialization function called soil().

Element canopy contains state variables within the canopy:

x$canopy
##    zlow zmid  zup LAIlive LAIexpanded LAIdead Tair Cair VPair
## 1     0   50  100      NA          NA      NA   NA   NA    NA
## 2   100  150  200      NA          NA      NA   NA   NA    NA
## 3   200  250  300      NA          NA      NA   NA   NA    NA
## 4   300  350  400      NA          NA      NA   NA   NA    NA
## 5   400  450  500      NA          NA      NA   NA   NA    NA
## 6   500  550  600      NA          NA      NA   NA   NA    NA
## 7   600  650  700      NA          NA      NA   NA   NA    NA
## 8   700  750  800      NA          NA      NA   NA   NA    NA
## 9   800  850  900      NA          NA      NA   NA   NA    NA
## 10  900  950 1000      NA          NA      NA   NA   NA    NA
## 11 1000 1050 1100      NA          NA      NA   NA   NA    NA
## 12 1100 1150 1200      NA          NA      NA   NA   NA    NA
## 13 1200 1250 1300      NA          NA      NA   NA   NA    NA
## 14 1300 1350 1400      NA          NA      NA   NA   NA    NA
## 15 1400 1450 1500      NA          NA      NA   NA   NA    NA
## 16 1500 1550 1600      NA          NA      NA   NA   NA    NA
## 17 1600 1650 1700      NA          NA      NA   NA   NA    NA
## 18 1700 1750 1800      NA          NA      NA   NA   NA    NA
## 19 1800 1850 1900      NA          NA      NA   NA   NA    NA
## 20 1900 1950 2000      NA          NA      NA   NA   NA    NA
## 21 2000 2050 2100      NA          NA      NA   NA   NA    NA
## 22 2100 2150 2200      NA          NA      NA   NA   NA    NA
## 23 2200 2250 2300      NA          NA      NA   NA   NA    NA
## 24 2300 2350 2400      NA          NA      NA   NA   NA    NA
## 25 2400 2450 2500      NA          NA      NA   NA   NA    NA
## 26 2500 2550 2600      NA          NA      NA   NA   NA    NA
## 27 2600 2650 2700      NA          NA      NA   NA   NA    NA
## 28 2700 2750 2800      NA          NA      NA   NA   NA    NA

Canopy temperature, water vapour pressure and CO2CO_2 concentration are state variables needed for canopy energy balance. If the canopy energy balance assumes a single canopy layer, the same values will be assumed through the canopy. Variation of within-canopy state variables is modelled if a multi-canopy energy balance is used (see control parameter multiLayerBalance).

As you may already known, element above contains the aboveground structure data that we already know:

x$above
##          H        CR   LAI_live LAI_expanded LAI_dead ObsID
## T1_148 800 0.6605196 0.84874773   0.84874773        0  <NA>
## T2_168 660 0.6055642 0.70557382   0.70557382        0  <NA>
## S1_165  80 0.8032817 0.03062604   0.03062604        0  <NA>

Belowground parameters can be seen in below:

x$below
##        Z50  Z95 Z100
## T1_148 100  600   NA
## T2_168 300 1000   NA
## S1_165 200 1000   NA

and in belowLayers:

x$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
## 
## $L
##               1        2        3        4
## T1_148 2289.062 1566.552 2250.052 4226.166
## T2_168 1817.571 2100.346 2410.127 4285.194
## S1_165 1085.030 1380.808 2170.587 4146.637
## 
## $VGrhizo_kmax
##               1        2         3         4
## T1_148 11478618  1593494  201562.5  65957.49
## T2_168 36121247 32493859 2931286.8 566975.78
## S1_165 10941459  4405482  574055.7 169670.90
## 
## $VCroot_kmax
##               1         2          3           4
## T1_148 2.382795 0.4833484 0.04256689 0.007416044
## T2_168 1.568929 1.2213562 0.09601747 0.010445417
## S1_165 2.407779 0.7618041 0.06314806 0.009770000
## 
## $Wpool
##        1 2 3 4
## T1_148 1 1 1 1
## T2_168 1 1 1 1
## S1_165 1 1 1 1
## 
## $RhizoPsi
##             1      2      3      4
## T1_148 -0.033 -0.033 -0.033 -0.033
## T2_168 -0.033 -0.033 -0.033 -0.033
## S1_165 -0.033 -0.033 -0.033 -0.033

The spwbInputobject also includes cohort parameter values for several kinds of traits. For example, plant anatomy parameters are described in paramsAnatomy:

x$paramsAnatomy
##        Hmed    Al2As      SLA LeafWidth LeafDensity WoodDensity FineRootDensity
## T1_148  850 1317.523 5.140523 0.1384772   0.2982842   0.6077016       0.2982842
## T2_168  500 3908.823 6.340000 1.7674359   0.4893392   0.9008264       0.4893392
## S1_165   80 4189.325 4.980084 1.3761085   0.3709679   0.4389106       0.3709679
##        conduit2sapwood      SRL RLD     r635
## T1_148       0.9236406 3172.572  10 1.964226
## T2_168       0.6238125 4398.812  10 1.805872
## S1_165       0.6238125 4398.812  10 2.289452

Parameters related to plant transpiration and photosynthesis can be seen in paramsTranspiration:

x$paramsTranspiration
##             Gswmin    Gswmax  Vmax298  Jmax298 Kmax_stemxylem Kmax_rootxylem
## T1_148 0.003086667 0.2850000 72.19617 124.1687           0.15           0.60
## T2_168 0.004473333 0.2007222 68.51600 118.7863           0.40           1.60
## S1_165 0.010455247 0.2830167 62.78100 118.4486           0.29           1.16
##        VCleaf_kmax VCleafapo_kmax  VCleaf_c  VCleaf_d kleaf_symp VCstem_kmax
## T1_148    4.000000        8.00000 11.137050 -2.380849    8.00000    1.339563
## T2_168    4.000000        8.00000  1.339370 -2.582279    8.00000    1.620936
## S1_165    9.579077       19.15815  2.254991 -3.133381   19.15815    4.599269
##         VCstem_c  VCstem_d VCroot_kmax  VCroot_c  VCroot_d VGrhizo_kmax
## T1_148 12.709999 -5.290000    2.916127 11.137050 -3.065569     13339632
## T2_168  3.560000 -7.720000    2.896748  1.339370 -2.214081     72113368
## S1_165  3.095442 -7.857378    3.242501  1.402489 -1.523324     16090667
##        Plant_kmax   FR_leaf   FR_stem   FR_root
## T1_148  0.7465846 0.1866462 0.5573346 0.2560193
## T2_168  0.8249857 0.2062464 0.5089563 0.2847972
## S1_165  1.5867376 0.1656462 0.3449978 0.4893561

Parameters related to pressure-volume curves and water storage capacity of leaf and stem organs are in paramsWaterStorage:

x$paramsWaterStorage
##           maxFMC   LeafPI0   LeafEPS LeafAF     Vleaf   StemPI0   StemEPS
## T1_148 126.03063 -1.591429  8.918571 0.3525 0.5258525 -2.008039 13.256355
## T2_168  93.15304 -1.483333 19.260000 0.1700 0.2199087 -3.227438 46.420610
## S1_165  96.53441 -2.370000 17.230000 0.2400 0.4108968 -1.305868  6.297155
##           StemAF Vsapwood
## T1_148 0.9236406 6.174277
## T2_168 0.6238125 1.278142
## S1_165 0.6238125 1.064511

Finally, remember 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.

Static analysis of sub-models

Before using the advanced water and energy balance model, is important to understand the parameters that influence the different sub-models. Package medfate provides low-level functions corresponding to sub-models (light extinction, hydraulics, transpiration, photosynthesis…). In addition, there are several high-level plotting functions that allow examining several aspects of these processes.

Vulnerability curves

Given a spwbInput object, we can use function hydraulics_vulnerabilityCurvePlot() to inspect vulnerability curves (i.e. how hydraulic conductance of a given segment changes with the water potential) for each plant cohort and each of the different segments of the soil-plant hydraulic network: rhizosphere, roots, stems and leaves:

hydraulics_vulnerabilityCurvePlot(x, examplesoil, type="rhizo")

The maximum values and shape of vulnerability curves for leaves and stems are regulated by parameters in paramsTranspiration. Roots have vulnerability curve parameters in the same data frame, but maximum conductance values need to be specified for each soil layer and are given in belowLayers$VCroot_kmax. Note that the last call to hydraulics_vulnerabilityCurvePlot() includes a soil object. This is because the van Genuchten parameters that define the shape of the vulnerability curve for the rhizosphere are stored in this object. Maximum conductance values in the rhizosphere are given in belowLayers$VGrhizo_kmax.

Supply functions

The vulnerability curves conforming the hydraulic network are used in the model to build the supply function, which relates water flow (i.e. transpiration) with the drop of water potential along the whole hydraulic pathway. The supply function contains not only these two variables, but also the water potential of intermediate nodes in the the hydraulic network. Function hydraulics_supplyFunctionPlot() can be used to inspect any of this variables:

Calls to hydraulics_supplyFunctionPlot() always need both a spwbInput object and a soil object. The soil moisture state (i.e. its water potential) is the starting point for the calculation of the supply function, so different curves will be obtained for different values of soil moisture.

Stomatal regulation and photosynthesis

The soil water balance model determines stomatal conductance and transpiration separately for sunlit and shade leaves. Stomatal conductance is determined after building a photosynthesis function corresponding to the supply function and finding the value of stomatal conductance that maximizes carbon revenue while avoiding hydraulic damage (a profit-maximization approach). Given a meteorological and soil inputs and a chosen day and timestep, function transp_stomatalRegulationPlot() allows displaying the supply and photosynthesis curves for sunlit and shade leaves, along with an indication of the values corresponding to the chosen stomatal aperture:

d <- 100
transp_stomatalRegulationPlot(x, examplemeteo, day = d, timestep=12,
                              latitude = 41.82592, elevation = 100, type="E")
## Package 'meteoland' [ver. 2.2.2]

transp_stomatalRegulationPlot(x, examplemeteo, day = d, timestep=12,
                              latitude = 41.82592, elevation = 100, type="An")

transp_stomatalRegulationPlot(x, examplemeteo, day = d, timestep=12,
                              latitude = 41.82592, elevation = 100, type="Gsw")

transp_stomatalRegulationPlot(x, examplemeteo, day = d, timestep=12,
                              latitude = 41.82592, elevation = 100, type="T")

transp_stomatalRegulationPlot(x, examplemeteo, day = d, timestep=12,
                              latitude = 41.82592, elevation = 100, type="VPD")

Pressure volume curves

moisture_pressureVolumeCurvePlot(x, segment="leaf", fraction="symplastic")

moisture_pressureVolumeCurvePlot(x, segment="leaf", fraction="apoplastic")

moisture_pressureVolumeCurvePlot(x, segment="stem", fraction="symplastic")

moisture_pressureVolumeCurvePlot(x, segment="stem", fraction="apoplastic")

Water balance for a single day

Running the model

Soil water balance simulations will normally span periods of several months or years, but since the model operates at a daily and subdaily temporal scales, 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 the same day as before from the meteorological input data and perform soil water balance for that day only:

date <- examplemeteo$dates[d]
meteovec <- unlist(examplemeteo[d,])
sd1<-spwb_day(x, date, meteovec, 
             latitude = 41.82592, elevation = 100, slope= 0, aspect = 0)

The output of spwb_day() is a list with several elements:

names(sd1)
##  [1] "cohorts"            "topography"         "weather"           
##  [4] "WaterBalance"       "EnergyBalance"      "Soil"              
##  [7] "Stand"              "Plants"             "SunlitLeaves"      
## [10] "ShadeLeaves"        "RhizoPsi"           "ExtractionInst"    
## [13] "PlantsInst"         "RadiationInputInst" "SunlitLeavesInst"  
## [16] "ShadeLeavesInst"    "LightExtinction"    "LWRExtinction"     
## [19] "CanopyTurbulence"

Water balance output

Element WaterBalance contains the soil water balance flows of the day (precipitation, infiltration, transpiration, …)

sd1$WaterBalance
##                     PET                    Rain                    Snow 
##              3.90233421              0.00000000              0.00000000 
##                 NetRain                Snowmelt                   Runon 
##              0.00000000              0.00000000              0.00000000 
##            Infiltration      InfiltrationExcess        SaturationExcess 
##              0.00000000              0.00000000              0.00000000 
##                  Runoff            DeepDrainage         CapillarityRise 
##              0.00000000              0.00000000              0.00000000 
##         SoilEvaporation       HerbTranspiration         PlantExtraction 
##              0.50000000              0.04872542              0.68459236 
##           Transpiration HydraulicRedistribution 
##              0.68459236              0.00000000

And Soil contains water evaporated from each soil layer, water transpired from each soil layer and the final soil water potential:

sd1$Soil
##           Psi HerbTranspiration HydraulicInput HydraulicOutput PlantExtraction
## 1 -0.03547019      0.0444001775              0     0.494446834     0.494446834
## 2 -0.03323841      0.0034620610              0     0.173786416     0.173786416
## 3 -0.03303092      0.0006078123              0     0.014363954     0.014363954
## 4 -0.03301162      0.0002553696              0     0.001995157     0.001995157

Soil and canopy energy balance

Element EnergyBalance contains subdaily variation in atmosphere, canopy and soil temperatures, as well as canopy and soil energy balance components.

names(sd1$EnergyBalance)
## [1] "Temperature"         "SoilTemperature"     "CanopyEnergyBalance"
## [4] "SoilEnergyBalance"   "TemperatureLayers"   "VaporPressureLayers"

Package medfate provides a plot function for objects of class spwb_day that can be used to inspect the results of the simulation. We use this function to display subdaily dynamics in plant, soil and canopy variables. For example, we can use it to display temperature variations (only the temperature of the topmost soil layer is drawn):

plot(sd1, type = "Temperature")

plot(sd1, type = "CanopyEnergyBalance")

plot(sd1, type = "SoilEnergyBalance")

Plant output

Element Plants contains output values by plant cohort. Several output variables can be inspected in this element.

sd1$Plants
##               LAI    LAIlive     FPAR Extraction Transpiration
## T1_148 0.84874773 0.84874773 92.18285  0.4398375     0.4398375
## T2_168 0.70557382 0.70557382 72.36365  0.2323782     0.2323782
## S1_165 0.03062604 0.03062604 44.32407  0.0123766     0.0123766
##        GrossPhotosynthesis NetPhotosynthesis    RootPsi    StemPsi LeafPLC
## T1_148          2.13085415        2.01822582 -0.4190276 -1.2593181       0
## T2_168          1.74734659        1.63974124 -0.3353606 -0.8559196       0
## S1_165          0.06680913        0.06290243 -0.3759137 -0.6029081       0
##             StemPLC LeafPsiMin  LeafPsiMax      dEdP        DDS   StemRWC
## T1_148 5.822231e-09 -1.5416393 -0.03994108 0.5034372 0.00162010 0.9971770
## T2_168 2.190611e-04 -1.1346709 -0.04019180 0.5262791 0.05550598 0.9973077
## S1_165 1.941646e-04 -0.7151737 -0.04188680 1.0418424 0.02786522 0.9880915
##          LeafRWC      LFMC WaterBalance
## T1_148 0.9581789 123.17261 4.895173e-17
## T2_168 0.9826722  92.14730 1.059808e-17
## S1_165 0.9891188  95.42815 1.148577e-18

While Plants contains one value per cohort and variable that summarizes the whole simulated day, information by disaggregated by time step can be accessed in PlantsInst. Moreover, we can use function plot.spwb_day() to draw plots of sub-daily variation per species of plant transpiration per ground area (L·m2^{-2}), transpiration per leaf area (also in L·m2^{-2}), plant net photosynthesis (in g C·m2^{-2}), and plant water potential (in MPa):

plot(sd1, type = "PlantTranspiration", bySpecies = T)

plot(sd1, type = "TranspirationPerLeaf", bySpecies = T)

plot(sd1, type = "NetPhotosynthesis", bySpecies = T)

plot(sd1, type = "LeafPsiAverage", bySpecies = T)

Output for sunlit and shade leaves

The model distinguishes between sunlit and shade leaves for stomatal regulation. Static properties of sunlit and shade leaves, for each cohort, can be accessed via:

sd1$SunlitLeaves
##        LeafPsiMin  LeafPsiMax      GSWMin     GSWMax  TempMin  TempMax
## T1_148  -1.642069 -0.03994108 0.002242650 0.27415943 1.274590 12.16115
## T2_168  -1.593485 -0.04199022 0.003269167 0.07347117 1.272433 17.53310
## S1_165  -1.122060 -0.04703362 0.007561899 0.09612847 1.267823 17.29344
sd1$ShadeLeaves
##        LeafPsiMin  LeafPsiMax      GSWMin     GSWMax   TempMin  TempMax
## T1_148 -1.4414211 -0.03994108 0.002250500 0.27894888 0.9434619 10.29716
## T2_168 -0.7791464 -0.04019180 0.003263123 0.08228505 0.5326568 10.38288
## S1_165 -0.5152537 -0.04188680 0.007626981 0.10699247 0.6721882 10.16051

Instantaneous values are also stored for sunlit and shade leaves. We can also use the plot function for objects of class spwb_day to draw instantaneous variations in temperature for sunlit and shade leaves:

plot(sd1, type = "LeafTemperature", bySpecies=TRUE)

Note that sunlit leaves of some species reach temperatures higher than the canopy. We can also plot variations in instantaneous gross and net photosynthesis rates:

plot(sd1, type = "LeafGrossPhotosynthesis", bySpecies=TRUE)

plot(sd1, type = "LeafNetPhotosynthesis", bySpecies=TRUE)

Or variations in stomatal conductance:

plot(sd1, type = "LeafStomatalConductance", bySpecies=TRUE)

Or variations in vapour pressure deficit:

plot(sd1, type = "LeafVPD", bySpecies=TRUE)

Or variations in leaf water potential:

plot(sd1, type = "LeafPsi", bySpecies=TRUE)

plot(sd1, type = "LeafCi", bySpecies=TRUE)

plot(sd1, type = "LeafIntrinsicWUE", bySpecies=TRUE)

Water balance for multiple days

Running the model

Users will often use function spwb() to run the soil water balance model for several days. This function requires the spwbInput object, the soil object and the meteorological data frame. However, running spwb_day() modified the input objects. In particular, the soil moisture at the end of the simulation was:

x$soil$W
## [1] 0.9847618 0.9984805 0.9998023 0.9999257

And the temperature of soil layers:

x$soil$Temp
## [1] 8.088428 3.159952 2.383624 2.363290

We can also see the current state of canopy variables:

x$canopy
##    zlow zmid  zup    LAIlive LAIexpanded LAIdead     Tair Cair     VPair
## 1     0   50  100 0.03062604  0.03062604       0 5.684041  386 0.5170718
## 2   100  150  200 0.00000000  0.00000000       0 5.684041  386 0.5170718
## 3   200  250  300 0.06200693  0.06200693       0 5.684041  386 0.5170718
## 4   300  350  400 0.29933459  0.29933459       0 5.684041  386 0.5170718
## 5   400  450  500 0.43266592  0.43266592       0 5.684041  386 0.5170718
## 6   500  550  600 0.41005056  0.41005056       0 5.684041  386 0.5170718
## 7   600  650  700 0.24368578  0.24368578       0 5.684041  386 0.5170718
## 8   700  750  800 0.10657777  0.10657777       0 5.684041  386 0.5170718
## 9   800  850  900 0.00000000  0.00000000       0 5.684041  386 0.5170718
## 10  900  950 1000 0.00000000  0.00000000       0 5.684041  386 0.5170718
## 11 1000 1050 1100 0.00000000  0.00000000       0 5.684041  386 0.5170718
## 12 1100 1150 1200 0.00000000  0.00000000       0 5.684041  386 0.5170718
## 13 1200 1250 1300 0.00000000  0.00000000       0 5.684041  386 0.5170718
## 14 1300 1350 1400 0.00000000  0.00000000       0 5.684041  386 0.5170718
## 15 1400 1450 1500 0.00000000  0.00000000       0 5.684041  386 0.5170718
## 16 1500 1550 1600 0.00000000  0.00000000       0 5.684041  386 0.5170718
## 17 1600 1650 1700 0.00000000  0.00000000       0 5.684041  386 0.5170718
## 18 1700 1750 1800 0.00000000  0.00000000       0 5.684041  386 0.5170718
## 19 1800 1850 1900 0.00000000  0.00000000       0 5.684041  386 0.5170718
## 20 1900 1950 2000 0.00000000  0.00000000       0 5.684041  386 0.5170718
## 21 2000 2050 2100 0.00000000  0.00000000       0 5.684041  386 0.5170718
## 22 2100 2150 2200 0.00000000  0.00000000       0 5.684041  386 0.5170718
## 23 2200 2250 2300 0.00000000  0.00000000       0 5.684041  386 0.5170718
## 24 2300 2350 2400 0.00000000  0.00000000       0 5.684041  386 0.5170718
## 25 2400 2450 2500 0.00000000  0.00000000       0 5.684041  386 0.5170718
## 26 2500 2550 2600 0.00000000  0.00000000       0 5.684041  386 0.5170718
## 27 2600 2650 2700 0.00000000  0.00000000       0 5.684041  386 0.5170718
## 28 2700 2750 2800 0.00000000  0.00000000       0 5.684041  386 0.5170718

We simply use function resetInputs() to reset state variables to their default values, so that the new simulation is not affected by the end state of the previous simulation:

resetInputs(x)
x$soil$W
## [1] 1 1 1 1
x$soil$Temp
## [1] NA NA NA NA
x$canopy
##    zlow zmid  zup    LAIlive LAIexpanded LAIdead Tair Cair VPair
## 1     0   50  100 0.03062604  0.03062604       0   NA   NA    NA
## 2   100  150  200 0.00000000  0.00000000       0   NA   NA    NA
## 3   200  250  300 0.06200693  0.06200693       0   NA   NA    NA
## 4   300  350  400 0.29933459  0.29933459       0   NA   NA    NA
## 5   400  450  500 0.43266592  0.43266592       0   NA   NA    NA
## 6   500  550  600 0.41005056  0.41005056       0   NA   NA    NA
## 7   600  650  700 0.24368578  0.24368578       0   NA   NA    NA
## 8   700  750  800 0.10657777  0.10657777       0   NA   NA    NA
## 9   800  850  900 0.00000000  0.00000000       0   NA   NA    NA
## 10  900  950 1000 0.00000000  0.00000000       0   NA   NA    NA
## 11 1000 1050 1100 0.00000000  0.00000000       0   NA   NA    NA
## 12 1100 1150 1200 0.00000000  0.00000000       0   NA   NA    NA
## 13 1200 1250 1300 0.00000000  0.00000000       0   NA   NA    NA
## 14 1300 1350 1400 0.00000000  0.00000000       0   NA   NA    NA
## 15 1400 1450 1500 0.00000000  0.00000000       0   NA   NA    NA
## 16 1500 1550 1600 0.00000000  0.00000000       0   NA   NA    NA
## 17 1600 1650 1700 0.00000000  0.00000000       0   NA   NA    NA
## 18 1700 1750 1800 0.00000000  0.00000000       0   NA   NA    NA
## 19 1800 1850 1900 0.00000000  0.00000000       0   NA   NA    NA
## 20 1900 1950 2000 0.00000000  0.00000000       0   NA   NA    NA
## 21 2000 2050 2100 0.00000000  0.00000000       0   NA   NA    NA
## 22 2100 2150 2200 0.00000000  0.00000000       0   NA   NA    NA
## 23 2200 2250 2300 0.00000000  0.00000000       0   NA   NA    NA
## 24 2300 2350 2400 0.00000000  0.00000000       0   NA   NA    NA
## 25 2400 2450 2500 0.00000000  0.00000000       0   NA   NA    NA
## 26 2500 2550 2600 0.00000000  0.00000000       0   NA   NA    NA
## 27 2600 2650 2700 0.00000000  0.00000000       0   NA   NA    NA
## 28 2700 2750 2800 0.00000000  0.00000000       0   NA   NA    NA

Now we are ready to call function spwb():

S <- spwb(x, examplemeteo, latitude = 41.82592, elevation = 100)
## Initial plant water content (mm): 6.78662
## Initial soil water content (mm): 290.875
## Initial snowpack content (mm): 0
## Performing daily simulations
## 
##  [Year 2001]:............
## 
## Final plant water content (mm): 6.78164
## Final soil water content (mm): 273.973
## Final snowpack content (mm): 0
## Change in plant water content (mm): -0.00497874
## Plant water balance result (mm): -5.66285e-16
## Change in soil water content (mm): -16.902
## Soil water balance result (mm): -16.902
## 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) 92 Net rainfall (mm) 370
##   Infiltration (mm) 402 Infiltration excess (mm) 19 Saturation excess (mm) 0 Capillarity rise (mm) 0
##   Soil evaporation (mm) 22  Herbaceous transpiration (mm) 13 Woody plant transpiration (mm) 242
##   Plant extraction from soil (mm) 242  Plant water balance (mm) -0 Hydraulic redistribution (mm) 4
##   Runoff (mm) 19 Deep drainage (mm) 141

Function spwb() returns an object of class spwb. If we inspect its elements, we realize that the output is arranged differently than in spwb_day():

##  [1] "latitude"      "topography"    "weather"       "spwbInput"    
##  [5] "spwbOutput"    "WaterBalance"  "EnergyBalance" "Temperature"  
##  [9] "Soil"          "Snow"          "Stand"         "Plants"       
## [13] "SunlitLeaves"  "ShadeLeaves"   "subdaily"

In particular, element spwbInput contains a copy of the input parameters that were used to run the model:

names(S$spwbInput)
##  [1] "control"                 "soil"                   
##  [3] "snowpack"                "canopy"                 
##  [5] "herbLAI"                 "herbLAImax"             
##  [7] "cohorts"                 "above"                  
##  [9] "below"                   "belowLayers"            
## [11] "paramsPhenology"         "paramsAnatomy"          
## [13] "paramsInterception"      "paramsTranspiration"    
## [15] "paramsWaterStorage"      "internalPhenology"      
## [17] "internalWater"           "internalLAIDistribution"
## [19] "internalFCCS"

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 0.8828475      4.869109  4.869109    0  3.4241795        0
## 2001-01-02 1.6375337      2.498292  2.498292    0  1.0717469        0
## 2001-01-03 1.3017026      0.000000  0.000000    0  0.0000000        0
## 2001-01-04 0.5690790      5.796973  5.796973    0  4.3625616        0
## 2001-01-05 1.6760567      1.884401  1.884401    0  0.7539027        0
## 2001-01-06 1.2077028     13.359801 13.359801    0 11.7240275        0
##            Infiltration InfiltrationExcess SaturationExcess Runoff DeepDrainage
## 2001-01-01    3.4241795                  0                0      0    2.9587043
## 2001-01-02    1.0717469                  0                0      0    0.4987713
## 2001-01-03    0.0000000                  0                0      0    0.0000000
## 2001-01-04    4.3625616                  0                0      0    3.3039457
## 2001-01-05    0.7539027                  0                0      0    0.1771615
## 2001-01-06   11.7240275                  0                0      0    4.1214138
##            CapillarityRise Evapotranspiration Interception SoilEvaporation
## 2001-01-01               0          1.9104045     1.444929       0.4478948
## 2001-01-02               0          1.9995203     1.426545       0.5000000
## 2001-01-03               0          0.8999863     0.000000       0.5000000
## 2001-01-04               0          1.5930409     1.434411       0.1435328
## 2001-01-05               0          1.7587830     1.130499       0.5000000
## 2001-01-06               0          2.1067816     1.635773       0.4511066
##            HerbTranspiration PlantExtraction Transpiration
## 2001-01-01       0.011023432     0.006557005   0.006557005
## 2001-01-02       0.020446613     0.052528994   0.052528994
## 2001-01-03       0.016253351     0.383732929   0.383732929
## 2001-01-04       0.007105368     0.007991412   0.007991412
## 2001-01-05       0.020927620     0.107356642   0.107356642
## 2001-01-06       0.015079612     0.004822175   0.004822175
##            HydraulicRedistribution
## 2001-01-01            0.000000e+00
## 2001-01-02            0.000000e+00
## 2001-01-03            0.000000e+00
## 2001-01-04            0.000000e+00
## 2001-01-05            0.000000e+00
## 2001-01-06            1.329694e-05

Elements Plants is itself a list with several elements that contain daily output results by plant cohorts, for example leaf minimum (midday) water potentials are:

head(S$Plants$LeafPsiMin)
##               T1_148     T2_168     S1_165
## 2001-01-01 -1.256406 -0.7425001 -0.3902716
## 2001-01-02 -1.368721 -0.6525553 -0.3961108
## 2001-01-03 -1.331580 -0.8165961 -0.4527407
## 2001-01-04 -1.223824 -0.6063900 -0.3488515
## 2001-01-05 -1.349259 -0.7358269 -0.4326192
## 2001-01-06 -1.299800 -0.6350148 -0.3832314

Plotting and summarizing results

Package medfate also provides a plot function for objects of class spwb. It can be used to show the meteorological input. Additionally, it can also be used to draw soil and plant variables. In the code below we draw water fluxes, soil water potentials, plant transpiration and plant (mid-day) water potential:

plot(S, type="Evapotranspiration")

plot(S, type="SoilPsi", bySpecies = TRUE)

plot(S, type="PlantTranspiration", bySpecies = TRUE)

plot(S, type="LeafPsiMin", bySpecies = TRUE)

Alternatively, one can interactively create plots using function shinyplot, e.g.:

While the simulation model uses daily steps, users may 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 water balance by months one can use:

summary(S, freq="months",FUN=mean, output="WaterBalance")
##                 PET Precipitation       Rain      Snow    NetRain   Snowmelt
## 2001-01-01 1.011397    2.41127383 1.87415609 0.5371177 1.34613589 0.42235503
## 2001-02-01 2.278646    0.17855109 0.08778069 0.0907704 0.03511889 0.19831578
## 2001-03-01 2.368035    2.41917349 2.41917349 0.0000000 1.93933438 0.01762496
## 2001-04-01 3.086567    0.63056064 0.29195973 0.3386009 0.13472156 0.33860091
## 2001-05-01 3.662604    0.76337345 0.76337345 0.0000000 0.57881566 0.00000000
## 2001-06-01 5.265359    0.21959509 0.21959509 0.0000000 0.15746695 0.00000000
## 2001-07-01 4.443053    3.27810591 3.27810591 0.0000000 2.81775241 0.00000000
## 2001-08-01 4.463242    1.92222891 1.92222891 0.0000000 1.55188110 0.00000000
## 2001-09-01 3.453891    1.30651303 1.30651303 0.0000000 1.04946567 0.00000000
## 2001-10-01 2.405506    1.33598175 1.33598175 0.0000000 1.05395924 0.00000000
## 2001-11-01 1.716591    2.20566281 1.47764599 0.7280168 1.33350571 0.72801682
## 2001-12-01 1.608082    0.05046181 0.05046181 0.0000000 0.02018853 0.00000000
##            Infiltration InfiltrationExcess SaturationExcess    Runoff
## 2001-01-01   1.76849092          0.0000000                0 0.0000000
## 2001-02-01   0.23343467          0.0000000                0 0.0000000
## 2001-03-01   1.95695933          0.0000000                0 0.0000000
## 2001-04-01   0.47332247          0.0000000                0 0.0000000
## 2001-05-01   0.57881566          0.0000000                0 0.0000000
## 2001-06-01   0.15746695          0.0000000                0 0.0000000
## 2001-07-01   2.57561889          0.2421335                0 0.2421335
## 2001-08-01   1.51553769          0.0363434                0 0.0363434
## 2001-09-01   1.04946567          0.0000000                0 0.0000000
## 2001-10-01   0.95317435          0.1007849                0 0.1007849
## 2001-11-01   1.82722547          0.2342971                0 0.2342971
## 2001-12-01   0.02018853          0.0000000                0 0.0000000
##            DeepDrainage CapillarityRise Evapotranspiration Interception
## 2001-01-01   1.44744549               0          0.9342692   0.52802019
## 2001-02-01   0.01123283               0          0.5703038   0.05266179
## 2001-03-01   1.26967055               0          1.0907492   0.47983911
## 2001-04-01   0.00000000               0          0.8133118   0.15723817
## 2001-05-01   0.06372233               0          1.1254065   0.18455779
## 2001-06-01   0.00000000               0          1.2242501   0.06212814
## 2001-07-01   0.00000000               0          1.6060321   0.46035350
## 2001-08-01   0.09758682               0          1.5964331   0.37034782
## 2001-09-01   0.05128315               0          1.0899358   0.25704736
## 2001-10-01   0.44489349               0          0.9902250   0.28202252
## 2001-11-01   1.21949898               0          0.6282484   0.14414028
## 2001-12-01   0.00000000               0          0.4466326   0.03027328
##            SoilEvaporation HerbTranspiration PlantExtraction Transpiration
## 2001-01-01     0.170049280        0.01262819       0.2235716     0.2235716
## 2001-02-01     0.039707854        0.02844308       0.4494911     0.4494911
## 2001-03-01     0.120147424        0.02955993       0.4612028     0.4612028
## 2001-04-01     0.012045501        0.03849426       0.6055338     0.6055338
## 2001-05-01     0.073947519        0.04566650       0.8212347     0.8212347
## 2001-06-01     0.004702183        0.06307895       1.0943408     1.0943408
## 2001-07-01     0.090002094        0.05492023       1.0007562     1.0007562
## 2001-08-01     0.043282716        0.05567775       1.1271248     1.1271248
## 2001-09-01     0.044322248        0.04310262       0.7454636     0.7454636
## 2001-10-01     0.052513679        0.03002608       0.6256627     0.6256627
## 2001-11-01     0.058371102        0.02142489       0.4043121     0.4043121
## 2001-12-01     0.016180807        0.02006187       0.3801167     0.3801167
##            HydraulicRedistribution
## 2001-01-01            6.954160e-07
## 2001-02-01            2.649091e-04
## 2001-03-01            1.001693e-03
## 2001-04-01            5.639151e-03
## 2001-05-01            4.514233e-03
## 2001-06-01            9.831075e-02
## 2001-07-01            2.318220e-02
## 2001-08-01            2.130429e-03
## 2001-09-01            1.746721e-03
## 2001-10-01            5.115775e-04
## 2001-11-01            1.584007e-03
## 2001-12-01            2.420113e-03

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_148     T2_168     S1_165
## 2001-01-01 0.0002425489 0.02029131 0.01098663
## 2001-02-01 0.0007955526 0.03584040 0.01969908
## 2001-03-01 0.0010360682 0.04084532 0.02237665
## 2001-04-01 0.0013961111 0.05026582 0.03026205
## 2001-05-01 0.0029847640 0.06881531 0.04117978
## 2001-06-01 0.0210319599 0.12176464 0.12757254
## 2001-07-01 0.0083677818 0.09575847 0.06826600
## 2001-08-01 0.0063842654 0.09342219 0.05705369
## 2001-09-01 0.0028120353 0.06597470 0.03795780
## 2001-10-01 0.0019567417 0.05328059 0.02954134
## 2001-11-01 0.0006214232 0.03239042 0.01851331
## 2001-12-01 0.0006653219 0.03295971 0.02006250

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     1.239166e-04       0.009798356   0.02120075
## 2001-01-02     2.690256e-04       0.009886504   0.01865970
## 2001-01-03     2.951949e-04       0.012992165   0.02712720
## 2001-01-04     8.704417e-05       0.009361148   0.01819566
## 2001-01-05     2.837136e-04       0.010253995   0.01932877
## 2001-01-06     1.669615e-04       0.008492610   0.01632111

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     0.0002425489        0.01098663   0.02029131
## 2001-02-01     0.0007955526        0.01969908   0.03584040
## 2001-03-01     0.0010360682        0.02237665   0.04084532
## 2001-04-01     0.0013961111        0.03026205   0.05026582
## 2001-05-01     0.0029847640        0.04117978   0.06881531
## 2001-06-01     0.0210319599        0.12757254   0.12176464
## 2001-07-01     0.0083677818        0.06826600   0.09575847
## 2001-08-01     0.0063842654        0.05705369   0.09342219
## 2001-09-01     0.0028120353        0.03795780   0.06597470
## 2001-10-01     0.0019567417        0.02954134   0.05328059
## 2001-11-01     0.0006214232        0.01851331   0.03239042
## 2001-12-01     0.0006653219        0.02006250   0.03295971

References

  • De Cáceres M, Mencuccini M, Martin-StPaul N, Limousin JM, Coll L, Poyatos R, Cabon A, Granda V, Forner A, Valladares F, Martínez-Vilalta J (2021) Unravelling the effect of species mixing on water use and drought stress in holm oak forests: a modelling approach. Agricultural and Forest Meteorology 296 (https://doi.org/10.1016/j.agrformet.2020.108233).

  • Ruffault J, Pimont F, Cochard H, Dupuy JL, Martin-StPaul N (2022) SurEau-Ecos v2.0: a trait-based plant hydraulics model for simulations of plant water status and drought-induced mortality at the ecosystem level. Geoscientific Model Development 15, 5593-5626 (https://doi.org/10.5194/gmd-15-5593-2022).