| Title: | functions used in KWB project MIA-CSO |
|---|---|
| Description: | functions used in KWB project MIA-CSO, for example for plotting data availabilities. |
| 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.1.0 |
| Built: | 2026-04-15 04:49:28 UTC |
| Source: | https://github.com/KWB-R/kwb.miacso |
MS Access Databases (Hydraulic Data)
hmdb(...)hmdb(...)
... |
arguments passed to |
Returns a list containing
full path to Access database,
table name,
name of timestamp field,
name of parameter field
for the table that contains data of parameter parName, measured at
monitoring point moniPoint in data quality level qua.level.
hsDataSource( qua.level = NULL, moniPoint = NULL, parName, kind = "q", owner = "KWB", dbg = FALSE )hsDataSource( qua.level = NULL, moniPoint = NULL, parName, kind = "q", owner = "KWB", dbg = FALSE )
qua.level |
data quality level ("r" = raw, "v" = validated, "c" = calibrated) |
moniPoint |
name of monitoring point, e.g. "STA", "TEG", "MUE" |
parName |
name of parameter, e.g. "AFS", "CSB", "CSBf" |
kind |
kind of data: "q" = water quality, "h" = hydraulic data, "r" = rain |
owner |
owner of the data, one of "KWB", "SEN", "BWB" |
dbg |
whether to show debug messages or not |
Returns a list with the following named elements:
mdb: full path to Access database,
tbl: table name,
tsField: name of timestamp field,
parField: name of parameter field
# Get source information of validated data of parameter AFS from Stallstr. si <- hsDataSource("v", "STA", "AFS") si # ouput: # $db # [1] "//moby/miacso$/Daten/ACCESS/KwbMonitoring/2VAL/KWB_STA_VAL.mdb" # # $tbl # [1] "KWB_STA_ScanPar_AFS_VAL" # # $tsfield # [1] "myDateTime" # # $parfield # [1] "AFS_A" # Access the pieces of information with the $ operator: si$mdb # [1] "//moby/miacso$/Daten/ACCESS/KwbMonitoring/2VAL/KWB_STA_VAL.mdb" si$tbl # [1] "KWB_STA_ScanPar_AFS_VAL"# Get source information of validated data of parameter AFS from Stallstr. si <- hsDataSource("v", "STA", "AFS") si # ouput: # $db # [1] "//moby/miacso$/Daten/ACCESS/KwbMonitoring/2VAL/KWB_STA_VAL.mdb" # # $tbl # [1] "KWB_STA_ScanPar_AFS_VAL" # # $tsfield # [1] "myDateTime" # # $parfield # [1] "AFS_A" # Access the pieces of information with the $ operator: si$mdb # [1] "//moby/miacso$/Daten/ACCESS/KwbMonitoring/2VAL/KWB_STA_VAL.mdb" si$tbl # [1] "KWB_STA_ScanPar_AFS_VAL"
String representing comma separated list of fields in fingerprint table
hsFpFields(moniPoint)hsFpFields(moniPoint)
moniPoint |
acronym of monitoring point: "STA", "TEG" or "MUE" |
String representing comma separated list of fields in fingerprint table
For the given parameters, the values and fingerprints are read from the database.
hsGetFpAndValRaw(moniPoint, parNames, year, firstDate, lastDate, home = FALSE)hsGetFpAndValRaw(moniPoint, parNames, year, firstDate, lastDate, home = FALSE)
moniPoint |
name of monitoring point |
parNames |
vector of parameter names |
year |
year of which data is requested |
firstDate |
first date of requested time period |
lastDate |
last date of requested time period |
home |
if |
Return the query result as a new data.frame (which is a special type of a list) with elements "dts" (date-times), "pars" (parameter values) and "fps" (fingerprints)
2011-10-25: created
hsGetValData(moniPoint, parName, firstDate, lastDate)hsGetValData(moniPoint, parName, firstDate, lastDate)
moniPoint |
name of monitoring point, e.g. "TEG", "STA", "MUE" |
parName |
parameter name, e.g. "AFS" |
firstDate |
first date to be selected as "mm/dd/yyyy hh:nn:ss" |
lastDate |
last date to be selected as "mm/dd/yyyy hh:nn:ss" |
data.frame containing validated data
Returns the index at which the wavelength given in nm can be found in a vector (i = 1: 200nm, i = 2: 202.5nm, ..., i = 217: 740nm).
hsIndexOfWavelength(wavelength)hsIndexOfWavelength(wavelength)
wavelength |
Wavelength for which corresponding index shall be determined |
2011-12-19: moved from hsLibFingerprint.r
Index corresponding the given wavelength
Returns the last available wavelength of the spectrometer installed at the given monitoring point.
hsLastWL(moniPoint)hsLastWL(moniPoint)
moniPoint |
Name of monitoring point, e.g. "TEG", "STA", "MUE" |
2011-12-19: moved from hsLibFingerprint.r
Last wavelength being provided by spectrometer at given monitoring point
Data availability of raw/validated/calibrated data for parameter para,
measured at monitoring point moniPoint between dateFirst and
dateLast.
hsMiaCsoDataAvailability( level, moniPoint, parName, dateFirst = NULL, dateLast = NULL, tstep = NULL, dbg = FALSE )hsMiaCsoDataAvailability( level, moniPoint, parName, dateFirst = NULL, dateLast = NULL, tstep = NULL, dbg = FALSE )
level |
one of "r" (= raw), "v" (= validated), "c" (= calibrated) |
moniPoint |
one of "STA" (= Stallstr.), "TEG" (= Tegeler Weg), "MUE" (= Muehlendamm) |
parName |
e.g. "AFS", "CSB", "CSBf", ... |
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 |
## Not run: # Get data availability of raw data of parameter "CSBf", measured at # monitoring point "TEG" (Tegeler Weg) between 2011-04-01 and 2011-10-01 da <- hsMiaCsoDataAvailability("r", "TEG", "CSBf", "2011-04-01", "2011-10-01") head(da) ## End(Not run) # Output: # myInterval myCount myAvail # 1 2011-04-01 1440 100.00000 # 2 2011-04-02 1440 100.00000 # 3 2011-04-03 1440 100.00000 # 4 2011-04-04 1440 100.00000 # 5 2011-04-05 1440 100.00000 # 6 2011-04-06 1409 97.84722## Not run: # Get data availability of raw data of parameter "CSBf", measured at # monitoring point "TEG" (Tegeler Weg) between 2011-04-01 and 2011-10-01 da <- hsMiaCsoDataAvailability("r", "TEG", "CSBf", "2011-04-01", "2011-10-01") head(da) ## End(Not run) # Output: # myInterval myCount myAvail # 1 2011-04-01 1440 100.00000 # 2 2011-04-02 1440 100.00000 # 3 2011-04-03 1440 100.00000 # 4 2011-04-04 1440 100.00000 # 5 2011-04-05 1440 100.00000 # 6 2011-04-06 1409 97.84722
Returns the names of available monitoring points
hsMoniPoints(kind = NULL, owner = "KWB")hsMoniPoints(kind = NULL, owner = "KWB")
kind |
kind of data: "q" = water quality, "h" = hydraulic data, "r" = rain |
owner |
owner of the data, one of "KWB", "SEN", "BWB" |
Names of available parameters
hsPars( kind = NULL, moniPoint = NULL, qua.level = "c", owner = "KWB", dbg = TRUE )hsPars( kind = NULL, moniPoint = NULL, qua.level = "c", owner = "KWB", dbg = TRUE )
kind |
kind of data: "q" = water quality, "h" = hydraulic data, "r" = rain |
moniPoint |
name of monitoring point, e.g. "STA", "TEG", "MUE" |
qua.level |
data quality level ("r" = raw, "v" = validated, "c" = calibrated) |
owner |
owner of the data, one of "KWB", "SEN", "BWB" |
dbg |
whether to show debug messages or not |
Returns the names of available parameters
Plots availability of raw and validated data for different monitoring points
and parameters. For each monitoring point a pdf file
"hsDataAvailability_<MP>" where <MP> is the acronym of the monitoring point
is created in the directory .
hsPlotAllDataAvailabilities(moniPoints, parNames, dates, pdfDir)hsPlotAllDataAvailabilities(moniPoints, parNames, dates, pdfDir)
moniPoints |
vector containing names of monitoring points, e.g. c("TEG", "MUE") |
parNames |
vector containing names of parameters, e.g. c("AFS", "CSB", "CSBf") |
dates |
vector containing a list of Date objects |
pdfDir |
path to output directory to which created pdf-files shall be written. |
2012-04-17;HSB;example removed
## Not run: # Generate pdf files containing data availability plots for parameters # "AFS", "CSB", "CSBf", measured at monitoring points "MUE" (Muehlendamm), # "TEG" (Tegeler Weg), "STA" (Stallstr.) within two different # time intervals: 2010-01-01 to 2010-07-01 and 2011-01-01 to 2011-07-01. hsPlotAllDataAvailabilities( c("MUE", "TEG", "STA"), c("AFS", "CSB", "CSBf"), as.Date(c("2010-01-01", "2010-07-01", "2011-01-01", "2011-07-01")), tempdir() ) # Show data availability plots for Muehlendamm in pdf viewer pdfFile <- file.path(tempdir(), "hsDataAvailability_MUE.pdf") system(paste(options("pdfviewer"), pdfFile)) ## End(Not run)## Not run: # Generate pdf files containing data availability plots for parameters # "AFS", "CSB", "CSBf", measured at monitoring points "MUE" (Muehlendamm), # "TEG" (Tegeler Weg), "STA" (Stallstr.) within two different # time intervals: 2010-01-01 to 2010-07-01 and 2011-01-01 to 2011-07-01. hsPlotAllDataAvailabilities( c("MUE", "TEG", "STA"), c("AFS", "CSB", "CSBf"), as.Date(c("2010-01-01", "2010-07-01", "2011-01-01", "2011-07-01")), tempdir() ) # Show data availability plots for Muehlendamm in pdf viewer pdfFile <- file.path(tempdir(), "hsDataAvailability_MUE.pdf") system(paste(options("pdfviewer"), pdfFile)) ## End(Not run)
Plots availability of raw and validated data as bar plot into one plot
hsPlotMiaCsoAvailabilities(qTypes, moniPoint, parName, dateFirst, dateLast)hsPlotMiaCsoAvailabilities(qTypes, moniPoint, parName, dateFirst, dateLast)
qTypes |
vector of data quality type codes, e.g. c("r", "v", "c"): raw, validated and calibrated data |
moniPoint |
name of monitoring point, e.g. "TEG", "MUE", "STA" |
parName |
name of parameter, e.g. "AFS", "CSB", "CSBf" |
dateFirst |
Date object representing first date to be considered |
dateLast |
Date object representing last date to be considered |
Read MIA-CSO databases
hsReadMiaMdbs(root, search.new = FALSE, dbg = FALSE)hsReadMiaMdbs(root, search.new = FALSE, dbg = FALSE)
root |
root directory to start searching for new databases |
search.new |
if TRUE, root directory is searched recursively for new databases; if FALSE databases are read from R meta database |
dbg |
whether to show debug messages or not |
data frame with columns mdbFile, mdbDesc, mdbDir
Update Metadata Database
hsUpdateMiaMdbs(dfMdbs, root)hsUpdateMiaMdbs(dfMdbs, root)
dfMdbs |
data frame with columns |
root |
path to directory from which to start looking recursively for MS Access database files |
Return number n of added database paths
2011-12-19: moved from hsLibFingerprint.r
hsWavelengthAtIndex(i)hsWavelengthAtIndex(i)
i |
Index (i = 1: 200nm, i = 2: 202.5nm, ..., i = 217: 740nm) |
Wavelength corresponding to index
This function does not work! The intension was to get the full path to an MS Access database file by filtering for certain criteria (owner, kind of data, quality level (raw, valid, calibrated) and time resolution)...
miadir( owner = NA, kind = NA, quaLevel = NA, resol = NA, DS = kwb.misc::hsDirStructure(dbg = dbg), depth = 1, dbg = FALSE )miadir( owner = NA, kind = NA, quaLevel = NA, resol = NA, DS = kwb.misc::hsDirStructure(dbg = dbg), depth = 1, dbg = FALSE )
owner |
data owner |
kind |
kind of data (hydraulic, quality, rain) |
quaLevel |
quality level (raw, validated, calibrated) |
resol |
resolution |
DS |
directory structure |
depth |
depth |
dbg |
whether to show debug messages or not |
Get Path to MS Access Database Used in MIA-CSO
miamdb(kind = NULL, moniPoint = NULL, qua.level = NULL, owner = "KWB")miamdb(kind = NULL, moniPoint = NULL, qua.level = NULL, owner = "KWB")
kind |
kind of data: "q" = water quality, "h" = hydraulic data, "r" = rain |
moniPoint |
name of monitoring point, e.g. "STA", "TEG", "MUE" |
qua.level |
data quality level ("r" = raw, "v" = validated, "c" = calibrated) |
owner |
owner of the data, one of "KWB", "SEN", "BWB" |
This function returns the full path to the Access database containing the specified kind of data
Full Path to MIA CSO Database File
miamdb2(id = 0)miamdb2(id = 0)
id |
optional. Integer number identifying the database file. If not given the user is asked to enter a number on the console. |
full path to database file or empty string "" if an invalid
id was given.
MS Access Databases (Water Quality Data)
qmdb(...)qmdb(...)
... |
arguments passed to |
MS Access Databases (Rain Data)
rmdb(...)rmdb(...)
... |
arguments passed to |