extract {medfate} | R Documentation |
Extracts model outputs
Description
Function extract()
extracts daily or subdaily output and returns it as a tidy data frame.
Usage
extract(
x,
level = "forest",
output = NULL,
vars = NULL,
dates = NULL,
subdaily = FALSE
)
Arguments
x |
An object returned by simulation functions |
level |
Level of simulation output, either "forest" (stand-level results), "soillayer" (soil layer-level results), "cohort" (cohort-level results), "sunlitleaf" or "shadeleaf" (leaf-level results) |
output |
Section of the model output to be explored. See details. |
vars |
Variables to be extracted (by default, all of them). |
dates |
A date vector indicating the subset of simulated days for which output is desired. |
subdaily |
A flag to indicate that subdaily values are desired (see details). |
Details
When subdaily = FALSE
, parameter output
is used to restrict the section in x
where variables are located. For
example output = "Plants"
will correspond to variables "LAI", "LAIlive", "Transpiration", "StemPLC",... as returned by a call
names(x$Plants)
.
Option subdaily = TRUE
only works when simulations have been carried using control option 'subdailyResults = TRUE' (see defaultControl
).
When using subdaily = TRUE
, parameter output
is not taken into account, and options for parameter vars
are the following:
Variables for
level = "forest"
orlevel = "soillayer"
: Not allowed. An error is raised.Variables for
level = "cohort"
: "E","Ag","An","dEdP","RootPsi","StemPsi","LeafPsi","StemPLC","StemRWC","LeafRWC","StemSympRWC","LeafSympRWC","PWB".Variables for
level = "shadeleaf"
andlevel="sunlitleaf"
: "Abs_SWR","Abs_PAR","Net_LWR","E","Ag","An","Ci","Gsw","VPD","Temp","Psi","iWUE".
Value
Function extract()
returns a data frame:
If
level = "forest"
, columns are "date" and variable names.If
level = "soillayer"
, columns are "date", "soillayer" and variable names.If
level = "cohort"
,level = "sunlitleaf"
orlevel = "shadeleaf"
, columns are "date", "cohorts", "species" and variable names.If
subdaily = TRUE
, columns are "datetime", "cohorts", "species" and variable names.
Author(s)
Miquel De Cáceres Ainsa, CREAF
See Also
Examples
#Load example daily meteorological data
data(examplemeteo)
#Load example plot plant data
data(exampleforest)
#Default species parameterization
data(SpParamsMED)
#Define soil with default soil params (4 layers)
examplesoil <- defaultSoilParams(4)
#Initialize control parameters
control <- defaultControl("Granier")
#Initialize input
x <- spwbInput(exampleforest,examplesoil, SpParamsMED, control)
#Call simulation function (ten days)
S1<-spwb(x, examplemeteo[1:10, ], latitude = 41.82592, elevation = 100)
#Extracts daily forest-level output as a data frame
extract(S1, level = "forest")
#Extracts daily soil layer-level output as a data frame
extract(S1, level = "soillayer")
#Extracts daily cohort-level output as a data frame
extract(S1, level = "cohort")
#Select the output tables/variables to be extracted
extract(S1, level ="cohort", output="Plants", vars = c("PlantStress", "StemPLC"))