get_soilmoisture: Extract or calculate soil moisture

View source: R/sw_OutputDerived_Functions.R

get_soilmoistureR Documentation

Extract or calculate soil moisture

Description

Extract or calculate soil moisture

Usage

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
)

Arguments

x

An object of class swOutput.

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 ⁠[cm]⁠).

fcoarse

A numeric vector of coarse fragments per soil layer (units ⁠[volume fraction]⁠).

keep_time

A logical value. Include time information in the returned object.

Value

A data frame with requested soil moisture; rows represent time steps and columns represent soil layers.

Details

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).

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)


Burke-Lauenroth-Lab/rSOILWAT2 documentation built on Dec. 9, 2023, 1:46 a.m.