check.wateres_system: Check of system of reservoirs

View source: R/system.R

checkR Documentation

Check of system of reservoirs

Description

Checks if reservoirs in the system are correctly interconnected and if their time series share the same period.

Usage

check(system)

## S3 method for class 'wateres_system'
check(system)

Arguments

system

A wateres_system object.

Details

A warning is given if:

  • any downstream reservoir does not exist in the system (NA is set instead of the downstream ID in the system to be returned),

  • a reservoir does not contain data of time step identical with the time step of the first reservoir (then it is removed and downstream IDs of affected reservoirs are adjusted),

  • a reservoir is not connected to the first reservoir in the system (it is removed),

  • for daily or hourly data, a reservoir has time series of length different from time series of the first reservoir,

  • for monthly data, a reservoir has not dates of time series identical to the first reservoir in the system (its time series are shortened or the reservoir is removed completely in case of no intersection).

An error occurs if the system structure forms a cycle.

Value

A wateres_system object with modified or removed reservoirs (which do not conform to the check rules).

Examples

period = seq(as.Date("2000-01-01"), by = "months", length.out = 24)
riv_data = data.frame(
    Q =  c(0.111, 0.339, 0.723, 0.165, 0.14, 0.088, 0.098, 0.052, 0.034, 0.022, 0.152, 0.162,
        0.156, 0.19, 0.259, 0.142, 0.075, 0.054, 0.118, 0.119, 0.267, 0.105, 0.194, 0.126),
    DTM = period)
riv = as.wateres(riv_data, 14.4e6, 754e3, id = "riv", down_id = "thar")
thar_data = data.frame(
    Q =  c(9.275, 32.586, 64.53, 16.702, 12.749, 9.646, 6.748, 6.645, 4.018, 3.523, 3.118, 4.009,
        7.137, 20.377, 47.467, 15.501, 8.199, 7.014, 7.086, 6.769, 9.038, 4.859, 12.006, 22.218),
    DTM = period)
thar = as.wateres(thar_data, 41.3e6, 2672e3, id = "thar")
sys = as.system(riv, thar)
sys_modif = check(sys)

tgmwri/wateres documentation built on Feb. 13, 2024, 10:25 p.m.