| Title: | R Package with Functions for Working with EPA`s Storm Water Management Model (SWMM) |
|---|---|
| Description: | R package with functions for working with EPA`s Storm Water Management Model [SWMM](https://www.epa.gov/water-research/storm-water-management-model-swmm). |
| Authors: | Michael Rustler [aut, cre] (ORCID: <https://orcid.org/0000-0003-0647-7726>), KEYS [fnd], Kompetenzzentrum Wasser Berlin gGmbH (KWB) [cph] |
| Maintainer: | Michael Rustler <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.1 |
| Built: | 2026-06-24 15:15:27 UTC |
| Source: | https://github.com/KWB-R/kwb.swmm |
Calculate Rain Events
calculate_rainevent_stats( results_system, col_eventsep = "total_runoff", aggregation_function = "sum", signalThreshold = 0, eventSeparationTime = 6 * 3600, ... )calculate_rainevent_stats( results_system, col_eventsep = "total_runoff", aggregation_function = "sum", signalThreshold = 0, eventSeparationTime = 6 * 3600, ... )
results_system |
data frame as retrieved by |
col_eventsep |
column to be used for event separation (default: "total_runoff") |
aggregation_function |
function to be used for aggregation and passed to getEventStatistics (default: "sum") |
signalThreshold |
passed to getEvents, Value that needs to be exceeded (signalComparisonOperator == "gt") or reached (signalComparisonOperator == "ge") by the rain heights (or intensities) in order to be counted as a "signal". default: 0 |
eventSeparationTime |
eventSeparationTime passed to getEvents (default: 6*3600) |
... |
additional arguments passed to getEvents |
tibble with statistics for all rain events
## Not run: path_out_file <- "path-to-my-swmm-output-file" results_system <- kwb.swmm::get_results(path_out = path_out_file) rainevent_stats <- calculate_rainevent_stats(results_system, aggregation_function = "sum", signalThreshold = 0, eventSeparationTime = 6*3600) ## End(Not run)## Not run: path_out_file <- "path-to-my-swmm-output-file" results_system <- kwb.swmm::get_results(path_out = path_out_file) rainevent_stats <- calculate_rainevent_stats(results_system, aggregation_function = "sum", signalThreshold = 0, eventSeparationTime = 6*3600) ## End(Not run)
downloads SWMM executable from USEPA's GitHub repo of
https://github.com/USEPA/Stormwater-Management-Model/releases
download_swmm_executable(tdir = tempdir(), swmm_version = "5.2.0")download_swmm_executable(tdir = tempdir(), swmm_version = "5.2.0")
tdir |
target directory for unzipping zip files |
swmm_version |
desired SWMM version, one of: "5.2.0", "5.1.15", "5.1.14", "5.1.13" (default: "5.2.0") |
path to download "runswmm.exe"
download_swmm_executable()download_swmm_executable()
Get Path to File in This Package
extdata_file(...)extdata_file(...)
... |
parts of path passed to |
get_lid_para_types
get_lid_para_types()get_lid_para_types()
returns tidy data frame with required parameteration for LIDs based on SWMM documentation
get_lid_para_types()get_lid_para_types()
Helper function: get metadata for selected elements
get_meta(name, path_out)get_meta(name, path_out)
name |
of element to select. one of: c("subcatchments", "nodes", "links", "system") |
path_out |
path to SWMM output file |
tibble with columns "name", "itype", "vindex" and corresponding IDs required for read_out
Get Results
get_results(path_out, type = "system", object_name = NULL, vIndex = NULL)get_results(path_out, type = "system", object_name = NULL, vIndex = NULL)
path_out |
path to SWMM output file |
type |
output type, select from c("subcatchments" "nodes", "links" or "system"), default: "system" |
object_name |
Sets the objects of which time series data is returned. if NULL all objects will be returned (default: NULL) |
vIndex |
indexes of system wide indexes to be imported. By default all indexes will be imported (default: NULL). If only selected vIndex's should be imported have a look at the documentation of read_out |
for "system" a tibble with selected system variables, for all other "type" a list with sublists for each "object_name"
## Not run: path_out_file <- "path-to-my-swmm-output-file" results_subcatchments <- kwb.swmm::get_results(path_out_file, type = "subcatchments") results_links <- kwb.swmm::get_results(path_out_file, type = "links") results_nodes <- kwb.swmm::get_results(path_out_file, type = "nodes") results_system <- kwb.swmm::get_results(path_out_file, type = "system") ## End(Not run)## Not run: path_out_file <- "path-to-my-swmm-output-file" results_subcatchments <- kwb.swmm::get_results(path_out_file, type = "subcatchments") results_links <- kwb.swmm::get_results(path_out_file, type = "links") results_nodes <- kwb.swmm::get_results(path_out_file, type = "nodes") results_system <- kwb.swmm::get_results(path_out_file, type = "system") ## End(Not run)
Helper function: hectar to squaremeter
hectar_to_squaremeter(hectar)hectar_to_squaremeter(hectar)
hectar |
hectar |
area in hectar
squaremeter_to_hectar(100)squaremeter_to_hectar(100)
Helper function: converts l/s into mm/h
lps_to_mmPerHour(values)lps_to_mmPerHour(values)
values |
values in liter per second |
values in mm per hour
lps_to_mmPerHour(1)lps_to_mmPerHour(1)
allows to run SWMM model in model folder, i.e. it is possible
to define paths to climate data in swmm_model.inp with relative paths (if these
are contained in the same folder or a subfolder of the model_dir)
run_swmm(model_dir, model_inp, exe, ...)run_swmm(model_dir, model_inp, exe, ...)
model_dir |
model directory with 'model.inp' |
model_inp |
name of model input fike 'model.inp' |
exe |
path to SWMM executabvle |
... |
additional arguments passed to |
runs SWMM
Helper function: squaremeter to hectar
squaremeter_to_hectar(squaremeter)squaremeter_to_hectar(squaremeter)
squaremeter |
squarmeter |
area in hectar
squaremeter_to_hectar(100)squaremeter_to_hectar(100)