Title: | Functions Used Within Different Kwb Monitoring Projects |
---|---|
Description: | Functions used within different KWB projects dealing with monitoring data. |
Authors: | Hauke Sonnenberg [aut, cre] , Kompetenzzentrum Wasser Berlin gGmbH [cph], Michael Rustler [ctb] (0000-0003-0647-7726) |
Maintainer: | Hauke Sonnenberg <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.0 |
Built: | 2024-11-16 04:50:38 UTC |
Source: | https://github.com/KWB-R/kwb.monitoring |
Plot Rain Data
.plotRainData(rainData, gauges, xlim, innerMargins, eventAndStat = NULL)
.plotRainData(rainData, gauges, xlim, innerMargins, eventAndStat = NULL)
rainData |
data frame with columns DateTime |
gauges |
character vector of gauge names |
xlim |
vector of two POSIXct determining the x limits |
innerMargins |
passed to |
eventAndStat |
if not NULL (default) this must be a one row data frame with columns ... |
Converts two character vectors representing the beginning and end timestamps
of time intervals into a list of lubridate interval objects created by
interval
.toIntervalList(from = NULL, to = NULL, tzone = "UTC")
.toIntervalList(from = NULL, to = NULL, tzone = "UTC")
from |
vector of timestamps (vector of character will be converted to
vector of POSIXct using |
to |
vector of timestamps (vector of character will be converted to
vector of POSIXct using |
tzone |
passed to |
Add Fake Entries for Days Without Data
addFakeEntriesForDaysWithoutData(dataFrame, parameterName = "Q")
addFakeEntriesForDaysWithoutData(dataFrame, parameterName = "Q")
dataFrame |
data frame with columns day, parName, parVal |
parameterName |
name of parameter, default: |
Add Sample Times to Plot
addSampleTimesToPlot(sampleTimes, ymax, timeFormat = default_day_time_format(), cex.text = 0.7, showArrows = FALSE, showTimes = FALSE, showBottleNumbers = FALSE, legendPosition = "bottom")
addSampleTimesToPlot(sampleTimes, ymax, timeFormat = default_day_time_format(), cex.text = 0.7, showArrows = FALSE, showTimes = FALSE, showBottleNumbers = FALSE, legendPosition = "bottom")
sampleTimes |
data frame with columns |
ymax |
maximum y value of plot. Used to determine arrow lengths and positions |
timeFormat |
default: "%d.%m %H:%M" |
cex.text |
default: 0.7 |
showArrows |
default: FALSE |
showTimes |
default: FALSE |
showBottleNumbers |
default: FALSE |
legendPosition |
character string specifying the legend position, e.g. "bottom", "[top|bottom]left", "top", "[top|bottom]right" |
Add Statistics to Events
addStatisticsToEvents(events, hydraulicData)
addStatisticsToEvents(events, hydraulicData)
events |
list with elements |
hydraulicData |
passed to |
Add Sum Row
addSumRow(x)
addSumRow(x)
x |
matrix or data frame to which a sum row is added as its last row |
Add Zoom to History
addZoomToHistory(zoomHistory, i, j)
addZoomToHistory(zoomHistory, i, j)
zoomHistory |
list of (i, j) pairs, storing the history of zoom settings |
i |
index in range of slider "left" |
j |
index in range of slider "right" |
Append Column "samplesOk"
appendColumn_samplesOk(samplingEvents, bottleEvents, successWord = "SUCCESS", columnName = "samplesOk")
appendColumn_samplesOk(samplingEvents, bottleEvents, successWord = "SUCCESS", columnName = "samplesOk")
samplingEvents |
data frame with columns |
bottleEvents |
bottle events (data frame) |
successWord |
word indicating a successful sampling in column
|
columnName |
name of appended column |
Append Interpol Columns
appendInterpolColumns(hydraulicData, settings, columnQraw = "Q.raw", columnQ = "Q", columnQInterpol = "Q.interpol", columnHraw = "H.raw", columnH = "H", columnHInterpol = "H.interpol")
appendInterpolColumns(hydraulicData, settings, columnQraw = "Q.raw", columnQ = "Q", columnQInterpol = "Q.interpol", columnHraw = "H.raw", columnH = "H", columnHInterpol = "H.interpol")
hydraulicData |
data frame containing hydraulic data |
settings |
list of settings (not used!) |
columnQraw |
name of column containing raw discharge |
columnQ |
name of column containing (valid) discharge |
columnQInterpol |
name of column to be added containing interpolated discharges |
columnHraw |
name of column containing raw water levels |
columnH |
name of column containing (valid) water levels |
columnHInterpol |
name of column to be added containing interpolated water levels |
data frame with columns H.interpol, Q.interpol appended, containing only the interpolated values and NA for times when H (or Q, respectively) was already available in column H.raw (or Q.raw, respectively)
Apply H threshold given in settings to H in dat.raw
apply_H_threshold(dat.raw, settings)
apply_H_threshold(dat.raw, settings)
dat.raw |
data frame with column H |
settings |
list as returned by |
Available "sample_log"-Files
availableAutoSamplerFiles(sampleDirectory = getOrCreatePath("SAMPLE_DIR", dictionary), pattern = do_resolve("SAMPLE_CSV_PATTERN", dictionary), dictionary = NULL, warn = TRUE)
availableAutoSamplerFiles(sampleDirectory = getOrCreatePath("SAMPLE_DIR", dictionary), pattern = do_resolve("SAMPLE_CSV_PATTERN", dictionary), dictionary = NULL, warn = TRUE)
sampleDirectory |
directory in which to look for sample files. By default the directory is looked up in the dictionary at keyword: SAMPLE_DIR |
pattern |
file name pattern to which file names are matched. By default pattern is looked up in the dictionary at keyword: SAMPLE_CSV_PATTERN |
dictionary |
dictionary (list) with elements SAMPLE_DIR and SAMPLE_CSV_PATTERN |
warn |
if TRUE, a warning is given if there are no sample files |
Available Auto Sampler Files 2
availableAutoSamplerFiles2(rootDirectory, station, dictionaryFile)
availableAutoSamplerFiles2(rootDirectory, station, dictionaryFile)
rootDirectory |
passed as |
station |
passed as |
dictionaryFile |
passed to |
Bottle Events to Sampler Events
bottleEventsToSamplerEvents(bottleEvents, signalWidth)
bottleEventsToSamplerEvents(bottleEvents, signalWidth)
bottleEvents |
data frame with columns samplerFile |
signalWidth |
passed to |
Calculate Volume Composite Sample
calculateVolumeCompositeSample(hydraulicSubset, settings, show.all.bottles = FALSE)
calculateVolumeCompositeSample(hydraulicSubset, settings, show.all.bottles = FALSE)
hydraulicSubset |
data frame with columns DateTime, Q, bottle |
settings |
settings as returned by |
show.all.bottles |
if |
Generate a configuration for an analysis run
configure(rawdir, station, sampleEventIndex = -1, sampleEventMethod = "centre", replaceMissingQMethod = "interpolate", bottlesToDiscard = NA, Vbottle = 1600, Vmax = 5000, Hthresholds = 0, Qthresholds = NULL, Vthresholds = NULL, tstep.fill.s = 60, evtSepTime = 2 * 3600, sampleEventSeparationTime = NA, durationThreshold = 5, outsep = ";", outdec = ",", context = c(left = 0.1, right = 0.2), plotchars = c(1, 3, 4, 4), rain.aggregation.interval = 600, max.samples.ok = 4, bottlesToConsider = NA, dictionaryFile = "")
configure(rawdir, station, sampleEventIndex = -1, sampleEventMethod = "centre", replaceMissingQMethod = "interpolate", bottlesToDiscard = NA, Vbottle = 1600, Vmax = 5000, Hthresholds = 0, Qthresholds = NULL, Vthresholds = NULL, tstep.fill.s = 60, evtSepTime = 2 * 3600, sampleEventSeparationTime = NA, durationThreshold = 5, outsep = ";", outdec = ",", context = c(left = 0.1, right = 0.2), plotchars = c(1, 3, 4, 4), rain.aggregation.interval = 600, max.samples.ok = 4, bottlesToConsider = NA, dictionaryFile = "")
rawdir |
Where is the "root" directory to raw data? |
station |
which monitoring station? E.g in OGRE: one of c("EFH", "STR", "ALT", "NEU", "GEW"). |
sampleEventIndex |
which sample event (logged by sampler), according to the list of files recorded by the autosampler, sorted by name. Give a negative number to select files from the end of the list of files: -1 means "last", -2 "one before last", etc. |
sampleEventMethod |
one of c("centre", "left", "right"). "left": sample time is begin of time interval, "right": sample time is end of time interval, "centre": sample time is middle of time interval |
replaceMissingQMethod |
one of c("interpolate", "predict"). "interpolate": linear interpolation "predict": prediction from water levels using a saved square regression |
bottlesToDiscard |
which bottles are to be discarded (because they are not full)? Default: NA |
Vbottle |
sample volume (in mL) given to the bottle representing the time interval with highest flow volume. Default: 1600 |
Vmax |
maximum total volume for mixed sample, in mL. Default: 5000 |
Hthresholds |
What are the level thresholds (in m) that trigger the start of the sampler? Named vector of numeric with names representing the site codes. E.g. for project OGRE: c("EFH", "STR", "ALT", "NEU", "GEW"). Default: 0 |
Qthresholds |
flow thresholds for each station. Mark flow tresholds to define runoff events, same structure as Hthresholds |
Vthresholds |
hydraulic event volume thresholds for each station |
tstep.fill.s |
time step in seconds used to fill up data. Default: 60 seconds = 1 minute. |
evtSepTime |
separation of events (how long in seconds may Hthreshold be underrun within an event?). Default: 2*3600 (= 2 hours) |
sampleEventSeparationTime |
separation of sampled events within one and the same sampler file. If the difference between two sample times is greater than this time (in seconds) two sampled events are distinguished. Set to NA to prevent the splitting of sampled events. |
durationThreshold |
minimum duration (in minutes) of hydraulic events to be considered. Default: 5 minutes |
outsep |
separator to be used in output files (csv). Default: ";" |
outdec |
decimal character to be used in output files (csv). Default: "," |
context |
Vector of two elements giving the "context" before and after the event to be plotted, as percentages of the event duration. E.g. c(0.1, 0.2) means that the time interval to be plotted starts 10 percent of the event duration before the event begin and ends 20 percent of the event duration after the end of the event. |
plotchars |
plotting characters for Q.raw, Q.signal, ... |
rain.aggregation.interval |
time interval in seconds for rain data aggregation, e.g. 600 = 10 minutes. NA = no aggregation of original rain data |
max.samples.ok |
maximum number of "successful" samples within one bottle. Used for scaling the bottle "height" in the sample plot |
bottlesToConsider |
numeric vector of bottle numbers. Only bottles of the given numbers are considered (read from the sampler file). Set to NA to consider all bottles |
dictionaryFile |
full path to "dictionary" file that defines the folder structure and file name patterns in which the input files are expected to reside and to which the output files will be written. See kwb.ogre::OGRE_DEFAULT_DICTIONARY or kwb.dswt::DSWT_DEFAULT_DICTIONARY |
Create dummy files defining H and Q thresholds for different time intervals
createDummyEventThresholdFiles(stations = names(kwb.utils::selectElements(settings, "Hthresholds")), outdir = file.path(kwb.utils::selectElements(settings, "rawdir"), "..", "META"), settings = NULL)
createDummyEventThresholdFiles(stations = names(kwb.utils::selectElements(settings, "Hthresholds")), outdir = file.path(kwb.utils::selectElements(settings, "rawdir"), "..", "META"), settings = NULL)
stations |
names of monitoring stations |
outdir |
path to output directory |
settings |
list from which to take non-given arguments |
returns a list (with the stations as element names) containing the paths to the created files.
Date to Date String in Path
dateToDateStringInPath(x)
dateToDateStringInPath(x)
x |
date or time object passed to |
Filter Data Frame by Bottle Number
filterForRelevantBottles(sampleDataExtended, bottlesToConsider)
filterForRelevantBottles(sampleDataExtended, bottlesToConsider)
sampleDataExtended |
dataFrame with column bottle |
bottlesToConsider |
vector of bottle numbers to be considered |
data frame with rows in which column bottle is one of the numbers given in bottlesToConsider
Filter Sample Events for Filename
filterSampleEventsForFilename(events, fileName)
filterSampleEventsForFilename(events, fileName)
events |
list with required elements samplingEvents, bottleEvents, samplerEvents |
fileName |
file name to be filtered for in column samplerFile of each of the data frames events$samplingEvents, events$bottleEvents and events$samplerEvents |
list with elements samplingEvents, bottleEvents, samplerEvents
Format Event
formatEvent(event, eventNumber = 1, precisionLevel = NULL)
formatEvent(event, eventNumber = 1, precisionLevel = NULL)
event |
one row of event data frame as returned by
|
eventNumber |
number of the event |
precisionLevel |
1 (less precise) or 2 (more precise) |
Format Event Statistics
formatEventStatistics(eventStatistics, precisionLevel = NULL)
formatEventStatistics(eventStatistics, precisionLevel = NULL)
eventStatistics |
date frame with columns V.m3, H.max, Q.max, Q.raw.na, |
precisionLevel |
number of digits after decimal point |
Format Event Statistics Table
formatEventStatisticsTable(eventStatisticsExtended, precisionLevel = NULL)
formatEventStatisticsTable(eventStatisticsExtended, precisionLevel = NULL)
eventStatisticsExtended |
list of event properties |
precisionLevel |
1 (less precise) or 2 (more precise) |
Format Settings
formatSettings(settings, settingNames = names(settings), do.stop = FALSE)
formatSettings(settings, settingNames = names(settings), do.stop = FALSE)
settings |
list of settings |
settingNames |
names of the settings, by default:
|
do.stop |
passed to |
Get All Sampler Events
getAllSamplerEvents(rootDirectory, dictionaryFile, stations, FUN.readSamplerFile, bottlesToConsider = NA, sampleEventSeparationTime = 3600, method = "centre", signalWidth = 60)
getAllSamplerEvents(rootDirectory, dictionaryFile, stations, FUN.readSamplerFile, bottlesToConsider = NA, sampleEventSeparationTime = 3600, method = "centre", signalWidth = 60)
rootDirectory |
passed to |
dictionaryFile |
passed to |
stations |
vector of monitoring station names, each of which is passed
to |
FUN.readSamplerFile |
passed to |
bottlesToConsider |
passed to |
sampleEventSeparationTime |
passed to
|
method |
passed to |
signalWidth |
passed to |
Get All Types of Events
getAllTypesOfEvents(hydraulicData = NULL, settings, FUN.readSamplerFile)
getAllTypesOfEvents(hydraulicData = NULL, settings, FUN.readSamplerFile)
hydraulicData |
data frame containing hydraulic data that is passed to
|
settings |
list of settings, passed to |
FUN.readSamplerFile |
e.g. kwb.ogre::readOgreSamplerFileByName or kwb.dswt::readDswtSamplerFileByName |
Get Function Value or Default 2
getFunctionValueOrDefault2(values, FUN, default, timestamps = NULL, columnName = "")
getFunctionValueOrDefault2(values, FUN, default, timestamps = NULL, columnName = "")
values |
passed to |
FUN |
passed to |
default |
passed to |
timestamps |
vector of timestamps (used in warning message) |
columnName |
column name (used in warning message) |
Get Hydraulic Events
getHydraulicEvents(hydraulicData, settings, eventSettings = settings$event[[settings$station]], columnQ = "Q", columnH = "H")
getHydraulicEvents(hydraulicData, settings, eventSettings = settings$event[[settings$station]], columnQ = "Q", columnH = "H")
hydraulicData |
data frame with columns ... |
settings |
settings as returned by ... |
eventSettings |
default: |
columnQ |
name of column containing water flows. Default: "Q" |
columnH |
name of column containing water levels. Default: "H" |
Get Indices Within Events
getIndicesWithinEvents(hydraulicData, eventSettings = NULL, thresholds = c(H = NA, Q = NA), columns = c(H = "H", Q = "Q"))
getIndicesWithinEvents(hydraulicData, eventSettings = NULL, thresholds = c(H = NA, Q = NA), columns = c(H = "H", Q = "Q"))
hydraulicData |
data frame with a columns DateTime and two columns named as given in columnH, columnQ |
eventSettings |
data frame with columns tBeg, tEnd (begin and end of period in which thresholds are valid), Hthreshold, Qthreshold |
thresholds |
default H and Q thresholds to be applied for time intervals for which no special thresholds are defined |
columns |
optional. Named vector of character with column names for
|
Merge hydraulic events and sampler events
getMergedEvents(hydraulicEvents, samplerEvents, signalWidth)
getMergedEvents(hydraulicEvents, samplerEvents, signalWidth)
hydraulicEvents |
data frame containing information on hydraulic events |
samplerEvents |
data frame containing information on sampler events |
signalWidth |
passed to |
Read Regression Model from Text File
getModelFromFile(modelFile, warn = TRUE)
getModelFromFile(modelFile, warn = TRUE)
modelFile |
path to .RData file containing the model |
warn |
if |
Get or Create Path
getOrCreatePath(variableName, dictionary = settings$dictionary, settings = NULL, create.dir = FALSE, stop.on.no.resolving = TRUE, dbg = FALSE, ...)
getOrCreatePath(variableName, dictionary = settings$dictionary, settings = NULL, create.dir = FALSE, stop.on.no.resolving = TRUE, dbg = FALSE, ...)
variableName |
key to be looked up in dictionary, resolving to a file path |
dictionary |
dictionary (list of key/value pairs) in which variableName is looked up |
settings |
default: NULL |
create.dir |
if TRUE, the directory is created |
stop.on.no.resolving |
if TRUE and variableName could not be resolved the program stops |
dbg |
if TRUE, debug messages are shown |
... |
arguments passed to |
Get Prediction of Q
getPredictionOfQ(hydraulicData, regressionModels = NULL, modelDir, columns = c(DateTime = "DateTime", H = "H", Q.raw = "Q.raw"), only.if.na = TRUE)
getPredictionOfQ(hydraulicData, regressionModels = NULL, modelDir, columns = c(DateTime = "DateTime", H = "H", Q.raw = "Q.raw"), only.if.na = TRUE)
hydraulicData |
data frame with columns as named in |
regressionModels |
data frame with character columns from, to (or POSIXct columns tBeg and tEnd) and character columns modelFile determining the time intervals to which the different correlation models are assigned. |
modelDir |
full path to directory where the model files (of the current station) are stored |
columns |
names of columns containing Date and Time, water levels and water flows |
only.if.na |
logical. Not used! |
Get Sample Information
getSampleInformation(dictionary = settings$dictionary, sampleEventSeparationTime = settings$sampleEventSeparationTime, sampleEventIndices = -1, bottlesToConsider = settings$bottlesToConsider, method = settings$sampleEventMethod, FUN.readSamplerFile, settings = NULL, signalWidth = 1)
getSampleInformation(dictionary = settings$dictionary, sampleEventSeparationTime = settings$sampleEventSeparationTime, sampleEventIndices = -1, bottlesToConsider = settings$bottlesToConsider, method = settings$sampleEventMethod, FUN.readSamplerFile, settings = NULL, signalWidth = 1)
dictionary |
default: settings$dictionary |
sampleEventSeparationTime |
default: settings$sampleEventSeparationTime |
sampleEventIndices |
default: -1 |
bottlesToConsider |
default: settings$bottlesToConsider |
method |
one of the methods supported by
|
FUN.readSamplerFile |
function to be used to read an auto sampler file |
settings |
list of settings, as returned by |
signalWidth |
signal width in seconds. Default: 1 |
list with elements sampleTimes, samplingEvents, bottle events (data frame with columns...)
Get sample event information from all available auto sampler files
getSamplerEvents(settings, FUN.readSamplerFile, warn = TRUE)
getSamplerEvents(settings, FUN.readSamplerFile, warn = TRUE)
settings |
passed to |
FUN.readSamplerFile |
passed to |
warn |
passed to |
Get Statistics by Day
getStatisticsByDay(dataFrame)
getStatisticsByDay(dataFrame)
dataFrame |
data frame with columns parName, parVal, day |
data frame with additional columns info ("day: H max = ... cm, Q max = ... L/s")
Get Statistics by Event
getStatisticsByEvent(hydraulicData, events)
getStatisticsByEvent(hydraulicData, events)
hydraulicData |
data frame containing hydraulic data |
events |
data frame containing information on events, passed to
|
Vector of TRUE/FALSE with TRUE at positions where H is above the threshold
H_above_threshold(dat.raw, settings)
H_above_threshold(dat.raw, settings)
dat.raw |
data frame with column H |
settings |
list as returned by |
Indices of Rows Belonging to Time Intervals
indicesInIntervals(timestamps, intervals)
indicesInIntervals(timestamps, intervals)
timestamps |
vector of POSIXct timestamps |
intervals |
vector of Interval objects as returned by lubridate::interval |
indices of elements in timestamps that belong to the given time intervals
Merge Parallel Rain Event Statistics
mergeParallelRainEventStat(hydraulicEvents, rainEvents, rainData, seriesName, offset = 0, plot.merged.event.info = TRUE)
mergeParallelRainEventStat(hydraulicEvents, rainEvents, rainData, seriesName, offset = 0, plot.merged.event.info = TRUE)
hydraulicEvents |
data frame containing information on hydraulic events,
with columns |
rainEvents |
list of data frames containing information on rain events,
with one list entry per rain gauge of which one is named as given in
|
rainData |
passed to |
seriesName |
name of rain gauge |
offset |
time in seconds by which tBeg is shifted backwards |
plot.merged.event.info |
if |
Read dictionary from file and set RAW_DIR and STATION
pathDictionary(dictionaryFile, RAW_DIR = settings$rawdir, STATION = settings$station, settings = NULL)
pathDictionary(dictionaryFile, RAW_DIR = settings$rawdir, STATION = settings$station, settings = NULL)
dictionaryFile |
full path to file defining a dictionary and being
read with |
RAW_DIR |
value for placeholder of the same name in the dictionary |
STATION |
value for placeholder of the same name in the dictionary |
settings |
optional. List with elements |
Plot H Columns
plot_H_columns(hydraulicData, h.threshold = 0, time.dependent.thresholds = NULL, xlim = NULL, ylim = NULL, innerMargins = default_inner_margins())
plot_H_columns(hydraulicData, h.threshold = 0, time.dependent.thresholds = NULL, xlim = NULL, ylim = NULL, innerMargins = default_inner_margins())
hydraulicData |
data frame with columns DateTime, H, H.interpol |
h.threshold |
H threshold at which a horizontal line is to be drawn (default: 0) |
time.dependent.thresholds |
passed to
|
xlim |
passed to |
ylim |
passed to |
innerMargins |
passed to |
Plot Hydraulic Event
plot_hydraulic_event(hydraulicData, settings, eventAndStat, sampleInformation = NULL, ylim.Q = NULL, rainData = NULL, gauges = NULL, left = 0.1, right = 0.1, innerMargins.HQ = c(0.2, left, 0.1, right), innerMargins.rain = c(0, left, 0.2, right), dbg = FALSE)
plot_hydraulic_event(hydraulicData, settings, eventAndStat, sampleInformation = NULL, ylim.Q = NULL, rainData = NULL, gauges = NULL, left = 0.1, right = 0.1, innerMargins.HQ = c(0.2, left, 0.1, right), innerMargins.rain = c(0, left, 0.2, right), dbg = FALSE)
hydraulicData |
data frame with columns DateTime, H, Q, Q.raw, Q.raw.signal, Q.interpol |
settings |
list of settings containing additional information and passed to other functions |
eventAndStat |
passed to |
sampleInformation |
passed to |
ylim.Q |
passed to |
rainData |
optional. Data frame containing rain data |
gauges |
passed to |
left |
fraction of event length by which xlim is extended to the left |
right |
fraction of event length by which xlim is extended to the right |
innerMargins.HQ |
"inner margins" of H and Q plots. Default: c(0.2, left, 0.1, right) |
innerMargins.rain |
"inner margins" of rain plots. Default: c(0, left, 0.2, right) |
dbg |
logical. If |
Plot Hydraulic Events
plot_hydraulic_events(hydraulicData, settings, eventsAndStat, to.pdf = FALSE, rainData = NULL, gauges = NULL, landscape = TRUE, plot.event.overview = TRUE, FUN.plot_hydraulic_event = kwb.monitoring::plot_hydraulic_event, ...)
plot_hydraulic_events(hydraulicData, settings, eventsAndStat, to.pdf = FALSE, rainData = NULL, gauges = NULL, landscape = TRUE, plot.event.overview = TRUE, FUN.plot_hydraulic_event = kwb.monitoring::plot_hydraulic_event, ...)
hydraulicData |
data frame with column |
settings |
list of settings (e.g. |
eventsAndStat |
data frame containing event information |
to.pdf |
if |
rainData |
passed to the function given in FUN.plot_hydraulic_event |
gauges |
passed to the function given in FUN.plot_hydraulic_event |
landscape |
orientation of pages in PDF file if |
plot.event.overview |
if |
FUN.plot_hydraulic_event |
function to be called to plot one event |
... |
arguments passed to the function given in FUN.plot_hydraulic_event |
Plot Sampled Event
plot_sampled_event(hydraulicData, settings, sampleInformation = NULL, mergedEventAndStat, volumeCompositeSample = NULL, to.pdf = FALSE, interpolate = TRUE, ...)
plot_sampled_event(hydraulicData, settings, sampleInformation = NULL, mergedEventAndStat, volumeCompositeSample = NULL, to.pdf = FALSE, interpolate = TRUE, ...)
hydraulicData |
data frame with columns DateTime, H, Q, Q.raw, Q.raw.signal, Q.interpol |
settings |
list with elements |
sampleInformation |
passed to |
mergedEventAndStat |
list with event information such as |
volumeCompositeSample |
list with elements |
to.pdf |
logical. If |
interpolate |
passed to |
... |
further arguments given to |
Plot Event Distribution
plotEventDistribution(eventsAndStat, settings)
plotEventDistribution(eventsAndStat, settings)
eventsAndStat |
data frame containing event information |
settings |
list of settings, at least with elements
|
Gantt-Plots for Event Overview
plotEventOverview(events, settings, dbg = FALSE)
plotEventOverview(events, settings, dbg = FALSE)
events |
list with elements hydraulic, sample, merged each of which is a data frame with columns tBeg, tEnd |
settings |
list with elements evtSepTime, station, Hthresholds |
dbg |
logical. If |
Plot Overview
plotOverview(dat, station, Qmax = NULL, Hmax = NULL)
plotOverview(dat, station, Qmax = NULL, Hmax = NULL)
dat |
data frame containing the data to be plotted |
station |
name of monitoring station, used in plot title |
Qmax |
passed to |
Hmax |
passed to |
plotSampleInformation. TODO: simplify interface, e.g. plotSampleInformation(getSampleInformation(getSampleFiles()[1]))
plotSampleInformation(sampleInformation, add = FALSE, xlim = kwb.datetime::toUTC(range(c(sampleInformation$samplingEvents$tBeg, sampleInformation$samplingEvents$tEnd))), ylim = c(-2, 7), main = NA, cex.legend = 0.6, density = 0, plotSampleIntervals = TRUE, maxSamplesOk = NULL, plotSamplingPoints = plotSampleIntervals)
plotSampleInformation(sampleInformation, add = FALSE, xlim = kwb.datetime::toUTC(range(c(sampleInformation$samplingEvents$tBeg, sampleInformation$samplingEvents$tEnd))), ylim = c(-2, 7), main = NA, cex.legend = 0.6, density = 0, plotSampleIntervals = TRUE, maxSamplesOk = NULL, plotSamplingPoints = plotSampleIntervals)
sampleInformation |
list with elements samplingEvents, bottleEvents |
add |
passed to |
xlim |
passed to |
ylim |
passed to |
main |
plot title |
cex.legend |
passed to |
density |
passed to |
plotSampleIntervals |
logical. If |
maxSamplesOk |
maximum number of valid samples. This value is used to calculate an y coordinate |
plotSamplingPoints |
= logical. If |
Plot Total Discharge Versus Rain Properties
plotTotalDischargeVersusRainProperties(hydraulicEvents, stations, main, settings, statistics = "sum", to.pdf = FALSE)
plotTotalDischargeVersusRainProperties(hydraulicEvents, stations, main, settings, statistics = "sum", to.pdf = FALSE)
hydraulicEvents |
data frame containing information on hydraulic events |
stations |
vector of monitoring station names |
main |
plot title |
settings |
list of settings |
statistics |
one of |
to.pdf |
logial. If |
Print Sample Information
printSampleInformation(sampleInformation)
printSampleInformation(sampleInformation)
sampleInformation |
list with elements |
Rain Gauges Near to Monitoring Sites
rainGaugesNearStation(station = NULL)
rainGaugesNearStation(station = NULL)
station |
name of monitoring station in KWB project OGRE or DSWT |
list (one list element per monitoring site) of character vectors representing rain gauge names
Read Multiple Auto-Sampler Files
readAndJoinSamplerFiles(samplerFiles, FUN.readSamplerFile, bottlesToConsider = NA, ...)
readAndJoinSamplerFiles(samplerFiles, FUN.readSamplerFile, bottlesToConsider = NA, ...)
samplerFiles |
vector of paths to sampler files |
FUN.readSamplerFile |
function to be used for reading the sampler file |
bottlesToConsider |
vector of bottle numbers to consider. Defaults to NA meaning that information on all bottles are to be returened. |
... |
further arguments passed to |
data frame with columns file, myDateTime, sample, bottle, volume, unit, result
Remove Duplicates
removeDuplicates(hydraulicData, timeColumnName = "DateTime", keep.first = TRUE)
removeDuplicates(hydraulicData, timeColumnName = "DateTime", keep.first = TRUE)
hydraulicData |
data frame with date and time column as named in
|
timeColumnName |
name of date and time column in |
keep.first |
logical. If |
Remove Intervals
removeIntervals(dataFrame, intervals, dateTimeColumn = names(kwb.utils::posixColumnAtPosition(dataFrame))[1])
removeIntervals(dataFrame, intervals, dateTimeColumn = names(kwb.utils::posixColumnAtPosition(dataFrame))[1])
dataFrame |
data frame with a column as named in |
intervals |
vector of Interval objects as returned by
lubridate::interval, passed to |
dateTimeColumn |
name of date and time column in |
Remove Zoom from History
removeZoomFromHistory(zoomHistory)
removeZoomFromHistory(zoomHistory)
zoomHistory |
list of (i, j) pairs, storing the history of zoom settings |
Sample Data to Sampling Events
sampleDataToSamplingEvents(sampleData, method = "centre", default.interval.width.s = 600, signalWidth = 1)
sampleDataToSamplingEvents(sampleData, method = "centre", default.interval.width.s = 600, signalWidth = 1)
sampleData |
sample data as returned by
|
method |
one of c("left", "right", "centre") |
default.interval.width.s |
default interval width in seconds |
signalWidth |
interval length in seconds that a sampling action is assumed to represent. It is only used to calculate the duration D of the time interval between two samplings at t1 and t2: D = t2 - t1 + signalWidth |
data frame with columns tBeg, tEnd, ...
Sample Log File to Sample Name
sampleLogFileToSampleName(sampleFile)
sampleLogFileToSampleName(sampleFile)
sampleFile |
full path to auto sampler file |
Sampling Events to Bottle Events
samplingEventsToBottleEvents(samplingEvents, signalWidth = 1)
samplingEventsToBottleEvents(samplingEvents, signalWidth = 1)
samplingEvents |
data frame with columns samplerFile, bottle, tBeg, tEnd |
signalWidth |
passed to |
data frame with columns tBeg, tEnd, dur, bottle, samplesOk
Save Regression Model
saveRegressionModel(regressionModel, settings = NULL, dictionary = kwb.utils::selectElements(settings, "dictionary"), sep = kwb.utils::selectElements(settings, "outsep"), dec = kwb.utils::selectElements(settings, "outdec"))
saveRegressionModel(regressionModel, settings = NULL, dictionary = kwb.utils::selectElements(settings, "dictionary"), sep = kwb.utils::selectElements(settings, "outsep"), dec = kwb.utils::selectElements(settings, "outdec"))
regressionModel |
model object to be stored |
settings |
optional. List from which to take the arguments if not given |
dictionary |
dictionary (list) containing entries "REGRESSION_MODEL_TXT" and "REGRESSION_COEFF_TXT" |
sep |
column separator in created file |
dec |
decimal character in created file |
Save Sample Information
saveSampleInformation(sampleInformation, settings, sampleFile)
saveSampleInformation(sampleInformation, settings, sampleFile)
sampleInformation |
list with elements |
settings |
list with elements |
sampleFile |
name of auto sampler file, passed to
|
Select Intervals for Correlation
selectIntervalsForCorrelation(dat.all, settings, h.threshold.max = 0.4)
selectIntervalsForCorrelation(dat.all, settings, h.threshold.max = 0.4)
dat.all |
data frame containing all relevant data passed to
|
settings |
list of settings with elements |
h.threshold.max |
maximum value for the slider |
Update Pauses of Merged Events
setPausesOfMergedEvents(hydraulicEvents, mergedEvents, dbg = FALSE)
setPausesOfMergedEvents(hydraulicEvents, mergedEvents, dbg = FALSE)
hydraulicEvents |
data frame containing information on hydraulic events |
mergedEvents |
data frame containing information on "merged" events |
dbg |
logical. If |
mergedEvents with updated pauses pBefore and pAfter
Show Overview
showOverview(dat, settings, Qmax = NULL, Hmax = NULL, to.pdf = FALSE, save.pdf = FALSE)
showOverview(dat, settings, Qmax = NULL, Hmax = NULL, to.pdf = FALSE, save.pdf = FALSE)
dat |
data frame with columns |
settings |
list with elements |
Qmax |
passed to |
Hmax |
passed to |
to.pdf |
if |
save.pdf |
if |
Update Zoom History
updateZoomHistory(action, zoomHistory, i, j)
updateZoomHistory(action, zoomHistory, i, j)
action |
one of |
zoomHistory |
list of (i, j) pairs, storing the history of zoom settings |
i |
index in range of slider "left" |
j |
index in range of slider "right" |
1. remove rows with duplicate timestamps 2. fill gaps within hydraulic events given by time intervals exceeding H threshold
validateAndFillHydraulicData(hydraulicData, tstep.fill.s = selectElements(settings, "tstep.fill.s"), replaceMissingQMethod = selectElements(settings, "replaceMissingQMethod"), regressionModels = selectElements(selectElements(settings, "regression"), "models")[[selectElements(settings, "station")]], regressionUsage = selectElements(selectElements(settings, "regression"), "usage")[[selectElements(settings, "station")]], hydraulicEvents = NULL, additionalColumns = NULL, modelDir = getOrCreatePath("REGRESSION_DIR", selectElements(settings, "dictionary")), settings = NULL)
validateAndFillHydraulicData(hydraulicData, tstep.fill.s = selectElements(settings, "tstep.fill.s"), replaceMissingQMethod = selectElements(settings, "replaceMissingQMethod"), regressionModels = selectElements(selectElements(settings, "regression"), "models")[[selectElements(settings, "station")]], regressionUsage = selectElements(selectElements(settings, "regression"), "usage")[[selectElements(settings, "station")]], hydraulicEvents = NULL, additionalColumns = NULL, modelDir = getOrCreatePath("REGRESSION_DIR", selectElements(settings, "dictionary")), settings = NULL)
hydraulicData |
data frame with column DateTime, ... |
tstep.fill.s |
target time step in seconds. Time gaps in hydraulicData will be filled with interpolated values |
replaceMissingQMethod |
one of c("interpolate", "predict"). "interpolate": linear interpolation "predict": prediction from water levels using a saved square regression |
regressionModels |
data frame with character columns from, to (or POSIXct columns tBeg and tEnd) and modelFile determining the time intervals to which the different correlation models are assigned. |
regressionUsage |
data frame with character columns from, to (or POSIXct columns tBeg and tEnd) defining the first and last timestamp of the time intervals in which the correlation is to be used |
hydraulicEvents |
hydraulic events |
additionalColumns |
columns additional to "DateTime", "H" and "Q" to be selected from hydraulicData |
modelDir |
full path to the directory where the model files (of the current station) are stored) |
settings |
settings as returned by |
Get indices of rows in hydraulicData in which H or Q thresholds are exceeded
whichAboveThresholds(hydraulicData, indices = seq_len(nrow(hydraulicData)), thresholds = c(H = NA, Q = NA), columns = c(H = "H", Q = "Q"))
whichAboveThresholds(hydraulicData, indices = seq_len(nrow(hydraulicData)), thresholds = c(H = NA, Q = NA), columns = c(H = "H", Q = "Q"))
hydraulicData |
data frame with columns as named in |
indices |
vector of indices of preselected rows from which to exclude those in which the thresholds are exceeded |
thresholds |
vector of thresholds for |
columns |
vector of names containing |
Write CSV to Path From Dictionary
writeCsvToPathFromDictionary(dataFrame, key, settings, open.directory = TRUE, ...)
writeCsvToPathFromDictionary(dataFrame, key, settings, open.directory = TRUE, ...)
dataFrame |
data frame containing data to save |
key |
key in settings$dictionary to be resolved to file path |
settings |
list of settings with elements dictionary, outsep, outdec |
open.directory |
if TRUE (default), the directory in which the file is created is opened in the Windows Explorer after the file has been written. |
... |
arguments passed to |
Write Data and Open Directory
writeDataAndOpenDirectory(dataFrame, filePath, settings)
writeDataAndOpenDirectory(dataFrame, filePath, settings)
dataFrame |
data frame containing data to save |
filePath |
base name of file ("_<moniPoint>_<sampleName>.csv" will be appended) |
settings |
list of settings, as returned by |