| Title: | Load Model Developed in OGRE Project |
|---|---|
| Description: | This package contains the functions written by Andreas Matzinger that were originally located in the script "OgRe_LoadModel_functions.R". Since this script was copied by some students and then adapted there are many duplicated functions now. I (Hauke) will replace those functions in the copied scripts that did not change at all with "links" to the original functions in this package. |
| Authors: | Andreas Matzinger [aut] (ORCID: <https://orcid.org/0000-0001-5483-4594>), Hauke Sonnenberg [aut, cre] (ORCID: <https://orcid.org/0000-0001-9134-2871>), Michael Rustler [ctb] (ORCID: <https://orcid.org/0000-0003-0647-7726>), OgRe [fnd], Kompetenzzentrum Wasser Berlin gGmbH (KWB) [cph] |
| Maintainer: | Hauke Sonnenberg <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.0.9000 |
| Built: | 2026-05-05 07:11:58 UTC |
| Source: | https://github.com/KWB-R/kwb.ogre.model |
requires list of these substances as data.frame for each site (one column per site). If substance is always < dl at one site, results are set to zero. If substance is sometimes > dl, resluts are set to a factor*dl
adapt_nondetect(x_in, x_nd, factor = 0.5)adapt_nondetect(x_in, x_nd, factor = 0.5)
x_in |
name of input data.frame |
x_nd |
vector with substances < detection (one column per site) |
factor |
multiplier of detection limit if smaller dl (e.g., 0, 0.5 or 1) |
separates pathways (rain runoff, CSO and WWTP)
annual_load_rain(data.dir, error_removal_rate = 0.3)annual_load_rain(data.dir, error_removal_rate = 0.3)
data.dir |
path of model data (annual mean concentrations "annual_mean_conc.csv", rain runoff volumes "Vol_rain.csv", removal at WWTP "substance_info.csv") |
error_removal_rate |
relative error in removal at WWTP |
Function returns list with loads and standard deviations, by entry path (sep, cso, wwtp) and by surface water catchment. Concentration in units "mg/L" and "ug/L" is automatically transformed to loads in "kg/yr". Other (unknown) units are left unchanged, resulting in "unit * m3/yr".
separates pathways (CSO and WWTP)
annual_load_sewage(data.dir, error_removal_rate = 0.3, error_conc = 0.5)annual_load_sewage(data.dir, error_removal_rate = 0.3, error_conc = 0.5)
data.dir |
path of model data (annual mean concentrations "substance_info.csv", WWTP runoff volumes "Vol_sewage.csv", removal at WWTP "substance_info.csv", optional: relative error by substance can be indicated as additional column "error_conc" in "substance_info.csv") |
error_removal_rate |
relative error in removal at WWTP |
error_conc |
constant relative error in concentrations at WWTP outflow (default = 0.5) or "individual" if relative error by substance is included in "substance_info.csv" |
Function returns list with loads and standard deviations, by entry path (cso, wwtp) and by surface water catchment. Concentration in units "mg/L" and "ug/L" is automatically transformed to loads in "kg/yr". Other (unknown) units are left unchanged, resulting in "unit * m3/yr".
Apart from a matrix with mean concentrations for each substance and site (= 0 if always below detection limit), matrices with N, standard error, standard deviation, RMSE, as well as measured min and max are calculated. Result is given as a list, of these matrices. Different methods can be chosen: Method 1: arithmetic mean Method 2: functions and RMSE from file, arithmetic mean for substances without functions
annual_mean_conc(x_in, method, data.dir)annual_mean_conc(x_in, method, data.dir)
x_in |
name of input data.frame |
method |
estimation method: 1 = arithmetic mean; 2 = functions and RMSE from file, arithmetic mean for substances without functions |
data.dir |
file directory where correlation data and rain series for method 2 are located |
Apart from a matrix with mean concentrations for each substance and site (= 0 if always below detection limit), matrices with N, 95 measured min and max are calculated. Result is given as a list, of these matrices.
annual_stats(x_in)annual_stats(x_in)
x_in |
name of input data.frame |
calculate default statistics for a grouped data frame (created with dplyr::group_by)
default_statistics(x)default_statistics(x)
x |
data frame with columns |
requires list of these substances as single vector
detect(x_in, x_nd)detect(x_in, x_nd)
x_in |
name of input data.frame |
x_nd |
vector with substances < detection |
function gives geometric mean
geom_mean(x)geom_mean(x)
x |
vector of numeric values of which to calculate the geometric mean |
Appends also site code (e.g., "NEU") and substance name apart from standard-fields the fields "CensorCode", "QualityControlLevelID", and "UnitsAbbreviation" are included. If one measurements exists twice, only higher QualityControlLevelID is included
get_lab_values(odbc_name)get_lab_values(odbc_name)
odbc_name |
Name of the odbc source |
that changed (lowered) during the monitoring
getNewDetectionLimits()getNewDetectionLimits()
data frame with columns VariableCode, DetectionLimit
removes rows in data.frame with site code = "PNK"
no_Panke(x_in)no_Panke(x_in)
x_in |
name of input data.frame |
Apart from entire dataset x_in (first column), lists are given for each site individually (following columns)
non_detect(x_in)non_detect(x_in)
x_in |
name of input data.frame |
removes rows in data.frame with SampleType ! = "Composite"
only_composite(x_in)only_composite(x_in)
x_in |
name of input data.frame |
when dl was too high (old analytical method). Works by VariableCode
only_new_dl_metals(x_in)only_new_dl_metals(x_in)
x_in |
name of input data.frame |
at least one measurement (can also be below detection limit) per catchment type
only_representative_subst(x_in)only_representative_subst(x_in)
x_in |
name of input data.frame |
keeps only rows in data.frame with site code = "PNK"
Panke(x_in)Panke(x_in)
x_in |
name of input data.frame |
function gives the 25 percent quantile
quant25(x)quant25(x)
x |
vector of numeric values of which to calculate the quantile |
function gives the 75 percent quantile
quant75(x)quant75(x)
x |
vector of numeric values of which to calculate the quantile |
function gives the 95 percent quantile
quant95(x)quant95(x)
x |
vector of numeric values of which to calculate the quantile |
other than "lt" and "nc" (e.g., "???" are removed)
reduce_codes(x_in)reduce_codes(x_in)
x_in |
name of input data.frame |
removes measurements of Variables of a specific group
remove_group(x_in, group)remove_group(x_in, group)
x_in |
name of input data.frame |
group |
Variable group to be removed (string) |