| flowunit | R Documentation |
In order to compute deficit volumes time series of discharges (either of class 'lfobj' or 'xts') summary.deficit needs to be aware of the unit. Units are stored in the attributes of the time series. flowunit(x) retrieves the current unit from the attributes, flowunit(x) <- value sets a new one.
flowunit(x) ## S3 method for class 'xts' flowunit(x) ## S3 method for class 'lfobj' flowunit(x) flowunit(x) <- value ## S3 replacement method for class 'xts' flowunit(x) <- value ## S3 replacement method for class 'lfobj' flowunit(x) <- value
x |
The time series, either of class |
value |
a valid character string of length one that can be interpreted as flow unit. See details. |
Currently, just a few functions like summary.deficit and lfstat:::plot.deficit_dygraph make use of the unit stored as an attribute.
Usually flow units are of dimension $L^3 T^-1$. Currently a length $l$ can be on of c("metre", "cm", "centimetre" "litre"), whereas time $T$ can be one in c("days", "hours", "mins", "secs"), possibly abbreviated. The numerator of the fraction (everything before the literal "/") is interpreted as the length (superscripts like "^3" are discarded), the denominator as time. E.g. valid units would be "cm^3/s", "m^3/day" or "litre/sec".
A character vector of length one, containing the currently used discharge unit.
data(ray) ray <- as.xts(ray)["1970::1970", ] # currently discharges are in cubic metres per second flowunit(ray) # calculating deficit volumes, for fixed threshold 0.001 m^3/s (s <- summary(find_droughts(ray, threshold = 0.001))) # multiplying the discharge by 1000 converts is to litre per second ray$discharge <- ray$discharge * 1000 # changing the unit accordingly, yields the same volumes flowunit(ray) <- "l/s" (ss <- summary(find_droughts(ray, threshold = 1))) identical(s$volume, ss$volume)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.