| Title: | Miscellaneous functions, not yet intended for distribution |
|---|---|
| Description: | Miscellaneous functions for data analysis with R at KWB, not yet intended for distribution. So far, functions of the following lib-files have been imported: hsLibMiaCsoData.R, hsLibDataAvailability.R, hsLibTimeshift.R, hsLibDataSource.R, hsLibImpSenData.R, hsLibRainDist.R, hsLibCalib.R. |
| Authors: | Hauke Sonnenberg [aut, cre] (ORCID: <https://orcid.org/0000-0001-9134-2871>), Michael Rustler [ctb] (ORCID: <https://orcid.org/0000-0003-0647-7726>), MIA-CSO [fnd], Kompetenzzentrum Wasser Berlin gGmbH (KWB) [cph] |
| Maintainer: | Hauke Sonnenberg <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.2 |
| Built: | 2026-04-26 09:18:18 UTC |
| Source: | https://github.com/KWB-R/kwb.misc |
Add Value Labels
add_value_labels(x, y, labels = y, cex = 0.9)add_value_labels(x, y, labels = y, cex = 0.9)
x |
x coordinates |
y |
y coordinates |
labels |
labels, default: y coordinates |
cex |
character expansion factor, default: 0.9 |
plot rain events from given rain data. Rain data is filtered for rows where signals from all gauges are available and where the sum of signals is greater than zero.
create_and_plot_rain_events( frmRain, strTimestamp = "Zeitstempel", strPdf = NULL, dbg = FALSE )create_and_plot_rain_events( frmRain, strTimestamp = "Zeitstempel", strPdf = NULL, dbg = FALSE )
frmRain |
data frame containing rain data |
strTimestamp |
name of timestamp field, default: "Zeitstempel" |
strPdf |
optional. full path to pdf output file |
dbg |
If |
Get a default dictionary from the meta database
defaultDictionary(mdb = mmdb(), dbg = FALSE)defaultDictionary(mdb = mmdb(), dbg = FALSE)
mdb |
full path to meta database, default: |
dbg |
If |
plot graphs showing the dependencies between package functions
documentPackageFunctionDependencies(packagenames, to.pdf = FALSE)documentPackageFunctionDependencies(packagenames, to.pdf = FALSE)
packagenames |
vector of character containing the names of the packages of which functional dependencies are to be documented. |
to.pdf |
if TRUE, graphical output is written to a pdf file |
# Show names of all installed KWB-packages grep("^kwb\\.", library()$results[, "Package"], value = TRUE) # Document one of the installed packages ## Not run: documentPackageFunctionDependencies("kwb.plot") ## End(Not run)# Show names of all installed KWB-packages grep("^kwb\\.", library()$results[, "Package"], value = TRUE) # Document one of the installed packages ## Not run: documentPackageFunctionDependencies("kwb.plot") ## End(Not run)
example rain data
example_rain_data(version = 1)example_rain_data(version = 1)
version |
Number representing version of data to return. Default: 1 |
Get Rain Stats
get_rain_stat(rain, strTimestamp = names(rain)[1])get_rain_stat(rain, strTimestamp = names(rain)[1])
rain |
data frame containing rain data |
strTimestamp |
Name of column containing timestamps. Default: Name of
first column in |
Generates all possible combinations of events as used for coefficient analysis
hsAllCoefAnaCombis(n, dbg.level = n)hsAllCoefAnaCombis(n, dbg.level = n)
n |
number of elements to be combined |
dbg.level |
if not 0, combinations are shown when dbg.level-th element just changed |
Generate all possible combinations of elements in x with order mattering
hsAllCombis(x)hsAllCombis(x)
x |
vector of elements of which to create combinations |
For one water quality parameter, all overflow events given in "evt" are plotted in different scales given by "fracts" (fractions of interval length). The time-series of the water quality parameter at the container, upstream and downstream are plotted over time as well as the flow.
hsAllTimeshiftPlots( frmOrig, frmUs, frmDs, evt, fieldNames, plusOverview = FALSE, type1 = "l", fracts = c(0, 0.75, 0.5, 0.25, 0.1, 0.05), fieldPrefix = "" )hsAllTimeshiftPlots( frmOrig, frmUs, frmDs, evt, fieldNames, plusOverview = FALSE, type1 = "l", fracts = c(0, 0.75, 0.5, 0.25, 0.1, 0.05), fieldPrefix = "" )
frmOrig |
Original time-series |
frmUs |
upstream shifted time-series |
frmDs |
downstream shifted time-series |
evt |
event list |
fieldNames |
vector containing the relevant table field names as named elements: tsOrig: timestamp in Q time-series), tsUsDs: timestamp in us/ds time-series), fieldQ: name of field containing Q, fieldP: name of field containing wq parameter |
plusOverview |
If true, one plot comprising the whole time-series in |
type1 |
Plot type (default: "l" = line) |
fracts |
Vector of scaling factors. For each factor a plot is generated representing the corresponding fraction of the whole time interval of the event. A factor of zero will plot the whole event. |
fieldPrefix |
Default: "" |
Converts a vector of attribute strings to a matrix with as many columns as there are different attributes occurring in the vector and each row representing an element of the vector for which the values of assigned attributes will occur in the corresponding attribute column.
hsAttribMatrix(attribs)hsAttribMatrix(attribs)
attribs |
Vector containing strings of the form "<key1>=<val1>,<key2>=<val2>,..." |
Return names of available calibrations according to calibration database
hsAvailCalibs( moniPoint = NULL, parAcronym = NULL, skipCur = FALSE, mdbCal = NULL, dbg = FALSE )hsAvailCalibs( moniPoint = NULL, parAcronym = NULL, skipCur = FALSE, mdbCal = NULL, dbg = FALSE )
moniPoint |
acronym of monitoring point |
parAcronym |
acronym of parameter |
skipCur |
if TRUE, the name of the current specification (<parAcronym>_<moniPoint>) is excluded from the list of available calibrations |
mdbCal |
Path to database containing queries that getting calibrated data according to the currently active calibration setting |
dbg |
If |
Return character vector of (filtered) calibration names
Browse through result tree of regression coefficient analysis and "rbind"
data frames linreg
hsBrowseCoefAnaRes(tree, combilen = -1)hsBrowseCoefAnaRes(tree, combilen = -1)
tree |
list representing a |
combilen |
length of combinations. Default: -1 |
Browse through result tree of regression coefficient analysis and "rbind" data frames linreg
hsBrowseCoefAnaResList(reslist, dbg.level = 10)hsBrowseCoefAnaResList(reslist, dbg.level = 10)
reslist |
result list as returned by hsCoefAna(..., recursive = FALSE, aslist = TRUE)) |
dbg.level |
debug level |
browses through result tree and collects all combinations
hsBrowseCombis(tree, combis = list())hsBrowseCombis(tree, combis = list())
tree |
list representing a |
combis |
List of combinations. Default: |
list with first element containing matrix of combinations of length 1, second element containing matrix of combinations of length 2, and so on.
Try all different combinations of events for calibration
hsCalibAna(data, dbg = TRUE, doplot = TRUE, plot.main = "", pdf)hsCalibAna(data, dbg = TRUE, doplot = TRUE, plot.main = "", pdf)
data |
data frame with column |
dbg |
If |
doplot |
logical telling whether to plot within
|
plot.main |
plot title. Default: "" |
pdf |
path to PDF file |
regression coefficient analysis
hsCoefAna( data, recursive = TRUE, evtNums = unique(data$evtID), aslist = recursive, uselm = FALSE, prep = FALSE, ..., dbg.level = max(2, length(evtNums) - 8) )hsCoefAna( data, recursive = TRUE, evtNums = unique(data$evtID), aslist = recursive, uselm = FALSE, prep = FALSE, ..., dbg.level = max(2, length(evtNums) - 8) )
data |
|
recursive |
if TRUE, the |
evtNums |
event numbers to be considered for the analysis. Only considered when recursive == TRUE. default: all distinct values provided in column evtID of data) |
aslist |
default: boolean value given in recursive |
uselm |
if TRUE, the lm function is used to calculate the linear regression,
otherwise ( |
prep |
Default: FALSE |
... |
further arguments passed to |
dbg.level |
default: max(2, length( |
non-recursive version of regression coefficient analysis
hsCoefAnaNonRec(data, uselm = FALSE, aslist = FALSE, ..., dbg.level = 1)hsCoefAnaNonRec(data, uselm = FALSE, aslist = FALSE, ..., dbg.level = 1)
data |
|
uselm |
if TRUE, the lm function is used to calculate the linear regression,
otherwise ( |
aslist |
if TRUE the result is retunred in forms of a list with each list element representing one combination. otherwise in forms of a database with columns np (number of points), offset, slope, combi. Default: FALSE. |
... |
further arguments passed to |
dbg.level |
debug level |
recursive version of regression coefficient analysis
hsCoefAnaRec( data, evtNums = unique(data$evtID), combi = NULL, tree = TRUE, resframe = NULL, uselm = FALSE, ..., dbg.level = 1 )hsCoefAnaRec( data, evtNums = unique(data$evtID), combi = NULL, tree = TRUE, resframe = NULL, uselm = FALSE, ..., dbg.level = 1 )
data |
|
evtNums |
event numbers to be considered for the analysis (default: all distinct values provided in column evtID of data) |
combi |
current combination to be evaluated and to be the base for the next combinations to be determined |
tree |
if TRUE, result is given in a |
resframe |
if tree is FALSE, this argument contains the results that have
been found so far in a |
uselm |
if TRUE, the lm function is used to calculate the linear regression,
otherwise ( |
... |
further arguments passed to |
dbg.level |
debug level |
Recursive list representing a tree structure. At the top level the list
contains elements e<i> where <i> are the event IDs to be considered
(elements in evtNums).
The sub lists below the top level (but not the "leafs" of the tree) also
contain elements e<j> where <j> are the "remaining" event IDs,
i.e. the IDs that do not yet occur in the "path" of event IDs
leading to the respective sub tree. These sub lists also have elements
combi (vector of event IDs representing the respective event
combination) and linreg containing the results from linear
regression. In fact, linreg is a data frame with each line
representing the slope and offset of the linear regression
through np number of points, taken from the events in combi.
Calculation of linear regressions for given combination of events
hsCombiLinReg( data, combi, uselm = FALSE, clever = FALSE, prep = FALSE, calc.rmse = TRUE, dbg = FALSE )hsCombiLinReg( data, combi, uselm = FALSE, clever = FALSE, prep = FALSE, calc.rmse = TRUE, dbg = FALSE )
data |
|
combi |
combination of events for which linear regressions are to be calculated
in the following way: the first event numbers in |
uselm |
if TRUE, the lm function is used to calculate the linear regression,
otherwise ( |
clever |
if TRUE, sums and means are updated by knowledge of previous values with
the current |
prep |
if TRUE, |
calc.rmse |
if TRUE, the root mean square error (RMSE) is calculated |
dbg |
If |
Get calibrated data according to current calibration
hsCurCal(moniPoint, parAcronym, globOnly = FALSE, mdbCal = NULL)hsCurCal(moniPoint, parAcronym, globOnly = FALSE, mdbCal = NULL)
moniPoint |
acronym of monitoring point |
parAcronym |
acronym of parameter |
globOnly |
logical. Globals only? Default: FALSE |
mdbCal |
Path to database containing queries that getting calibrated data according to the currently active calibration setting |
data availability in time-series data
hsDataAvailability( data, tstep = minTimeStep(data[[1]], dbg = dbg), interval = 60 * 60 * 24, includeCount = TRUE, dbg = FALSE )hsDataAvailability( data, tstep = minTimeStep(data[[1]], dbg = dbg), interval = 60 * 60 * 24, includeCount = TRUE, dbg = FALSE )
data |
|
tstep |
expected timestep between consecutive timestamps in seconds. Default: minimum time difference occurring in timestamps of data. |
interval |
length of time intervals to which |
includeCount |
if TRUE, not only the |
dbg |
If |
Data availability of time series data
hsDataAvailability.old( info, dateFirst = NULL, dateLast = NULL, tstep = NULL, dbg = FALSE )hsDataAvailability.old( info, dateFirst = NULL, dateLast = NULL, tstep = NULL, dbg = FALSE )
info |
list with the named elements (mdb: full path to Access database, tbl: table name, tsField: name of timestamp field, parField: name of parameter field) |
dateFirst |
Date object representing first date to be considered |
dateLast |
Date object representing last date to be considered |
tstep |
expected time step between time stamps in seconds. Default: minimum time difference found between consecutive timestamps in given interval |
dbg |
If TRUE, debug messages will be shown |
data.frame with each row representing a day within the specified time
interval and columns (day),
(number of non-NA-values in column <Par> within the interval)
and (data availability of parameter <Par> in percent
= number of available non-NA-values divided by maximum possible
number of non-NA-values per day (= 86400 / tstep).
Gets recursively defined directory structure from RMeta.mdb
hsDirStructure(asMatrix = FALSE, dbg = FALSE)hsDirStructure(asMatrix = FALSE, dbg = FALSE)
asMatrix |
logical indicating whether to return a matrix or not |
dbg |
If |
Drop an existing table (user interaction)
hsDropExistingTable(channel, strTable, boolAsk = TRUE)hsDropExistingTable(channel, strTable, boolAsk = TRUE)
channel |
database connection |
strTable |
table name |
boolAsk |
logical indication whether the user should be asked before dropping the table |
table name of created table.
returns the first index at which elements in combi1 and combi2 differ
hsEqualUntilPos(combi1, combi2)hsEqualUntilPos(combi1, combi2)
combi1 |
vector |
combi2 |
vector of same mode as |
provide example dataset for coefficient analysis with hsCoefAna
hsExampleCoefData( nevts = 5, step = 30, ex.avail = FALSE, dev = 0.01, dbg = FALSE )hsExampleCoefData( nevts = 5, step = 30, ex.avail = FALSE, dev = 0.01, dbg = FALSE )
nevts |
number of gaps to be produced in continuous examle data in order to split events. default: 5 |
step |
timestep in seconds. default: 30 |
ex.avail |
example data available? default: FALSE |
dev |
deviation. default: 0.01 |
dbg |
If |
find file candidates according to paths defined in dictionary
hsFileCands(mdb, dict.lst, dbg = FALSE)hsFileCands(mdb, dict.lst, dbg = FALSE)
mdb |
path to MS Access database |
dict.lst |
path dictionary (a list) |
dbg |
If |
Lookup a water quality parameter defined by (SEN-ID, name, unit)
hsGetOrCreateParID(parInfo, parDefs)hsGetOrCreateParID(parInfo, parDefs)
parInfo |
parameter definition |
parDefs |
list of parameter definitions |
List with two elements myParID and parDefs.
If the parameter defined in parInfo was found in the list of all
parameters parDefs that have been found so far, the unique
parameter ID used in parDefs is returned in myParID. If the
parameter was not found it is added to parDefs and
Lookup name of water quality parameter and return its ID or NA if
the parameter is not yet contained in the data frame wqpNames
hsGetParID(parName, wqpNames)hsGetParID(parName, wqpNames)
parName |
parameter name |
wqpNames |
data frame describing (water quality) parameters |
Returns vector of SQL strings each of which selects the values of one water quality parameter (in one column) from table “tbl” giving general column names
hsGetSqls(mdb, tbl, mpID, belowAbove = FALSE, bis2007 = FALSE)hsGetSqls(mdb, tbl, mpID, belowAbove = FALSE, bis2007 = FALSE)
mdb |
path to MS Access database |
tbl |
table name |
mpID |
monitoring point ID |
belowAbove |
Default: FALSE |
bis2007 |
Default: FALSE |
write table containing all grab sample data in "all-in-one-table"-format
to mdb database
hsGsDataListToMdb(gsDataList, mdb, ...)hsGsDataListToMdb(gsDataList, mdb, ...)
gsDataList |
List of grab sample data sets |
mdb |
path to MS Access database |
... |
arguments passed to hsPutTable |
csv
import SENATE's grab sample data from csv
hsImpGsData( csv, mdb, sep = ",", dateFormat = underscoreToPercent("_d/_m/_Y"), blockBeginPtrn = "Messstelle", tblNamePtrn = "tblSenGrabSmp_@M", boolAsk = TRUE, dbg = FALSE )hsImpGsData( csv, mdb, sep = ",", dateFormat = underscoreToPercent("_d/_m/_Y"), blockBeginPtrn = "Messstelle", tblNamePtrn = "tblSenGrabSmp_@M", boolAsk = TRUE, dbg = FALSE )
csv |
full path to |
mdb |
full path to MS Access database (*.mdb) |
sep |
separator in |
dateFormat |
date format in |
blockBeginPtrn |
pattern indicating the begin of a data block in the file (default: Messstelle) |
tblNamePtrn |
table name pattern. Default: "tblSenGrabSmp_@M" with the placeholder @M being replaced with the acronym of the monitoring point |
boolAsk |
logical passed to |
dbg |
If |
For each index <iStart> of vector values, this function tries to find
a corresponding index <iStop> in such a way that the sum of the vector
elements at indices between <iStart> and <iStop> reaches the given
threshold. For each possible start index i, the algorithm starts
either looking forward at indices i+1, i+2, ... or backwards at
indices i-1, i-2, ..., accumulating the values at these indices. Once the
accumulated sum reached the given threshold or if the difference
between the indices exceeds the maximum allowed index difference
maxDist the algorithm stops and continues with the next start index.
hsIntSumGeThreshold( tSeries, threshold, forward, maxTDiff, tsField = names(tSeries)[1], valField = names(tSeries)[2], valFactor = 1, includeIndices = TRUE, dbg = FALSE )hsIntSumGeThreshold( tSeries, threshold, forward, maxTDiff, tsField = names(tSeries)[1], valField = names(tSeries)[2], valFactor = 1, includeIndices = TRUE, dbg = FALSE )
tSeries |
data.frame with timestamps in first column and values in second column. |
threshold |
Threshold that shall be reached/exceeded by the sum of successive elements of values of which the maximum time difference is below or equal maxTDiff. |
forward |
If TRUE, the algorithm looks |
maxTDiff |
Maximum allowed time difference in seconds between two related timestamps. |
tsField |
Name of time stamp field; default: name of first column |
valField |
Name of value field containing the values of which the sum
shall reach the |
valFactor |
Factor to be applied to column valField before calculating value sums. |
includeIndices |
if TRUE, two columns iStart and iStop are included in the output data frame indicating the indices in tSeries corresponding to the timestamps tStart and tStop. |
dbg |
If |
data frame with columns iStart and iStop being the indices of tSeries that represent the beginning and the end of the time interval in which the value field sums up to at least threshold, tStart, tStop and tDiff representing the first timestamp, last timestamp and duration of the corresponding time intervals and the column sumWithin being the sum of values that was actially reached within the interval.
Merge Data in Available Calibrations
hsMergeAvailCalibs(moniPoint, parAcronym, mdbCal, ...)hsMergeAvailCalibs(moniPoint, parAcronym, mdbCal, ...)
moniPoint |
acronym of monitoring point |
parAcronym |
acronym of parameter |
mdbCal |
path to MS Access database containing calibration data |
... |
arguments given to |
data frame with the first two columns representing the timestamp and the global calibration, respectively and the following columns representing available calibrations, beginning with the "current" calibration that is stored in the calibration database under the name <parAcronym>_<moniPoint>, e.g. "AFS_STA"
Return directory paths containing mdb databases matching the criteria
defined by the ... parameter list
hsMiaDir(dbg = FALSE, ...)hsMiaDir(dbg = FALSE, ...)
dbg |
If |
... |
assignments of the form "name = value" |
given a current combination the next combination of events as used for coefficient analysis is provided
hsNextCoefAnaCombi(combi, n)hsNextCoefAnaCombi(combi, n)
combi |
current combination of which the "successor" combination is to be provided |
n |
number of elements in the combination (= length of combination) |
Plot Results of Calibration Analysis
hsPlotCalOverview(moniPoint, parAcronym, mdbCal, pdf, ...)hsPlotCalOverview(moniPoint, parAcronym, mdbCal, pdf, ...)
moniPoint |
acronym of monitoring point |
parAcronym |
acronym of parameter |
mdbCal |
path to MS Access database containing calibration data |
pdf |
path to PDF file to be created |
... |
arguments given to |
Plot function to visualise the regression lines calculated by hsCoefAna.
hsPlotCoefAnaRes(data, res, recursive = FALSE)hsPlotCoefAnaRes(data, res, recursive = FALSE)
data |
|
res |
result tree as returned by |
recursive |
Default: FALSE |
Plot function to visualise the distribution of slopes and offsets of regression lines through possible combinations of events.
hsPlotCoefAnaRes2(data, res, olim = NULL, slim = NULL)hsPlotCoefAnaRes2(data, res, olim = NULL, slim = NULL)
data |
|
res |
result tree as returned by |
olim |
limits of offset values to be used for plotting the offsets |
slim |
limits of slope values to be used for plotting the offsets |
barplot showing data availability in (e.g. daily) time intervals.
hsPlotDataAvailability( avail, colNames = NULL, firstIntBeg = NULL, lastIntBeg = NULL, main = "hsPlotDataAvailability", barCols = NULL, labelStep = 2, firstPlot = TRUE, dbg = FALSE, ... )hsPlotDataAvailability( avail, colNames = NULL, firstIntBeg = NULL, lastIntBeg = NULL, main = "hsPlotDataAvailability", barCols = NULL, labelStep = 2, firstPlot = TRUE, dbg = FALSE, ... )
avail |
data frame containing the availibility information as returned by
|
colNames |
name of column containing availabilities |
firstIntBeg |
timestamp indicating the begin of the first interval to be plotted |
lastIntBeg |
timestamp indicating the begin of the last interval to be plotted |
main |
|
barCols |
bar colour(s). If |
labelStep |
if set to <n>, only every n-th date label will be shown in the plot |
firstPlot |
if TRUE, barplot is replotted, else plot is added to existing plot |
dbg |
If |
... |
further arguments to be passed to R's barplot() function. |
Plot Event Overview
hsPlotEventOverview( dat, evts = NULL, evtSepTime = 3600, myTitle = "Event Overview", plotTypes = rep("l", ncol(dat) - 1), dbg = TRUE, ... )hsPlotEventOverview( dat, evts = NULL, evtSepTime = 3600, myTitle = "Event Overview", plotTypes = rep("l", ncol(dat) - 1), dbg = TRUE, ... )
dat |
data frame with at least two columns and the timestamps being in the first column |
evts |
data frame with columns tBeg and tEnd containing first and
last timestamp, respectively, of the events. If NULL (default) the
events are generated by calling hsEvents (using all timestamps in |
evtSepTime |
event separation time in seconds, default: 3600 (= 1h) |
myTitle |
plot title |
plotTypes |
vector containing the plot type (cp. type argument of plot function) for each data column to be plotted |
dbg |
If |
... |
e.g. inset = |
prints content of an object to a plot
hsPrintToPlot(data, main = "Printed by hsPrintToPlot", addLines = NULL, ...)hsPrintToPlot(data, main = "Printed by hsPrintToPlot", addLines = NULL, ...)
data |
object to print |
main |
plot title |
addLines |
additional lines |
... |
additional arguments passed to legend, e.g. cex |
Filter timeseries interactively for interval or parallel intervals
hsSel(tseries, interval = FALSE, tsfield = names(tseries)[1], dbg = FALSE)hsSel(tseries, interval = FALSE, tsfield = names(tseries)[1], dbg = FALSE)
tseries |
data frame containing time series data |
interval |
logical. Default: FALSE |
tsfield |
Name of column containing the time stamps. Default: name of first column |
dbg |
If |
Interactively select parallel time intervals from data.frame containing timeseries
hsSelectParallelTimeIntervals(tseries, tsfield = names(tseries)[1])hsSelectParallelTimeIntervals(tseries, tsfield = names(tseries)[1])
tseries |
data.frame containing timeseries (at least one timestamp column and one additional numeric column) |
tsfield |
name of timestamp column; default: name of first column in |
Interactively select time interval from data.frame containing timeseries
hsSelectTimeInterval(tseries, tsfield = names(tseries)[1])hsSelectTimeInterval(tseries, tsfield = names(tseries)[1])
tseries |
data.frame containing timeseries (at least one timestamp column and one additional numeric column) |
tsfield |
name of timestamp column; default: name of first column in |
Return data frame containing ids, properties and paths of mdb databases
matching criteria given in ... argument list
hsSourceList(keyptrn = "^DB_", dbg = FALSE, ...)hsSourceList(keyptrn = "^DB_", dbg = FALSE, ...)
keyptrn |
Pattern matching the keys representing databases. Default: "^DB_" |
dbg |
If |
... |
definition of filter criteria given as "key = value" pairs |
Get calibrated data according to a special calibration given by its name. Instead of running the prepared query in “KWB_CAL.mdb” the specific SQL query respecting the given calibratio name is built and run here.
hsSpecCal(moniPoint, parAcronym, calName = NULL, mdbCal = NULL)hsSpecCal(moniPoint, parAcronym, calName = NULL, mdbCal = NULL)
moniPoint |
acronym of monitoring point |
parAcronym |
acronym of parameter |
calName |
name of calibration |
mdbCal |
Path to database containing queries that getting calibrated data according to the currently active calibration setting |
Generate SQL expression needed to get calibrated data
hsSqlExCal(moniPoint, parAcronym, calName = NULL)hsSqlExCal(moniPoint, parAcronym, calName = NULL)
moniPoint |
acronym of monitoring point |
parAcronym |
acronym of parameter |
calName |
name of calibration |
Evaluate a specific combination of events used for calibration
hsTestCombi( data, combi, plot = TRUE, plot.main = "Lab values vs probe values", COLS = rainbow(length(unique(data$evtid))) )hsTestCombi( data, combi, plot = TRUE, plot.main = "Lab values vs probe values", COLS = rainbow(length(unique(data$evtid))) )
data |
data frame |
combi |
combination of events used for calibration |
plot |
logical indicating whether to plot |
plot.main |
plot title |
COLS |
vector of colours |
upstream or downstream "timeshift" of water quality data given
time-series of hydraulic and water quality data in one data frame
hsTimeshift( hq, threshold, upstream = TRUE, tsField = names(hq)[1], valField = names(hq)[2], quaFields = names(hq)[-c(1, 2)], maxTDiff = 3600, valFactor = 1, dbg = FALSE )hsTimeshift( hq, threshold, upstream = TRUE, tsField = names(hq)[1], valField = names(hq)[2], quaFields = names(hq)[-c(1, 2)], maxTDiff = 3600, valFactor = 1, dbg = FALSE )
hq |
hydraulic and water quality data in one data frame |
threshold |
Threshold that shall be reached/exceeded by the sum of successive values in column valField of which the maximum time difference is below or equal maxTDiff. |
upstream |
if TRUE, the algorithm “looks” |
tsField |
name of timestamp field in hq |
valField |
name of column in hq containing the values to be
summed up until the |
quaFields |
vector containing column names of water quality parameters, e.g. c("AFS", "CSB", "CSBf") |
maxTDiff |
Maximum allowed time difference in seconds between two related timestamps. |
valFactor |
factor to be applied to column valField before calculating value sums. |
dbg |
If |
A plot is generated, containing flow measurements as well as measurements
(original, upstream/downstream time-shifted) of one water quality parameter
and for one overflow events i contained in the event list "evt".
hsTimeshiftPlot( frmOrig, frmUs, frmDs, evt, fieldNames, i, evtDurFract, type1, boolOverview = FALSE, fieldPrefix = "" )hsTimeshiftPlot( frmOrig, frmUs, frmDs, evt, fieldNames, i, evtDurFract, type1, boolOverview = FALSE, fieldPrefix = "" )
frmOrig |
data frame with original measurements |
frmUs |
data frame with measurements time-shifted upstream |
frmDs |
data frame with measurements time-shifted downstream |
evt |
event list |
fieldNames |
field names |
i |
index |
evtDurFract |
event duration fraction |
type1 |
plot type, e.g. "p" for "points", passed to |
boolOverview |
should an overview be plotted? |
fieldPrefix |
field prefix |
Creates UNION-queries of given SQL queries, respecting the maximum number of subqueries to be used in one and the same UNION query.
hsUnionSqls(sqls, maxUnions)hsUnionSqls(sqls, maxUnions)
sqls |
vector of SQL statements |
maxUnions |
number of maximum UNIONs allowed |
vector of UNION queries
write data block to database table
hsWriteBlockToTable( channel, block, blockName, tblNamePtrn = "tblSenGrabSmp_@M", boolAsk, dbg = FALSE )hsWriteBlockToTable( channel, block, blockName, tblNamePtrn = "tblSenGrabSmp_@M", boolAsk, dbg = FALSE )
channel |
database connection |
block |
block |
blockName |
block name |
tblNamePtrn |
name of table to be written in database. @M is replaced with the name of the monitoring point |
boolAsk |
logical. Ask before tropping existing tables? |
dbg |
If |
Path to Metadata Database
mmdb(id = 0)mmdb(id = 0)
id |
id of record. Currently, only 0 allowed (the default) |
calculate checksum for each row of a data frame or matrix x. Each combination of NA-occurrence in the row gets a different checksum. Therefore, each column of x is represented as a power of two and for the columns in which the row contains NA the corresponding powers of two are added.
na_checksum(x)na_checksum(x)
x |
data frame or matrix |
capture the output of printing an object, split this output into blocks of
equal size (row per page) and print these blocks as plots using
hsPrintToPlot
pageAndPlot(data, rpp = 60, to.pdf = TRUE, ...)pageAndPlot(data, rpp = 60, to.pdf = TRUE, ...)
data |
|
rpp |
rows per page |
to.pdf |
if TRUE (default) the output goes into a temporary PDF file, otherwise to the standard plot device |
... |
arguments to be passed to |
plot all rain events from given rain data and event information.
This function calls plot_one_rain_event_2 in a loop over all events
with indices between imin and imax.
plot_given_rain_events( rain, evt, imin = 1, imax = -1, sigWidth_s, myCex = 0.7, myMinN )plot_given_rain_events( rain, evt, imin = 1, imax = -1, sigWidth_s, myCex = 0.7, myMinN )
rain |
data frame containing |
evt |
event information as returned by |
imin |
row index in evt of first event to be considered. Default: 1 |
imax |
row index in evt of last event to be considered. Set to -1 (default) to consider all events. |
sigWidth_s |
|
myCex |
default: 0.7 |
myMinN |
minimum total precipitation in mm. Rain events with less precipitation are not plotted |
Plot One Rain Event
plot_one_rain_event(frmR, evt, i)plot_one_rain_event(frmR, evt, i)
frmR |
data frame containing rain data |
evt |
data frame containing event data |
i |
index into event data |
plot one rain event by calling plot_one_rain_gauge_event
plot_one_rain_event_2( rain, rainEventIndex = 1, sigWidth_s = NULL, boolBarplot = TRUE, myCex = 1, myMinN = 0 )plot_one_rain_event_2( rain, rainEventIndex = 1, sigWidth_s = NULL, boolBarplot = TRUE, myCex = 1, myMinN = 0 )
rain |
data frame containing rain data |
rainEventIndex |
rain event index |
sigWidth_s |
|
boolBarplot |
logical. Default: |
myCex |
character expansion factor. Default: 1 |
myMinN |
minimum total precipitation. Default: 0 |
Plot One Rain Event 3
plot_one_rain_event_3(frmR, evt, i, myCols)plot_one_rain_event_3(frmR, evt, i, myCols)
frmR |
data frame containing rain data |
evt |
data frame containing rain event data |
i |
index |
myCols |
vector of colours |
Plot Rain Event
plot_one_rain_gauge_event( rain, sigWidth_s = NULL, i = 2, Nmax = 1, boolLabels = FALSE, boolDebug = FALSE, myBlue = rainbow(8)[6], nMaxLabels = 60, dbg = FALSE )plot_one_rain_gauge_event( rain, sigWidth_s = NULL, i = 2, Nmax = 1, boolLabels = FALSE, boolDebug = FALSE, myBlue = rainbow(8)[6], nMaxLabels = 60, dbg = FALSE )
rain |
data frame containing rain data |
sigWidth_s |
signal width in seconds |
i |
Default: 2 |
Nmax |
Default: 1 |
boolLabels |
plot labels? |
boolDebug |
logical |
myBlue |
nice blue colour |
nMaxLabels |
# max number of labels per page |
dbg |
If |
plot rain events from given rain data. Either one plot per day or one plot
per rain event (created within this function). This function calls
plot_given_rain_events
plot_rain_events( rain, strTimestamp = "Zeitstempel", strPdf = NULL, irng = c(1, -1), myCex = 0.7, myMinN, evtSepTime_s = 60 * 60 * 6, sigWidth_s = 300, events = TRUE )plot_rain_events( rain, strTimestamp = "Zeitstempel", strPdf = NULL, irng = c(1, -1), myCex = 0.7, myMinN, evtSepTime_s = 60 * 60 * 6, sigWidth_s = 300, events = TRUE )
rain |
data frame containing |
strTimestamp |
name of timestamp field, default: "Zeitstempel" |
strPdf |
optional. path to output pdf file |
irng |
vector of two integer values determining the first and last index,
respectively, in the data frame of |
myCex |
default: 0.7 |
myMinN |
minimum precipitation in mm. Events with a total depth less than this value are not plotted |
evtSepTime_s |
event separation time in seconds. Default: 6*3600 = 6 hours |
sigWidth_s |
|
events |
one plot per event ( |
Plot Rain Events to PDF
plot_rain_events_to_pdf(frmR, evt, strPdf, myCols, myVersion = 1)plot_rain_events_to_pdf(frmR, evt, strPdf, myCols, myVersion = 1)
frmR |
data frame containing rain data |
evt |
data frame containing rain event data |
strPdf |
path to PDF file |
myCols |
vector of colours |
myVersion |
Default: 1 |
Plot Rain Subevents by Checksum
plot_rain_subevents_by_checksum(rain, evt, n = nrow(evt))plot_rain_subevents_by_checksum(rain, evt, n = nrow(evt))
rain |
data frame containing rain data |
evt |
data frame containin rain event data |
n |
Default: number of rows in |
Plot Rain with Subevent Lines
plot_rain_with_subevent_lines(rain, subevt, rainEventIndex)plot_rain_with_subevent_lines(rain, subevt, rainEventIndex)
rain |
data frame containing rain data |
subevt |
subevent data |
rainEventIndex |
rain event index |
Plot Data Availability
plotDataAvailability( rainStat, n = nrow(rainStat), main = "Data Availability", cex = 0.9, barColours = c("lightgreen", "indianred") )plotDataAvailability( rainStat, n = nrow(rainStat), main = "Data Availability", cex = 0.9, barColours = c("lightgreen", "indianred") )
rainStat |
rain statistics with one row per rain event |
n |
number of rain event |
main |
plot title |
cex |
character expansion factor. Default: 0.9 |
barColours |
vector of bar colours |
minDate and maxDate must be given as "yyyy-mm-dd"
Timestamps of the day given in minDate are included, whereas timestamps of
the day given in maxDay are excluded! This way it is easy to select whole
months or whole years by selecting the first day of the next month/year as
maxDate.
It is assumed that all but the first columns contain rain heights!
plotRainOverview( rain, minDate = "", maxDate = "", strTimestamp = "Zeitstempel", boolMaxDateIncluded = FALSE, Nmax_mm = NA, cex = 0.9 )plotRainOverview( rain, minDate = "", maxDate = "", strTimestamp = "Zeitstempel", boolMaxDateIncluded = FALSE, Nmax_mm = NA, cex = 0.9 )
rain |
data frame containing rain data |
minDate |
minimum date |
maxDate |
maximum date |
strTimestamp |
name of timestamp column. Default: "Zeitstempel" |
boolMaxDateIncluded |
logical. Should the maximum date be included? |
Nmax_mm |
Default: NA |
cex |
character expansion factor. Default: 0.9 |
Plot Total Precipitation
plotTotalPrecipitation( rainStat, n = nrow(rainStat), main = "Total Precipitation", Nmax_mm = NA, cex = 0.9 )plotTotalPrecipitation( rainStat, n = nrow(rainStat), main = "Total Precipitation", Nmax_mm = NA, cex = 0.9 )
rainStat |
data frame with column N_mm and row names indicating rain gauge names |
n |
number of rain series |
main |
plot title |
Nmax_mm |
maximum total precipitation in mm |
cex |
character expansion factor. Default: 0.9 |
Prepare Rain Data
prepare_rain_data( rain, myVersion, event_sep_time = 60 * 60 * 6, signal_width = 300 )prepare_rain_data( rain, myVersion, event_sep_time = 60 * 60 * 6, signal_width = 300 )
rain |
rain data |
myVersion |
1 or 2, depending on required output |
event_sep_time |
event separation time in seconds |
signal_width |
signal width, i.e. time period that a rain data point represents, in seconds |
Read Rain Data from Database
read_rain_from_mdb(myVersion, strDb)read_rain_from_mdb(myVersion, strDb)
myVersion |
1 (to read from tbl_Regen_alleEZG_05min) or 2 (to read from tbl_Regen_alleEZG_05min) |
strDb |
path to MS Access database |