Title: | Soil and Chemical Substance Emission and Transport Model |
---|---|
Description: | An enhanced version of the semi-empirical, spatially distributed emission and transport model PhosFate implemented in 'R' and 'C++'. It currently supports suspended solids (SS) and particulate phosphorus (PP). A major feature is the allocation of substance loads entering surface waters to their sources of origin, which is a basic requirement for the identification of critical source areas and in consequence a cost-effective implementation of mitigation measures. References: Hepp et al. (2022) <doi:10.1016/j.jenvman.2022.114514>; Hepp and Zessner (2019) <doi:10.3390/w11102161>; Kovacs (2013) <http://hdl.handle.net/20.500.12708/9468>. |
Authors: | Gerold Hepp [aut, cre] |
Maintainer: | Gerold Hepp <[email protected]> |
License: | AGPL (>= 3) |
Version: | 1.0.4.9000 |
Built: | 2024-11-21 04:35:32 UTC |
Source: | https://github.com/gisler/rphosfate |
Automatically calibrates the model with the help of a combination of golden section search and successive parabolic interpolation.
## S4 method for signature 'RPhosFate' autoCalibrate( x, substance, col, interval, metric, tol = min(interval) * 0.1, parameter = NULL )
## S4 method for signature 'RPhosFate' autoCalibrate( x, substance, col, interval, metric, tol = min(interval) * 0.1, parameter = NULL )
x |
An S4 |
substance |
A character string specifying the substance to calculate. |
col |
A character string specifying the calibration data column with the respective substance river loads. |
interval |
A numeric vector specifying the end-points of the interval to be searched. |
metric |
A character string specifying the metric to optimise. See
|
tol |
A numeric scalar specifying the desired accuracy of the parameter used for optimisation (not the metric). |
parameter |
By default, SS are calibrated utilising the overland
deposition rate and all other substances are calibrated utilising their
respective enrichment ratio. This argument can be used to specify a
dedicated parameter utilised for calibration via a character string:
|
An S4 RPhosFate
river catchment object and side effects in
the form of raster files.
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) # presupposed method calls x <- firstRun(x, "SS") x <- snapGauges(x) x <- autoCalibrate( x, "SS", col = "SS_load", interval = c(10e-4, 20e-4), metric = "NSE" )
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) # presupposed method calls x <- firstRun(x, "SS") x <- snapGauges(x) x <- autoCalibrate( x, "SS", col = "SS_load", interval = c(10e-4, 20e-4), metric = "NSE" )
Automatically calibrates the model with the help of a general-purpose
optimisation function. In contrast to autoCalibrate
, this method always
utilises the overland and channel deposition rate at the same time and never
the respective enrichment ratio for calibration. Beware of local optima and
parameters approximately within the convergence tolerance of interval
end-points.
## S4 method for signature 'RPhosFate' autoCalibrate2( x, substance, col, metric, method = "Nelder-Mead", lower = 0, upper = 0.1, control = list(fnscale = if (metric %in% c("NSE", "mNSE", "KGE")) -1 else 1) )
## S4 method for signature 'RPhosFate' autoCalibrate2( x, substance, col, metric, method = "Nelder-Mead", lower = 0, upper = 0.1, control = list(fnscale = if (metric %in% c("NSE", "mNSE", "KGE")) -1 else 1) )
x |
An S4 |
substance |
A character string specifying the substance to calculate. |
col |
A character string specifying the calibration data column with the respective substance river loads. |
metric |
A character string specifying the metric to optimise. See
|
method |
A character string specifying the utilised optimisation method.
See |
lower |
A numeric scalar or vector specifying the lower end-point(s) of the interval(s) to be searched. |
upper |
A numeric scalar or vector specifying the upper end-point(s) of the interval(s) to be searched. |
control |
A |
An S4 RPhosFate
river catchment object and side effects in
the form of raster files.
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) # presupposed method calls x <- firstRun(x, "SS") x <- snapGauges(x) x <- autoCalibrate2( x, "SS", col = "SS_load", metric = "NSE", method = "L-BFGS-B", lower = c(10e-4, 0), upper = c(20e-4, 20e-4), control = list(fnscale = -1, parscale = c(1e-3, 1e-3), factr = 1e12) )
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) # presupposed method calls x <- firstRun(x, "SS") x <- snapGauges(x) x <- autoCalibrate2( x, "SS", col = "SS_load", metric = "NSE", method = "L-BFGS-B", lower = c(10e-4, 0), upper = c(20e-4, 20e-4), control = list(fnscale = -1, parscale = c(1e-3, 1e-3), factr = 1e12) )
Assesses the model's calibration quality with the help of the pairwise complete modelled as well as observed loads and the following metrics:
NSE: Nash-Sutcliffe Efficiency
mNSE: Modified Nash-Sutcliffe Efficiency (j = 1
)
KGE: Modified Kling-Gupta Efficiency
RMSE: Root Mean Square Error
PBIAS: Percent Bias
RSR: Ratio of the RMSE to the standard deviation of the observations
RCV: Ratio of the coefficients of variation
GMRAE: Geometric Mean Relative Absolute Error
MdRAE: Median Relative Absolute Error
In addition, a scatter plot with the observed river loads on the x- and the modelled river loads on the y-axis is displayed and provides a visual impression of the model performance. Other elements of this plot are an identity line (solid) and plus/minus 30% deviation lines (dashed).
## S4 method for signature 'RPhosFate' calibrationQuality(x, substance, col)
## S4 method for signature 'RPhosFate' calibrationQuality(x, substance, col)
x |
An S4 |
substance |
A character string specifying the substance to calculate. |
col |
A character string specifying the calibration data column with the respective substance river loads. |
A named numeric vector containing the assessed metrics along with the in-channel retention ratio (one minus sum of xxt at catchment outlet(s) divided by sum of xxt_inp).
Nash, J.E., Sutcliffe, J.V., 1970. River flow forecasting through conceptual models part I – a discussion of principles. Journal of Hydrology 10, 282–290. https://doi.org/10.1016/0022-1694(70)90255-6
Legates, D.R., McCabe Jr., G.J., 1999. Evaluating the use of “goodness-of-fit” measures in hydrologic and hydroclimatic model validation. Water Resources Research 35, 233–241. https://doi.org/10.1029/1998WR900018
Kling, H., Fuchs, M., Paulin, M., 2012. Runoff conditions in the upper Danube basin under an ensemble of climate change scenarios. Journal of Hydrology 424–425, 264–277. https://doi.org/10.1016/j.jhydrol.2012.01.011
Moriasi, D.N., Arnold, J.G., Van Liew, M.W., Bingner, R.L., Harmel, R.D., Veith, T.L., 2007. Model evaluation guidelines for systematic quantification of accuracy in watershed simulations. Transactions of the ASABE 50, 885–900.
snapGauges
, autoCalibrate
, autoCalibrate2
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) # presupposed method calls x <- firstRun(x, "SS") x <- snapGauges(x) calibrationQuality(x, "SS", "SS_load")
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) # presupposed method calls x <- firstRun(x, "SS") x <- snapGauges(x) calibrationQuality(x, "SS", "SS_load")
Copies a demonstration project to an existing or a temporary directory.
The demonstration project data are a derivative of the
Geoland.at (digital elevation model),
AMA (field data),
BMLRT (channel data) and
GIP.at (road data)
data sets, used and licensed under (CC BY 4.0) by Gerold Hepp.
While the data represent a real catchment (HOAL), some of them are fictitious, but plausible. These are, among others, R- and C-factors, soil and related data, existence of subsurface drainage at road embankments as well as substance river loads.
demoProject(cs_dir = tempdir(TRUE))
demoProject(cs_dir = tempdir(TRUE))
cs_dir |
An optional character string specifying an existing directory. |
A character string containing the demonstration project root directory.
demoProject()
demoProject()
Calculates and writes substance emissions to disk.
## S4 method for signature 'RPhosFate' emission(x, substance = "PP")
## S4 method for signature 'RPhosFate' emission(x, substance = "PP")
x |
An S4 |
substance |
A character string specifying the substance to calculate. |
An S4 RPhosFate
river catchment object and side effects in
the form of raster files.
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) # presupposed method calls x <- erosionPrerequisites(x) x <- erosion(x) x <- emission(x, "PP")
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) # presupposed method calls x <- erosionPrerequisites(x) x <- erosion(x) x <- emission(x, "PP")
Calculates and writes (R)USLE erosion to disk.
## S4 method for signature 'RPhosFate' erosion(x)
## S4 method for signature 'RPhosFate' erosion(x)
x |
An S4 |
An S4 RPhosFate
river catchment object and side effects in
the form of raster files.
Renard, K.G., Foster, G.R., Weesies, G.A., McCool, D.K., Yoder, D.C., 1997. Predicting soil erosion by water: a guide to conservation planning with the Revised Universal Soil Loss Equation (RUSLE), Agriculture Handbook. U.S. Government Printing Office, Washington, DC.
Wischmeier, W.H., Smith, D.D., 1978. Predicting rainfall erosion losses. A guide to conservation planning, Agriculture Handbook. U.S. Government Printing Office, Washington, DC.
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) # presupposed method call x <- erosionPrerequisites(x) x <- erosion(x)
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) # presupposed method call x <- erosionPrerequisites(x) x <- erosion(x)
Calculates and writes capped slopes, L- and RUSLE S-factors (equations for
summer conditions and slopes 15 ft) to disk. Weighted flow
accumulations less than one are set to one for the calculation of the
L-factors.
## S4 method for signature 'RPhosFate' erosionPrerequisites(x)
## S4 method for signature 'RPhosFate' erosionPrerequisites(x)
x |
An S4 |
An S4 RPhosFate
river catchment object and side effects in
the form of raster files.
Renard, K.G., Foster, G.R., Weesies, G.A., McCool, D.K., Yoder, D.C., 1997. Predicting soil erosion by water: a guide to conservation planning with the Revised Universal Soil Loss Equation (RUSLE), Agriculture Handbook. U.S. Government Printing Office, Washington, DC.
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) x <- erosionPrerequisites(x)
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) x <- erosionPrerequisites(x)
Calls erosionPrerequisites
, erosion
, emission
,
transportPrerequisites
, transportCalcOrder
and transport
in the
mentioned order. While transport
is called for the specified substance
only, emission
is called for all substances whose top soil concentrations
have been provided.
## S4 method for signature 'RPhosFate' firstRun(x, substance = "PP")
## S4 method for signature 'RPhosFate' firstRun(x, substance = "PP")
x |
An S4 |
substance |
A character string specifying the substance to calculate. |
An S4 RPhosFate
river catchment object and side effects in
the form of raster files.
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) x <- firstRun(x, "SS")
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) x <- firstRun(x, "SS")
Obtains a project raster layer for further analysis.
## S4 method for signature 'RPhosFate' getLayer(x, i, j = NULL) ## S4 method for signature 'RPhosFate,ANY,ANY' x[i, j]
## S4 method for signature 'RPhosFate' getLayer(x, i, j = NULL) ## S4 method for signature 'RPhosFate,ANY,ANY' x[i, j]
x |
An S4 |
i |
A character string specifying a layer name. Substance related layers
whose names start with xx are treated differently. They have to be
queried by their name (not filename), for example, |
j |
A character string specifying a substance if applicable. |
A terra::SpatRaster
object.
This directory holds all possible user input raster data (flow obstacles like roads must be considered during generation of the flow accumulation layers and also be cut out from them in order to be properly respected):
acc: Flow accumulations required for transportCalcOrder
.
acc_wtd: Weighted flow accumulations required for everything (can be equal to acc).
CFa: (R)USLE C-factors required for erosion
.
cha: Channel cells required for everything (1
: channel cell, NA
: no
channel cell).
clc: Clay contents of top soils in % required for substance
emission
s.
dem: Digital elevation model in m a.s.l. (optional).
dir: D8 flow directions required for transportPrerequisites
and
substance transport
.
fid: Field IDs (optional).
KFa: (R)USLE K-factors required for erosion
.
lue: Land use classes (optional).
man: Manning's roughness coefficients required for substance
transport
.
xxc: Substance contents of top soils in mg/kg required for substance
emission
s, for example, ppc for PP top soil contents.
rds: Road cells required for transportPrerequisites
(0
: road cell
without subsurface drainage, 1
: road cell with subsurface drainage, NA
:
no road cell).
RFa: (R)USLE R-factors required for erosion
.
slp: Slopes in % required for everything.
wsh: Watershed (optional).
This directory holds intermediate calculations:
inl: Cells representing inlets at roads (storm drains).
LFa: L-factors.
rhy: Hydraulic radii in m.
rip: Cells representing the riparian zones within channel cells.
SFa: RUSLE S-factors.
slp_cap: Capped slopes in %.
This directory holds the model results:
ero: Erosion in t/cell/yr.
xxe: Substance emissions in kg/cell/yr, for example, ppe for PP emissions.
xxr: Substance retentions in t/cell/yr (SS) or kg/cell/yr, for example, ppr for PP retentions.
xxt: Substance transports in t/cell/yr (SS) or kg/cell/yr, for example, ppt for PP transports.
xxt_cld: Substance cell loads in t/cell/yr (SS) or kg/cell/yr, for example, ppt_cld for PP cell loads.
xxt_ctf: Substance cell transfers in t/cell/yr (SS) or kg/cell/yr, for example, ppt_ctf for PP transfers.
xxt_inp: Substance inputs into surface waters in t/cell/yr (SS) or kg/cell/yr, for example, ppt_inp for PP inputs into surface waters.
xxt_out: Substance outlet loads of subsurface drainages in t/cell/yr (SS) or kg/cell/yr, for example, ppt_out for PP outlet loads.
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) # presupposed method call x <- firstRun(x, "SS") getLayer(x, "dir") getLayer(x, "xxt", "SS") getLayer(x, "xxe", "PP")
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) # presupposed method call x <- firstRun(x, "SS") getLayer(x, "dir") getLayer(x, "xxt", "SS") getLayer(x, "xxe", "PP")
Obtains a single model parameter or all model parameters at once.
## S4 method for signature 'RPhosFate' getParameter(x, parameter = NULL)
## S4 method for signature 'RPhosFate' getParameter(x, parameter = NULL)
x |
An S4 |
parameter |
A character string specifying a parameter name or |
Depends on the queried parameter or a list
in case of all
parameters. See model parameter arguments section for further information.
ns_slp_min
: A numeric scalar specifying the minimum bounding slope in %
(defaults to 0.001
).
ns_slp_max
: A numeric scalar specifying the maximum bounding slope in %
(defaults to 999.0
).
ns_rhy_a
: A numeric scalar specifying a network constant depending on the
discharge frequency needed for the calculation of the hydraulic radius, which
in turn is a prerequisite for substance transport (defaults to 0.09
representing a discharge frequency of approximately six years).
ns_rhy_b
: A numeric scalar specifying a geometry scaling exponent
depending on the discharge frequency needed for the calculation of the
hydraulic radius, which in turn is a prerequisite for substance transport
(defaults to 0.50
representing a discharge frequency of approximately six
years).
ns_cha_rto
: A numeric scalar specifying the ratio of the channel to the
cell width determining the widths of the riparian zones required for
substance transport
(defaults to 0.5
).
ns_man_rip
: A numeric scalar specifying Manning's roughness coefficient
of the riparian zones within channel cells required for substance
transport
(defaults to 0.32
).
ns_man_cha
: A numeric scalar specifying Manning's roughness coefficient
of the channel within channel cells required for substance transport
(defaults to 0.04
).
ns_dep_ovl
: A numeric scalar specifying the overland deposition rate per
second required for substance transport
(calibration parameter; no
default).
ns_dep_cha
: A numeric scalar specifying the channel deposition rate per
second required for substance transport
(calibration parameter; no
default).
nv_tfc_inl
: A named numeric vector specifying the inlet transfer
coefficients required for substance transport
, for example, c(SS = 0.6, PP = 0.6)
(no default).
nv_enr_rto
A named numeric vector specifying the substance enrichment
ratios required for substance except SS transport
, for example, c(PP = 2.0)
(calibration parameter; no default).
iv_fDo
: An integer vector specifying the outflow direction vector
required for substance transport
(defaults to ArcGIS codes).
nm_olc
: A two column numeric matrix
specifying one or more catchment
outlet coordinates required for the in-channel retention ratio of
calibrationQuality
(no default).
df_cdt
: A data.frame
with calibration data, which must have at least
the following three columns and one or more columns with substance river
loads in t/yr (no default):
ID: ID(s) of the gauge(s)
x: x-coordinate(s) of the gauge(s)
y: y-coordinate(s) of the gauge(s)
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) getParameter(x) getParameter(x, "ns_dep_ovl")
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) getParameter(x) getParameter(x, "ns_dep_ovl")
Converts all ERDAS IMAGINE raster files in a directory and its subdirectories into GeoTIFF raster files.
img2tif(cs_dir, cs_crs = NULL)
img2tif(cs_dir, cs_crs = NULL)
cs_dir |
A character string specifying an existing directory. |
cs_crs |
An optional character string used to set the coordinate
reference system of all output raster files. See |
A character vector containing the paths to the processed ERDAS IMAGINE raster files.
Initialises a project from scratch or loads the state of an existing one utilising GeoTIFF (*.tif) raster files from, by convention, the following three project root subdirectories:
Input
Intermediate
Result
See subdirectory sections for further information.
catchment
is an alias for RPhosFate
.
RPhosFate(...) catchment(...)
RPhosFate(...) catchment(...)
... |
Arguments used to initialise the project. See argument sections for further information. |
An S4 RPhosFate
river catchment object.
This directory holds all possible user input raster data (flow obstacles like roads must be considered during generation of the flow accumulation layers and also be cut out from them in order to be properly respected):
acc: Flow accumulations required for transportCalcOrder
.
acc_wtd: Weighted flow accumulations required for everything (can be equal to acc).
CFa: (R)USLE C-factors required for erosion
.
cha: Channel cells required for everything (1
: channel cell, NA
: no
channel cell).
clc: Clay contents of top soils in % required for substance
emission
s.
dem: Digital elevation model in m a.s.l. (optional).
dir: D8 flow directions required for transportPrerequisites
and
substance transport
.
fid: Field IDs (optional).
KFa: (R)USLE K-factors required for erosion
.
lue: Land use classes (optional).
man: Manning's roughness coefficients required for substance
transport
.
xxc: Substance contents of top soils in mg/kg required for substance
emission
s, for example, ppc for PP top soil contents.
rds: Road cells required for transportPrerequisites
(0
: road cell
without subsurface drainage, 1
: road cell with subsurface drainage, NA
:
no road cell).
RFa: (R)USLE R-factors required for erosion
.
slp: Slopes in % required for everything.
wsh: Watershed (optional).
This directory holds intermediate calculations:
inl: Cells representing inlets at roads (storm drains).
LFa: L-factors.
rhy: Hydraulic radii in m.
rip: Cells representing the riparian zones within channel cells.
SFa: RUSLE S-factors.
slp_cap: Capped slopes in %.
This directory holds the model results:
ero: Erosion in t/cell/yr.
xxe: Substance emissions in kg/cell/yr, for example, ppe for PP emissions.
xxr: Substance retentions in t/cell/yr (SS) or kg/cell/yr, for example, ppr for PP retentions.
xxt: Substance transports in t/cell/yr (SS) or kg/cell/yr, for example, ppt for PP transports.
xxt_cld: Substance cell loads in t/cell/yr (SS) or kg/cell/yr, for example, ppt_cld for PP cell loads.
xxt_ctf: Substance cell transfers in t/cell/yr (SS) or kg/cell/yr, for example, ppt_ctf for PP transfers.
xxt_inp: Substance inputs into surface waters in t/cell/yr (SS) or kg/cell/yr, for example, ppt_inp for PP inputs into surface waters.
xxt_out: Substance outlet loads of subsurface drainages in t/cell/yr (SS) or kg/cell/yr, for example, ppt_out for PP outlet loads.
cv_dir
: A character vector specifying the project root (first position)
and optionally the Monte Carlo input data directory (second position).
ls_ini
: A logical scalar specifying if the state of an existing project
shall be loaded from disk (defaults to FALSE
). Parameters or substance
parameter values specified via the ...
argument take precedence over loaded
ones.
is_ths
: An integer scalar holding the number of threads to use for
processing (defaults to 1).
is_MCi
: An integer scalar specifying the current Monte Carlo iteration if
applicable (defaults to integer()
, which means Monte Carlo simulation mode
is disabled).
cv_MCl
: A character vector specifying the names of the layers, which
shall be written to disk with the associated Monte Carlo iteration in their
filenames upon calling the appropriate methods (defaults to "xxt"
; no
effect in case Monte Carlo simulation mode is disabled).
ns_slp_min
: A numeric scalar specifying the minimum bounding slope in %
(defaults to 0.001
).
ns_slp_max
: A numeric scalar specifying the maximum bounding slope in %
(defaults to 999.0
).
ns_rhy_a
: A numeric scalar specifying a network constant depending on the
discharge frequency needed for the calculation of the hydraulic radius, which
in turn is a prerequisite for substance transport (defaults to 0.09
representing a discharge frequency of approximately six years).
ns_rhy_b
: A numeric scalar specifying a geometry scaling exponent
depending on the discharge frequency needed for the calculation of the
hydraulic radius, which in turn is a prerequisite for substance transport
(defaults to 0.50
representing a discharge frequency of approximately six
years).
ns_cha_rto
: A numeric scalar specifying the ratio of the channel to the
cell width determining the widths of the riparian zones required for
substance transport
(defaults to 0.5
).
ns_man_rip
: A numeric scalar specifying Manning's roughness coefficient
of the riparian zones within channel cells required for substance
transport
(defaults to 0.32
).
ns_man_cha
: A numeric scalar specifying Manning's roughness coefficient
of the channel within channel cells required for substance transport
(defaults to 0.04
).
ns_dep_ovl
: A numeric scalar specifying the overland deposition rate per
second required for substance transport
(calibration parameter; no
default).
ns_dep_cha
: A numeric scalar specifying the channel deposition rate per
second required for substance transport
(calibration parameter; no
default).
nv_tfc_inl
: A named numeric vector specifying the inlet transfer
coefficients required for substance transport
, for example, c(SS = 0.6, PP = 0.6)
(no default).
nv_enr_rto
A named numeric vector specifying the substance enrichment
ratios required for substance except SS transport
, for example, c(PP = 2.0)
(calibration parameter; no default).
iv_fDo
: An integer vector specifying the outflow direction vector
required for substance transport
(defaults to ArcGIS codes).
nm_olc
: A two column numeric matrix
specifying one or more catchment
outlet coordinates required for the in-channel retention ratio of
calibrationQuality
(no default).
df_cdt
: A data.frame
with calibration data, which must have at least
the following three columns and one or more columns with substance river
loads in t/yr (no default):
ID: ID(s) of the gauge(s)
x: x-coordinate(s) of the gauge(s)
y: y-coordinate(s) of the gauge(s)
This mode can make use of repeated random samples, i.e. raster data, of distributions of about all input data. The filenames of the Monte Carlo input raster data must contain the specified iteration, for example, CFa12.tif for the twelfth iteration of the C-factors input data, and can reside in a separate directory. In case no Monte Carlo raster file is found for a certain layer in the designated directory, the respective project root subdirectory is searched for one and finally the “normal” project input raster data is utilised.
# temporary demonstration project copy cv_dir <- demoProject() # initialise project from scratch x <- RPhosFate( cv_dir = cv_dir, ns_dep_ovl = 25e-4, ns_dep_cha = 0.0, nv_tfc_inl = c(SS = 0.6, PP = 0.6), nv_enr_rto = c(PP = 2.0), nm_olc = matrix(c(4704255, 2795195), ncol = 2L), df_cdt = read.table( file.path(cv_dir, "cdt.txt"), header = TRUE, stringsAsFactors = FALSE ) ) # load state of existing project in Monte Carlo simulation mode x <- RPhosFate( cv_dir = c( cv_dir, system.file("tinytest", "testProject", package = "RPhosFate") ), ls_ini = TRUE, is_MCi = 1L, cv_MCl = c("xxt", "xxt_cld") )
# temporary demonstration project copy cv_dir <- demoProject() # initialise project from scratch x <- RPhosFate( cv_dir = cv_dir, ns_dep_ovl = 25e-4, ns_dep_cha = 0.0, nv_tfc_inl = c(SS = 0.6, PP = 0.6), nv_enr_rto = c(PP = 2.0), nm_olc = matrix(c(4704255, 2795195), ncol = 2L), df_cdt = read.table( file.path(cv_dir, "cdt.txt"), header = TRUE, stringsAsFactors = FALSE ) ) # load state of existing project in Monte Carlo simulation mode x <- RPhosFate( cv_dir = c( cv_dir, system.file("tinytest", "testProject", package = "RPhosFate") ), ls_ini = TRUE, is_MCi = 1L, cv_MCl = c("xxt", "xxt_cld") )
An S4 object representing a river catchment.
cv_dir
A character vector holding the project root (first position) and optionally the Monte Carlo input data directory (second position).
ls_ini
A logical scalar specifying if the state of an existing project was loaded from disk.
is_ths
An integer scalar holding the number of threads to use for processing, where applicable.
is_MCi
An integer scalar holding the current Monte Carlo iteration if applicable.
cv_MCl
A character vector holding the names of the layers, which shall be written to disk with the associated Monte Carlo iteration in their filenames upon calling the appropriate methods.
parameters
An S4 object holding the model parameters.
topo
An S4 object holding the raster layers related to topography in the broader sense.
erosion
An S4 object holding the raster layers related to erosion.
transport
An S4 object holding raster layers required for modelling transport.
substances
An S4 object holding the substance raster layer containers.
helpers
An S4 object holding helper data.
Saves parameters (parameters.yaml) and transport calculation order (order.rds) to disk.
## S4 method for signature 'RPhosFate' saveState(x)
## S4 method for signature 'RPhosFate' saveState(x)
x |
An S4 |
NULL
invisibly and side effects in the form of files.
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) saveState(x)
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) saveState(x)
Sets one or more model parameters or substance parameter values.
## S4 method for signature 'RPhosFate' setParameter(x, ...)
## S4 method for signature 'RPhosFate' setParameter(x, ...)
x |
An S4 |
... |
Names and values of the parameters to set. See model parameter arguments section for further information. |
An S4 RPhosFate
river catchment object.
ns_slp_min
: A numeric scalar specifying the minimum bounding slope in %
(defaults to 0.001
).
ns_slp_max
: A numeric scalar specifying the maximum bounding slope in %
(defaults to 999.0
).
ns_rhy_a
: A numeric scalar specifying a network constant depending on the
discharge frequency needed for the calculation of the hydraulic radius, which
in turn is a prerequisite for substance transport (defaults to 0.09
representing a discharge frequency of approximately six years).
ns_rhy_b
: A numeric scalar specifying a geometry scaling exponent
depending on the discharge frequency needed for the calculation of the
hydraulic radius, which in turn is a prerequisite for substance transport
(defaults to 0.50
representing a discharge frequency of approximately six
years).
ns_cha_rto
: A numeric scalar specifying the ratio of the channel to the
cell width determining the widths of the riparian zones required for
substance transport
(defaults to 0.5
).
ns_man_rip
: A numeric scalar specifying Manning's roughness coefficient
of the riparian zones within channel cells required for substance
transport
(defaults to 0.32
).
ns_man_cha
: A numeric scalar specifying Manning's roughness coefficient
of the channel within channel cells required for substance transport
(defaults to 0.04
).
ns_dep_ovl
: A numeric scalar specifying the overland deposition rate per
second required for substance transport
(calibration parameter; no
default).
ns_dep_cha
: A numeric scalar specifying the channel deposition rate per
second required for substance transport
(calibration parameter; no
default).
nv_tfc_inl
: A named numeric vector specifying the inlet transfer
coefficients required for substance transport
, for example, c(SS = 0.6, PP = 0.6)
(no default).
nv_enr_rto
A named numeric vector specifying the substance enrichment
ratios required for substance except SS transport
, for example, c(PP = 2.0)
(calibration parameter; no default).
iv_fDo
: An integer vector specifying the outflow direction vector
required for substance transport
(defaults to ArcGIS codes).
nm_olc
: A two column numeric matrix
specifying one or more catchment
outlet coordinates required for the in-channel retention ratio of
calibrationQuality
(no default).
df_cdt
: A data.frame
with calibration data, which must have at least
the following three columns and one or more columns with substance river
loads in t/yr (no default):
ID: ID(s) of the gauge(s)
x: x-coordinate(s) of the gauge(s)
y: y-coordinate(s) of the gauge(s)
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) x <- setParameter(x, ns_dep_ovl = 15e-4) x <- setParameter( x, nv_tfc_inl = c(SS = 0.6, PP = 0.6), nv_enr_rto = c(PP = 1.4) )
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) x <- setParameter(x, ns_dep_ovl = 15e-4) x <- setParameter( x, nv_tfc_inl = c(SS = 0.6, PP = 0.6), nv_enr_rto = c(PP = 1.4) )
Snaps the coordinates of the provided calibration gauges to the respective midpoint of the nearest channel cell.
## S4 method for signature 'RPhosFate' snapGauges(x)
## S4 method for signature 'RPhosFate' snapGauges(x)
x |
An S4 |
An S4 RPhosFate
river catchment object.
calibrationQuality
, autoCalibrate
, autoCalibrate2
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) x <- snapGauges(x)
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) x <- snapGauges(x)
Calls transport
for the specified substance and optionally
erosionPrerequisites
, erosion
, emission
,
transportPrerequisites
and/or transportCalcOrder
beforehand.
## S4 method for signature 'RPhosFate' subsequentRun( x, substance = "PP", erosionPrerequisites = FALSE, erosion = FALSE, emission = FALSE, transportPrerequisites = FALSE, transportCalcOrder = FALSE )
## S4 method for signature 'RPhosFate' subsequentRun( x, substance = "PP", erosionPrerequisites = FALSE, erosion = FALSE, emission = FALSE, transportPrerequisites = FALSE, transportCalcOrder = FALSE )
x |
An S4 |
substance |
A character string specifying the substance to calculate. |
erosionPrerequisites |
A logical scalar specifying if
|
erosion |
A logical scalar specifying if |
emission |
A logical scalar specifying if |
transportPrerequisites |
A logical scalar specifying if
|
transportCalcOrder |
A logical scalar specifying if
|
An S4 RPhosFate
river catchment object and side effects in
the form of raster files.
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) # presupposed method call x <- firstRun(x, "SS") x <- subsequentRun(x, "PP")
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) # presupposed method call x <- firstRun(x, "SS") x <- subsequentRun(x, "PP")
Calculates and writes substance retentions, transports and cell loads as well as transfers to disk.
## S4 method for signature 'RPhosFate' transport(x, substance = "PP")
## S4 method for signature 'RPhosFate' transport(x, substance = "PP")
x |
An S4 |
substance |
A character string specifying the substance to calculate. |
An S4 RPhosFate
river catchment object and side effects in
the form of raster files.
Engman, E.T., 1986. Roughness coefficients for routing surface runoff. Journal of Irrigation and Drainage Engineering 112, 39–53.
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) # presupposed method calls x <- erosionPrerequisites(x) x <- erosion(x) x <- emission(x, "PP") x <- transportPrerequisites(x) x <- transportCalcOrder(x) x <- transport(x, "PP")
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) # presupposed method calls x <- erosionPrerequisites(x) x <- erosion(x) x <- emission(x, "PP") x <- transportPrerequisites(x) x <- transportCalcOrder(x) x <- transport(x, "PP")
Determines the cell transport calculation order.
## S4 method for signature 'RPhosFate' transportCalcOrder(x)
## S4 method for signature 'RPhosFate' transportCalcOrder(x)
x |
An S4 |
An S4 RPhosFate
river catchment object.
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) x <- transportCalcOrder(x)
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) x <- transportCalcOrder(x)
Calculates hydraulic radii and determines cells representing inlets as well as riparian zones before writing them to disk.
## S4 method for signature 'RPhosFate' transportPrerequisites(x)
## S4 method for signature 'RPhosFate' transportPrerequisites(x)
x |
An S4 |
An S4 RPhosFate
river catchment object and side effects in
the form of raster files.
Molnár, P., Ramírez, J.A., 1998. Energy dissipation theories and optimal channel characteristics of river networks. Water Resources Research 34, 1809–1818.
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) x <- transportPrerequisites(x)
# temporary demonstration project copy cv_dir <- demoProject() # load temporary demonstration project x <- RPhosFate( cv_dir = cv_dir, ls_ini = TRUE ) x <- transportPrerequisites(x)