View source: R/sw_OutputDerived_Functions.R
get_soilmoisture | R Documentation |
Extract or calculate soil moisture
get_soilmoisture(
x,
timestep = c("Day", "Week", "Month", "Year"),
type = c("swc", "vwc_bulk", "vwc_matric"),
swInput = NULL,
widths_cm = NULL,
fcoarse = NULL,
keep_time = FALSE
)
x |
An object of class |
timestep |
A character string. One of the rSOILWAT2 time steps. |
type |
A character string selecting type of soil moisture. |
swInput |
An object of class swInputData. |
widths_cm |
A numeric vector of soil layer widths (units |
fcoarse |
A numeric vector of coarse fragments per soil layer
(units |
keep_time |
A logical value. Include time information in the returned object. |
A data frame with requested soil moisture; rows represent time steps and columns represent soil layers.
Information on soil layer widths
and coarse fragments fcoarse
are only used if requested type of soil moisture is
not available and has to be calculated from a different type.
widths
and fcoarse
may be provided directly or via swInput
from which the information is extracted (see examples).
sw_in <- rSOILWAT2::sw_exampleData
sw_out <- sw_exec(inputData = sw_in)
res1 <- get_soilmoisture(sw_out, "Month", type = "swc")
deactivate_swOUT_OutKey(sw_in) <- sw_out_flags()[["sw_swcbulk"]]
sw_out <- sw_exec(inputData = sw_in)
res2 <- get_soilmoisture(sw_out, "Month", type = "swc", swInput = sw_in)
all.equal(res1, res2)
res3 <- get_soilmoisture(
sw_out,
timestep = "Month",
type = "swc",
widths = diff(c(0., swSoils_Layers(sw_in)[, "depth_cm"])),
fcoarse = swSoils_Layers(sw_in)[, "gravel_content"]
)
all.equal(res1, res3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.