Skip to main content

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

PyPI pipeline status License: MIT docs

PyPI - Downloads PyPI - Downloads PyPI - Downloads

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

swmm-api-0.2.0.9.tar.gz (100.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

swmm_api-0.2.0.9-py3-none-any.whl (114.9 kB view details)

Uploaded Python 3

File details

Details for the file swmm-api-0.2.0.9.tar.gz.

File metadata

  • Download URL: swmm-api-0.2.0.9.tar.gz
  • Upload date:
  • Size: 100.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10

File hashes

Hashes for swmm-api-0.2.0.9.tar.gz
Algorithm Hash digest
SHA256 236f17cd9df6f0e0cc5bf6b1ecba957e4d888ddabedb361e0a78bf99e1c8e73a
MD5 8cdc93f7b6259cd45def96309b7a8f34
BLAKE2b-256 fbad68c636a562bfa39d2678e1799ed2eedb8d8ff1ccdf32c8db1dc863ad7c9b

See more details on using hashes here.

File details

Details for the file swmm_api-0.2.0.9-py3-none-any.whl.

File metadata

  • Download URL: swmm_api-0.2.0.9-py3-none-any.whl
  • Upload date:
  • Size: 114.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10

File hashes

Hashes for swmm_api-0.2.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 eb696f9bb863c0b71ec63d3dcdf7be22271342e3328f2f3fb521ac9751a1f804
MD5 0470ac97680f30d2d14fcb1f57a0677a
BLAKE2b-256 5877ca97d4c6086b0bffd93e320b2214443ea9400785c9ed8113537ffd295374

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page