flowunit: Set and retrieve unit of the discharge

Description Usage Arguments Details Value Examples

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)

Example output

Loading required package: xts
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

Loading required package: lmom
Loading required package: lattice
[1] "m^3/s"
Summary of droughts
River: Ray at Grendon Underwood
Units: volumes in m<U+00B3>, duration in days

Filtered 3 minor events of 10 total. 
Only droughts with volume >= 20.304 m<U+00B3> and duration >= 5 days are reported.

   event.no      start       time        end volume duration dbt qmin
2         2 1970-05-21 1970-06-10 1970-06-10 1814.4       21  21    0
3         3 1970-06-13 1970-06-26 1970-06-26 1209.6       14  14    0
4         4 1970-06-28 1970-07-13 1970-07-13 1382.4       16  16    0
6         6 1970-07-20 1970-08-06 1970-08-06 1382.4       18  18    0
7         7 1970-08-08 1970-08-18 1970-08-18  950.4       11  11    0
8         8 1970-08-24 1970-09-08 1970-09-08 1382.4       16  16    0
10       10 1970-09-15 1970-10-31 1970-10-31 4060.8       47  47    0
        tqmin
2  1970-05-21
3  1970-06-13
4  1970-06-28
6  1970-07-20
7  1970-08-08
8  1970-08-24
10 1970-09-15
Summary of droughts
River: Ray at Grendon Underwood
Units: volumes in m<U+00B3>, duration in days

Filtered 3 minor events of 10 total. 
Only droughts with volume >= 20.304 m<U+00B3> and duration >= 5 days are reported.

   event.no      start       time        end volume duration dbt qmin
2         2 1970-05-21 1970-06-10 1970-06-10 1814.4       21  21    0
3         3 1970-06-13 1970-06-26 1970-06-26 1209.6       14  14    0
4         4 1970-06-28 1970-07-13 1970-07-13 1382.4       16  16    0
6         6 1970-07-20 1970-08-06 1970-08-06 1382.4       18  18    0
7         7 1970-08-08 1970-08-18 1970-08-18  950.4       11  11    0
8         8 1970-08-24 1970-09-08 1970-09-08 1382.4       16  16    0
10       10 1970-09-15 1970-10-31 1970-10-31 4060.8       47  47    0
        tqmin
2  1970-05-21
3  1970-06-13
4  1970-06-28
6  1970-07-20
7  1970-08-08
8  1970-08-24
10 1970-09-15
[1] TRUE

lfstat documentation built on May 2, 2019, 6:07 p.m.