| 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 |
Find DN for Given Site
.siteNameToDN(sitename).siteNameToDN(sitename)
sitename |
name of monitoring site |
Add Total Volume and Max Q
addTotalVolumeAndMaxQ(qValues, events, eventnr, digitsV = 3, digitsMaxQ = 3)addTotalVolumeAndMaxQ(qValues, events, eventnr, digitsV = 3, digitsMaxQ = 3)
qValues |
vector of discharge values given in L/s |
events |
event information as retrieved by |
eventnr |
integer vector of same length as qValues giving the
number of the event to which the Q value belongs, as returned by
|
digitsV |
number of decimal places for V in m3 |
digitsMaxQ |
number of decimal places for max. Q in L/s |
events with columns V_m3 and maxQ_L_s added
Complete Time Columns
completeTimeColumns( x, wanted = c("BerlinDateTime", "UTCOffset", "DateTimeUTC") )completeTimeColumns( x, wanted = c("BerlinDateTime", "UTCOffset", "DateTimeUTC") )
x |
data frame with time columns |
wanted |
Default: c("BerlinDateTime", "UTCOffset", "DateTimeUTC") |
(Hopefully) data frame with columns BerlinDateTimeNoDST, BerlinDateTime, UTCOffset, DateTimeUTC,
Convert Q in L/h to L/s, m3/s and m3/h
convertQUnits(hq)convertQUnits(hq)
hq |
data frame containing a column Q_L_h containing flows in L/h |
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
correctHandCalculateQ(hdat, hoffset, DN)correctHandCalculateQ(hdat, hoffset, DN)
hdat |
data frame containing at least a column Hraw_m, as e.g.
retrieved by |
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 |
data frame with additional columns H_m, Q_L_s
List Files on FTP Server
dirFtpPath(url, userpwd, full.names = FALSE)dirFtpPath(url, userpwd, full.names = FALSE)
url |
base url in which to look for files |
userpwd |
user and password, separated by colon ":" |
full.names |
logical (default: |
vector of urls or relative paths
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.
dirUploadedFiles(full.names = FALSE)dirUploadedFiles(full.names = FALSE)
full.names |
if |
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
DSWT_BWB_CODE_TO_SITE_CODE()DSWT_BWB_CODE_TO_SITE_CODE()
list with BWB names as element names and DSWT SiteCodes as elements
Default "dictionary" file describing the folder structure to be used in DSWT
DSWT_DICTIONARY_FILE()DSWT_DICTIONARY_FILE()
path to path dictionary file stored in the (installed) package
Containing e.g. a file name pattern
DSWT_FILE_TYPES()DSWT_FILE_TYPES()
list mapping keywords to file name patterns
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
DSWT_H_OFFSETS()DSWT_H_OFFSETS()
list of named elements with names corresponding to the monitoring site and the value corresponding to the offest in metres.
DSWT_H_OFFSETS_SINCE
DSWT_H_OFFSETS_SINCE()DSWT_H_OFFSETS_SINCE()
Rain Gauges Used in DSWT Project
DSWT_RAIN_GAUGES()DSWT_RAIN_GAUGES()
data frame with columns FUB_STATION, FUB_SHORT, BWB_SHORT
Names of Sites Monitored in DSWT Project
DSWT_SITES()DSWT_SITES()
named vector of SiteID values in ODM database
Foreign Keys Identifying Time Series in the ODM Data Model
DSWT_TIMESERIES()DSWT_TIMESERIES()
list of lists
Path to subfolder "DSWT" in tempdir(). If the subfolder does not yet exist it is created
dswtdir()dswtdir()
path to subfolder "DSWT" in tempdir()
Get Actions from Autosampler File
getActionsFromAutoSamplerFile(pnFile, fileNumber = 1, remove.errors = FALSE)getActionsFromAutoSamplerFile(pnFile, fileNumber = 1, remove.errors = FALSE)
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
getActionsFromAutoSamplerFiles(pnFiles)getActionsFromAutoSamplerFiles(pnFiles)
pnFiles |
full path(s) to ORI Auto sampler log files PN_<yyyymmdd>_<station>.csv |
Browse for files of given type (DSWT-specific)
getDswtFilePaths(srcdir, filetype, recursive = FALSE)getDswtFilePaths(srcdir, filetype, recursive = FALSE)
srcdir |
source directory |
filetype |
one of the file types contained in DSWT_FILE_TYPES |
recursive |
search in subdirectories? |
vector of file paths
Get H and Q Series from CSV File
getHQSeriesFromCSV( srcfile, DN, sep = "\t", timeFormat = NULL, hoffset = 0.02, addTimeColumns = TRUE, additionalColumns = c("I_mA", "Battery_V"), ... )getHQSeriesFromCSV( srcfile, DN, sep = "\t", timeFormat = NULL, hoffset = 0.02, addTimeColumns = TRUE, additionalColumns = c("I_mA", "Battery_V"), ... )
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 |
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
getLevelFilesForSite(config, station)getLevelFilesForSite(config, station)
config |
configuration object (list) with elements "dictionaryFile" and
elements required by |
station |
name of monitoring station |
vector of file paths
Get Level Files Info 2
getLevelFilesInfo2(levelData)getLevelFilesInfo2(levelData)
levelData |
data frame with columns myDateTime (character),
file, row, as returned by |
data frame with columns file,rows, min,
first, last, max
H-Q-Relationship Given by Manufacturer
H_Q_Table(DN)H_Q_Table(DN)
DN |
DN in mm, must be one of 150, 300 |
data frame with columns H_m, Q_L_s, Q_m3_s, Q_L_h, Q_m3_h
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
H_to_Q(H, DN)H_to_Q(H, DN)
H |
height above flume in m |
DN |
DN in mm, must be one of 150, 300 |
Insert LocalDateTime Columns
insertLocalDateTimeColumns(mydata)insertLocalDateTimeColumns(mydata)
mydata |
data frame with character column BerlinDateTimeNoDST |
data frame with additional columns BerlinDateTime (character), UTCOffset (numeric)
Insert DateTimeUTC Column
insertUtcDateTimeColumn(mydata)insertUtcDateTimeColumn(mydata)
mydata |
data frame with column |
mydata with additional column DateTimeUTC
Key Field Values in DSWT Project
keyFields_DSWT()keyFields_DSWT()
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
prepareSingleVariableDataValuesForOdm( dataFrame, colName, noDataValue = -9999, dbg = TRUE )prepareSingleVariableDataValuesForOdm( dataFrame, colName, noDataValue = -9999, dbg = TRUE )
dataFrame |
data frame containing the data |
colName |
column name |
noDataValue |
value indicating "no data", default: -9999 |
dbg |
logical. If |
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
Q_to_H(Q, DN)Q_to_H(Q, DN)
Q |
discharge Q in height above flume (in which unit?) |
DN |
DN in mm, must be one of 150, 300 |
Read all Level Files
readAllLevelFiles(levelFiles, dbg = TRUE)readAllLevelFiles(levelFiles, dbg = TRUE)
levelFiles |
vector of file paths |
dbg |
if |
Read and Plot Autosampler Files
readAndPlotAutoSamplerFiles( filePaths, removePattern = "Power|Bluetooth|Modem|SMS|Sonde", to.pdf = TRUE, evtSepTime = 30 * 60 )readAndPlotAutoSamplerFiles( filePaths, removePattern = "Power|Bluetooth|Modem|SMS|Sonde", to.pdf = TRUE, evtSepTime = 30 * 60 )
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: convert to minutes and rename columns
reformatEvents(events)reformatEvents(events)
events |
event list as retrieved by |
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
toLevelFileInfo(filePath, timestamps)toLevelFileInfo(filePath, timestamps)
filePath |
path to water level file |
timestamps |
vector of timestamps (read from the file?) |
Validate HQ relationships for DN = 150 and DN = 300
validate_HQ_relationships()validate_HQ_relationships()
Write Event List to CSV File
writeEventListToCSV(events, csv, sep = ";", dec = ",")writeEventListToCSV(events, csv, sep = ";", dec = ",")
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
writeHQSeriesToCSV(hqSeries, csv, sep = ";", dec = ",")writeHQSeriesToCSV(hqSeries, csv, sep = ";", dec = ",")
hqSeries |
data frame containing HQ time series |
csv |
full path to csv file |
sep |
column separator. Default: ";" |
dec |
decimal character. Default: "." |