Package 'kwb.dswt'

Title: R Package for the Project DSWT
Description: This package contains functions to be used in KWB project DSWT.
Authors: Hauke Sonnenberg [aut, cre] (ORCID: <https://orcid.org/0000-0001-9134-2871>), Michael Rustler [ctb] (ORCID: <https://orcid.org/0000-0003-0647-7726>), DSWT [fnd], FAKIN [fnd], Kompetenzzentrum Wasser Berlin gGmbH (KWB) [cph]
Maintainer: Hauke Sonnenberg <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2026-05-31 08:12:10 UTC
Source: https://github.com/KWB-R/kwb.dswt

Help Index


Find DN for Given Site

Description

Find DN for Given Site

Usage

.siteNameToDN(sitename)

Arguments

sitename

name of monitoring site


Add Total Volume and Max Q

Description

Add Total Volume and Max Q

Usage

addTotalVolumeAndMaxQ(qValues, events, eventnr, digitsV = 3, digitsMaxQ = 3)

Arguments

qValues

vector of discharge values given in L/s

events

event information as retrieved by kwb.event::hsEvents

eventnr

integer vector of same length as qValues giving the number of the event to which the Q value belongs, as returned by kwb.event::hsEventNumber.

digitsV

number of decimal places for V in m3

digitsMaxQ

number of decimal places for max. Q in L/s

Value

events with columns V_m3 and maxQ_L_s added


Complete Time Columns

Description

Complete Time Columns

Usage

completeTimeColumns(
  x,
  wanted = c("BerlinDateTime", "UTCOffset", "DateTimeUTC")
)

Arguments

x

data frame with time columns

wanted

Default: c("BerlinDateTime", "UTCOffset", "DateTimeUTC")

Value

(Hopefully) data frame with columns BerlinDateTimeNoDST, BerlinDateTime, UTCOffset, DateTimeUTC,


Convert Q in L/h to L/s, m3/s and m3/h

Description

Convert Q in L/h to L/s, m3/s and m3/h

Usage

convertQUnits(hq)

Arguments

hq

data frame containing a column Q_L_h containing flows in L/h

Value

data frame with columns H_m, Q_L_s, Q_m3_s, Q_L_h, Q_m3_h


Correct Level with Offset and Calculate Q

Description

Correct Level with Offset and Calculate Q

Usage

correctHandCalculateQ(hdat, hoffset, DN)

Arguments

hdat

data frame containing at least a column Hraw_m, as e.g. retrieved by readLogger_Ori_MLog

hoffset

offset in m to be subtracted from raw levels before the HQ relationship is applied

DN

DN in mm, must be one of 150, 300

Value

data frame with additional columns H_m, Q_L_s


List Files on FTP Server

Description

List Files on FTP Server

Usage

dirFtpPath(url, userpwd, full.names = FALSE)

Arguments

url

base url in which to look for files

userpwd

user and password, separated by colon ":"

full.names

logical (default: FALSE). Determines whether to return relative paths or the full URLs including the base url

Value

vector of urls or relative paths


List Uploaded Files

Description

You need to set the system environment variable "DSWT_FTP_LOGIN" to "user:pwd" where "user" is the username and "pwd" the password for the account that is allowed to access the FTP server where the files are stored.

Usage

dirUploadedFiles(full.names = FALSE)

Arguments

full.names

if TRUE the full absolute URLs are returned, otherwise only the relative paths.

Value

list with elements PN, H, RD, F, LPR, Q, BPR containing URLs to sampler files, water level files, rain data files, photos, laboratory protocol files, discharge files and operation protocol files, respectively, that are available at the DSWT server at sysprovide.de


Map BWB Rain Gauge Names to DSWT SiteCodes

Description

Map BWB Rain Gauge Names to DSWT SiteCodes

Usage

DSWT_BWB_CODE_TO_SITE_CODE()

Value

list with BWB names as element names and DSWT SiteCodes as elements


Path to Default Path Dictionary File

Description

Default "dictionary" file describing the folder structure to be used in DSWT

Usage

DSWT_DICTIONARY_FILE()

Value

path to path dictionary file stored in the (installed) package


List of File Type Definitions

Description

Containing e.g. a file name pattern

Usage

DSWT_FILE_TYPES()

Value

list mapping keywords to file name patterns


Water Level Offsets to be Subtracted from Measurement

Description

Water level offsets H_offset to be subtracted from measured level in order to get the water level above the plume: H = H_raw - H_offset. H is then used to calculate Q by using the relationship given by H_Q_Table

Usage

DSWT_H_OFFSETS()

Value

list of named elements with names corresponding to the monitoring site and the value corresponding to the offest in metres.


DSWT_H_OFFSETS_SINCE

Description

DSWT_H_OFFSETS_SINCE

Usage

DSWT_H_OFFSETS_SINCE()

Rain Gauges Used in DSWT Project

Description

Rain Gauges Used in DSWT Project

Usage

DSWT_RAIN_GAUGES()

Value

data frame with columns FUB_STATION, FUB_SHORT, BWB_SHORT


Names of Sites Monitored in DSWT Project

Description

Names of Sites Monitored in DSWT Project

Usage

DSWT_SITES()

Value

named vector of SiteID values in ODM database


Foreign Keys Identifying Time Series in the ODM Data Model

Description

Foreign Keys Identifying Time Series in the ODM Data Model

Usage

DSWT_TIMESERIES()

Value

list of lists


Path to Subfolder "DSWT" in tempdir()

Description

Path to subfolder "DSWT" in tempdir(). If the subfolder does not yet exist it is created

Usage

dswtdir()

Value

path to subfolder "DSWT" in tempdir()


Get Actions from Autosampler File

Description

Get Actions from Autosampler File

Usage

getActionsFromAutoSamplerFile(pnFile, fileNumber = 1, remove.errors = FALSE)

Arguments

pnFile

full path to ORI Auto sampler log files PN_<yyyymmdd>_<station>.csv

fileNumber

file number (will be included in the plot title). Useful if this function is called in a sequence for multiple files.

remove.errors

if TRUE, actions containing "Fehler" are removed


Get Actions from Autosampler Files

Description

Get Actions from Autosampler Files

Usage

getActionsFromAutoSamplerFiles(pnFiles)

Arguments

pnFiles

full path(s) to ORI Auto sampler log files PN_<yyyymmdd>_<station>.csv


Get DSWT File Paths

Description

Browse for files of given type (DSWT-specific)

Usage

getDswtFilePaths(srcdir, filetype, recursive = FALSE)

Arguments

srcdir

source directory

filetype

one of the file types contained in DSWT_FILE_TYPES

recursive

search in subdirectories?

Value

vector of file paths


Get H and Q Series from CSV File

Description

Get H and Q Series from CSV File

Usage

getHQSeriesFromCSV(
  srcfile,
  DN,
  sep = "\t",
  timeFormat = NULL,
  hoffset = 0.02,
  addTimeColumns = TRUE,
  additionalColumns = c("I_mA", "Battery_V"),
  ...
)

Arguments

srcfile

full path to csv file generated by radar probe

DN

DN in mm. Must be one of 150, 300.

sep

column separator. Default: Tabulator "\t"

timeFormat

format of timestamp. Default: "%d.%m.%Y %H:%M"

hoffset

level offset to be subtracted from the measured level in order to get the level above the flume

addTimeColumns

if TRUE, time columns containing local date and time are added

additionalColumns

names of additional columns to be imported. One of c("I_mA", "Battery_V", "DeviceID")

...

further arguments passed to readLogger_Ori_MLog, e.g. stopOnMissingColumns

Value

data frame with columns BerlinDateTimeNoDST (no daylight saving time adjustment!), Hraw_m (measured height in m), H_m (corrected height [= measured height minus offset] in m),Q_L_s (calculated discharge in L/s). If addTimeColumns is TRUE the columns BerlinDateTime and UTCOffset will be added.


Level Files for Site

Description

Level Files for Site

Usage

getLevelFilesForSite(config, station)

Arguments

config

configuration object (list) with elements "dictionaryFile" and elements required by pathDictionary

station

name of monitoring station

Value

vector of file paths


Get Level Files Info 2

Description

Get Level Files Info 2

Usage

getLevelFilesInfo2(levelData)

Arguments

levelData

data frame with columns myDateTime (character), file, row, as returned by readAllLevelFiles

Value

data frame with columns file,rows, min, first, last, max


H-Q-Relationship Given by Manufacturer

Description

H-Q-Relationship Given by Manufacturer

Usage

H_Q_Table(DN)

Arguments

DN

DN in mm, must be one of 150, 300

Value

data frame with columns H_m, Q_L_s, Q_m3_s, Q_L_h, Q_m3_h


Calculate Q from Height Above flume

Description

Calculates Q from height h above flume as Q = a*H^b with a and be retrieved from linear regression between log(H) and log(Q) with H and Q values taken from manufacturer's table

Usage

H_to_Q(H, DN)

Arguments

H

height above flume in m

DN

DN in mm, must be one of 150, 300


Insert LocalDateTime Columns

Description

Insert LocalDateTime Columns

Usage

insertLocalDateTimeColumns(mydata)

Arguments

mydata

data frame with character column BerlinDateTimeNoDST

Value

data frame with additional columns BerlinDateTime (character), UTCOffset (numeric)


Insert DateTimeUTC Column

Description

Insert DateTimeUTC Column

Usage

insertUtcDateTimeColumn(mydata)

Arguments

mydata

data frame with column BerlinDateTimeNoDST

Value

mydata with additional column DateTimeUTC


Key Field Values in DSWT Project

Description

Key Field Values in DSWT Project

Usage

keyFields_DSWT()

Value

A list with each entry representing a time series, i.e. the measurement of one variable at one site.


Prepare Single Variable Data Values for ODM

Description

Prepare Single Variable Data Values for ODM

Usage

prepareSingleVariableDataValuesForOdm(
  dataFrame,
  colName,
  noDataValue = -9999,
  dbg = TRUE
)

Arguments

dataFrame

data frame containing the data

colName

column name

noDataValue

value indicating "no data", default: -9999

dbg

logical. If TRUE, debug messages are shown


Back-Calculate Height Above Flume From Discharge

Description

back-calculates height H above flume from discharge Q. Q = a * H^b <=> H = (Q/a)^(1/b) with a and be retrieved from linear regression between log(H) and log(Q) with H and Q values taken from manufacturer's table

Usage

Q_to_H(Q, DN)

Arguments

Q

discharge Q in height above flume (in which unit?)

DN

DN in mm, must be one of 150, 300


Read all Level Files

Description

Read all Level Files

Usage

readAllLevelFiles(levelFiles, dbg = TRUE)

Arguments

levelFiles

vector of file paths

dbg

if TRUE, debug messages are shown.


Read and Plot Autosampler Files

Description

Read and Plot Autosampler Files

Usage

readAndPlotAutoSamplerFiles(
  filePaths,
  removePattern = "Power|Bluetooth|Modem|SMS|Sonde",
  to.pdf = TRUE,
  evtSepTime = 30 * 60
)

Arguments

filePaths

full path(s) to ORI Auto sampler log files PN_<yyyymmdd>_<station>.csv

removePattern

regular expression pattern matching logged actions to be removed before plotting. Set to "" in order not to remove any action

to.pdf

if TRUE, graphical output is directed to PDF

evtSepTime

event separation time in seconds. Minimum time of "no signal" between two distinct events.


Reformat Event List

Description

Reformat event list: convert to minutes and rename columns

Usage

reformatEvents(events)

Arguments

events

event list as retrieved by kwb.event::hsEvents

Value

events with tBeg renamed Ereignisbeginn_UTC, tEnd renamed Ereignisende_UTC, dur renamed Dauer_min, pBefore renamed Pause_davor_min and pAfter renamed Pause_danach_min and original columns iBeg and iEnd removed


Create Information on Water Level File

Description

Create Information on Water Level File

Usage

toLevelFileInfo(filePath, timestamps)

Arguments

filePath

path to water level file

timestamps

vector of timestamps (read from the file?)


Validate H-Q-Relationships

Description

Validate HQ relationships for DN = 150 and DN = 300

Usage

validate_HQ_relationships()

Write Event List to CSV File

Description

Write Event List to CSV File

Usage

writeEventListToCSV(events, csv, sep = ";", dec = ",")

Arguments

events

data frame containing event data

csv

full path to csv file

sep

column separator. Default: ";"

dec

decimal character. Default: "."


Write H-Q-Series to CSV File

Description

Write H-Q-Series to CSV File

Usage

writeHQSeriesToCSV(hqSeries, csv, sep = ";", dec = ",")

Arguments

hqSeries

data frame containing HQ time series

csv

full path to csv file

sep

column separator. Default: ";"

dec

decimal character. Default: "."