US-EPA-SWMM python interface
Project description
© Institute of Urban Water Management and Landscape Water Engineering, Graz University of Technology and Markus Pichler
This is an API for reading, manipulating and running SWMM-Projects
With this package you can read INP-files, manipulate them and write new ones. You can run swmm within the python api. And you can read the OUT-file as a pandas DataFrame for further analysis.
This package is based on the command line SWMM syntax. (see Appendix D in the SWMM User Manual 5.1)
Install the package:
pip install swmm-api
Read, manipulate and write the INP-File
Read the INP-File
from swmm_api.input_file.section_labels import TIMESERIES
from swmm_api import read_inp_file
inp = read_inp_file('inputfile.inp', convert_sections=[TIMESERIES]) # type: swmm_api.SwmmInput
# convert_sections limits the convertions during the reading of the file to the following section
# remove "convert_sections" to convert all sections
# converting sections helps manipulating the inp file
# unconverted sections will be loaded as the raw string
sec_timeseries = inp[TIMESERIES] # type: swmm_api.input_file.helpers.InpSection
ts = inp[TIMESERIES]['regenseries'].frame # type: pandas.Series
Manipulate the INP-File
from swmm_api import read_inp_file, SwmmInput
from swmm_api.input_file.section_labels import JUNCTIONS
inp = read_inp_file('inputfile.inp') # type: swmm_api.SwmmInput
# or
inp = SwmmInput.read_file('inputfile.inp')
inp[JUNCTIONS]['J01'].Elevation = 210
Write the manipulated INP-File
inp.write_file('new_inputfile.inp')
see examples/inp_file_reader.ipynb
see examples/inp_file_structure.ipynb
see examples/inp_file_macros.ipynb
Run SWMM
from swmm_api import swmm5_run
swmm5_run('new_inputfile.inp')
Read the OUT-File
from swmm_api import read_out_file
out = read_out_file('new_inputfile.out') # type: swmm_api.SwmmOut
df = out.to_frame() # type: pandas.DataFrame
see examples/out_file_reader.ipynb
Read the RPT-File
from swmm_api import read_rpt_file
rpt = read_rpt_file('new_inputfile.rpt') # type: swmm_api.SwmmReport
node_flooding_summary = rpt.node_flooding_summary # type: pandas.DataFrame
see examples/rpt_file_reader.ipynb
MORE INFORMATIONS COMMING SOON
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for swmm_api-0.2.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9279083c24576a6ce2e62b83ce7db7ec8cf182bab65bde3d1b82a77de6c9d86 |
|
MD5 | c1e1e36ca41680fee98169a580dc2de7 |
|
BLAKE2b-256 | efe53b55a3358f93e0754b41ec3c4d530a33b8d505f6d48664a096a1a21a8f5a |