| Title: | Functions to Handle and Plot Rain Data at KWB |
|---|---|
| Description: | Functions to handle and plot rain data at KWB. |
| Authors: | Hauke Sonnenberg [aut, cre] (ORCID: <https://orcid.org/0000-0001-9134-2871>), Michael Rustler [ctb] (ORCID: <https://orcid.org/0000-0003-0647-7726>), FLUSSHYGIENE [fnd], KURAS [fnd], Kompetenzzentrum Wasser Berlin gGmbH (KWB) [cph] |
| Maintainer: | Hauke Sonnenberg <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.0 |
| Built: | 2026-04-08 05:52:02 UTC |
| Source: | https://github.com/KWB-R/kwb.rain |
aggregate rain data by day
aggregateByDay(x, FUN, ..., timeColumn = 1, excludeColumns = 1:2)aggregateByDay(x, FUN, ..., timeColumn = 1, excludeColumns = 1:2)
x |
data frame containing at least one date and time column |
FUN |
aggregation function |
... |
arguments passed to FUN |
timeColumn |
number of the date and time column |
excludeColumns |
vector of column numbers to be excluded before aggregation |
Stop if there are Duplicates and show them
checkForDuplicates(x, keys)checkForDuplicates(x, keys)
x |
data frame |
keys |
columns that are expected to be key columns and that should not contain duplicated value combinations |
Compact Signal Data
compactForGauges( signals, gauges, validation, level = 2, stars = TRUE, dbg = TRUE )compactForGauges( signals, gauges, validation, level = 2, stars = TRUE, dbg = TRUE )
signals |
data frame as returned by
|
gauges |
character vector of rain gauge names |
validation |
data frame |
level |
level of compression |
stars |
if |
dbg |
if |
Add one day to the data in the "Date" column if the time in column "To" is before the time in column "From"
correctRainDiffs( rainDiffs, userCorrections, gauges = names(rainDiffs)[-(1:2)], dbg = TRUE )correctRainDiffs( rainDiffs, userCorrections, gauges = names(rainDiffs)[-(1:2)], dbg = TRUE )
rainDiffs |
rain height differences as provided by
|
userCorrections |
user correction data as returned by
|
gauges |
names of rain gauges (as they appear as column names in
|
dbg |
if |
rain correction data from 'wide' format to 'long' format
corrToLongFormat(corrData)corrToLongFormat(corrData)
corrData |
correction data as returned by
|
Output Template for Argument Assignments
defaultArgumentAssignment(x, type = c("R", "csv")[1])defaultArgumentAssignment(x, type = c("R", "csv")[1])
x |
vector of character |
type |
one of |
get a data frame with each row representing a gauge and a day at which rain data needs to be corrected
getCorrectionCases(corrData, rainData, ...)getCorrectionCases(corrData, rainData, ...)
corrData |
correction data as returned by
|
rainData |
rain data as returned by |
... |
additional arguments passed to the final |
cumulate rain data within each day
getDailyCumulativeRain(rd, to.long = TRUE)getDailyCumulativeRain(rd, to.long = TRUE)
rd |
data frame containing rain data as returned by
|
to.long |
if |
Get the Names of Neighbouring Rain Gauges
getNeighbours(signals, gaugeInfo, n = 2, gaugePos = NULL)getNeighbours(signals, gaugeInfo, n = 2, gaugePos = NULL)
signals |
data frame as returned by
|
gaugeInfo |
data frame as returned by
|
n |
number of neighbours |
gaugePos |
data frame containing the gauge positions as required by
|
plot cumulative rain
plotCumulativeRain(rd.long, to.pdf = TRUE)plotCumulativeRain(rd.long, to.pdf = TRUE)
rd.long |
data frame in 'long' format as returned by
|
to.pdf |
If |
Print Tables of Daily Rain Heights (as Plots!)
plotDailyRainHeightTable( rd, landscape = FALSE, cex = ifelse(landscape, 0.8, 0.6), ppp = ifelse(landscape, 1, 2), to.pdf = TRUE )plotDailyRainHeightTable( rd, landscape = FALSE, cex = ifelse(landscape, 0.8, 0.6), ppp = ifelse(landscape, 1, 2), to.pdf = TRUE )
rd |
data frame with time stamps in first column and rain heights per time interval for different rain gauges in all the other columns |
landscape |
passed to |
cex |
passed to |
ppp |
number of plots per page |
to.pdf |
if |
Plot all rain events contained in rain data
plotRainEventOverview(rd, timeColumn = "tEnd_BWB", to.pdf = TRUE)plotRainEventOverview(rd, timeColumn = "tEnd_BWB", to.pdf = TRUE)
rd |
data frame with time stamps in first column and rain heights per time interval for different rain gauges in all the other columns |
timeColumn |
name of the column containing the timestamps. Default: "tEnd_BWB" |
to.pdf |
if |
rain data from 'wide' format to 'long' format
rainToLongFormat(rainData)rainToLongFormat(rainData)
rainData |
rain data as returned by |
Read User Correction Data from CSV File
readUserCorrection( file, sep = ";", country = "de", date.format = "%d.%m.%Y", dbg = TRUE )readUserCorrection( file, sep = ";", country = "de", date.format = "%d.%m.%Y", dbg = TRUE )
file |
full path to CSV file |
sep |
column separator |
country |
country code ("de" or "en") |
date.format |
date format string |
dbg |
if |
Reformat rain data as returned by correctRainDiffs to the
format required by plotRainEventOverview.
reformat_rain_data(rain)reformat_rain_data(rain)
rain |
data frame with begin and end timestamps of five minute time
intervals in the first two (character) columns, rain heights of five minute
intervals in the remaining columns. Such a data frame is returned by
|
Convert raw Signals and Validation Data to Valid Signals
toGaugeSignals(signals, validation, neighbours, digits = 3, ...)toGaugeSignals(signals, validation, neighbours, digits = 3, ...)
signals |
data frame as returned by
|
validation |
data frame as returned by |
neighbours |
vector of names of neighbour gauges |
digits |
number of digits to which the signals are rounded |
... |
arguments passed to |
Create Validation Table from Signal and Correction Data
toValidationTable(signals, corrections)toValidationTable(signals, corrections)
signals |
data frame as returned by
|
corrections |
data frame as returned by
|
Write Files containing the "Diff" between raw and valid rain signal
writeDiffFiles( gaugeSignals, dir.out, gauges = names(gaugeSignals), years = NULL, suffix = NULL, sep = ";", dec = ",", dbg = TRUE )writeDiffFiles( gaugeSignals, dir.out, gauges = names(gaugeSignals), years = NULL, suffix = NULL, sep = ";", dec = ",", dbg = TRUE )
gaugeSignals |
list of data frames with each element representing one rain gauge |
dir.out |
full path to output directory |
gauges |
vector of character containing the names of the gauges for which files are to be written |
years |
vector of integer representing the years for which diff files are to be generated |
suffix |
to be used in the names of the created files |
sep |
column separator in created CSV files |
dec |
decimal character in created CSV files |
dbg |
if |