Skip to contents

Convert flows units

Usage

convertUnitQ(x, ...)

# S3 method for data.frame
convertUnitQ(x, areas, from, to, ...)

Arguments

x

a data.frame with a first column with the time stamp in POSIXct format and folling columns with flows

...

Arguments passed to the methods

areas

named vector, basin areas in km², names must correspond to station ids in columns names of x

from

flow unit of x, see details

to

flow unit of returned values

Value

data.frame with a first column with the time stamp in POSIXct format and folling columns with converted flows

Details

Available units are:

  • "mm" for mm per time step

  • "m3" for m3 per time step

  • "m3/s" for m3 per second

  • "l/s" for liter per second

The time step is determined with the time difference between rows in x.

Examples

data("L0123001", package = "airGR")
dfQmm <- data.frame(DatesR = BasinObs$DatesR, L0123001 = BasinObs$Qmm)
dfQls <- convertUnitQ(dfQmm, c(L0123001 = BasinInfo$BasinArea), from = "mm", to = "l/s")
head(dfQls)
#>       DatesR L0123001
#> 1 1984-01-01     2640
#> 2 1984-01-02     3440
#> 3 1984-01-03    12200
#> 4 1984-01-04     7600
#> 5 1984-01-05     6250
#> 6 1984-01-06     5650
head(BasinObs$Qls)
#> [1]  2640  3440 12200  7600  6250  5650