# flowunit: Set and retrieve unit of the discharge In lfstat: Calculation of Low Flow Statistics for Daily Stream Flow Data

## Description

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.

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10 11``` ``` 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 ```

## Arguments

 `x` The time seies, either of class 'lfobj' or 'xts'. `value` a valid character string of length one that can be interpreted as flow unit. See details.

## 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 befor 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"`.

## Value

A character vector of length one, containing the currently used discharge unit.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17``` ```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) ```

lfstat documentation built on May 30, 2017, 1:46 a.m.