Skip to content

scheidan/SWMMR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SWMMR - Modify inputs and read SWMM outputs from R

SWMMR is an R package to interface the EPA Storm Water Management Model (SWMM). It can modify SWMM input files, run SWMM, and read SWMM binary output files.

Installation from Github

  1. Install devtools (type in the R command line)
install.packages("devtools")
  1. Install SWMMR (type in the R command line)
library(devtools)
install_github("scheidan/SWMMR")

Usage

This is a minimal example, see the package help for more options.

library(SWMMR)

## Run SWMM
runSWMM(inputfile = "input.inp",
        reportfilename="report.rpt",
        outputfilename="output.out",
        SWMMexe="swmm5.exe")

## Run SWMM with given parameters
## The input file is now used as template:
## All strings "{area}" and "{width}" in the input file are
## replaced by the values given by 'parameter'.
runSWMM(parameter = c(area=10, width=4),
        inputfile = "input_template.inp",
        reportfilename="report.rpt",
        outputfilename="output.out",
        SWMMexe="swmm5.exe")

## Read output file
resfile <- openSWMMOutput("output.out")

resfile                                        # print summary

readSubcatchments(resfile, names=c("S1", "S2", "S3"), variables=c("rainfall", "runoff"))

readNodes(resfile, names="Nod1")               # read all variables for node "Nod1"

readLinks(resfile, names=NULL, variables=NULL) # read all variables for all links

readSystem(resfile)                            # read all system variables

closeSWMMOutput(resfile)                       # close file

Alternatives

An alternative is the swmmr package by Dominik Leutnant. It should be faster (due file reader written in C++), the interface is more low-level compared to SWMMR.

Acknowledgments

This package is based on this work of Peter Steinberg.

About

Modify inputs and read SWMM outputs from R

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages