Skip to main content

A numpy-only toolkit for EPA SWMM file and engine I/O.

Project description

SWMMer: lightweight SWMM I/O and engine runner

A numpy-only toolkit for EPA SWMM file and engine I/O.

swmmer builds a SWMM .inp, runs the EPA SWMM engine (bundled inside the wheel, so no external dependencies are needed), and reads the binary .out results directly through the EPA libswmm-output C library via ctypes. numpy is the only required dependency.

The EPA SWMM Example 1 network and its system response, both produced with swmmer:

swmmer network map of EPA SWMM Example 1

system hyetograph and hydrograph for EPA SWMM Example 1

Capabilities

  • Write input files. SWMMInputGenerator, together with typed element defaults (junctions, conduits, subcatchments, storage, and more), assembles a valid .inp.
  • Build design storms. build_nrcs_hyetograph distributes a total depth into an NRCS (SCS) Type II or Type III hyetograph, and write_rain_dat writes the SWMM rain file.
  • Run the engine. run_swmm invokes the bundled runswmm executable (also exposed as a runswmm command line tool). The engine is compiled into the wheel, so there is nothing to install separately.
  • Read results. SWMMResults reads the binary .out and returns NumPy arrays by element name and attribute (NodeAttr, LinkAttr, SubcatchAttr, SystemAttr), with optional to_pandas and to_xarray converters.
  • Plot. swmmer.plot draws the network map and a longitudinal profile with matplotlib, and can color elements by any result (peak flow, flooding, and so on).

Installation

pip install swmmer

The SWMM engine (runswmm and libswmm-output) is compiled from source and bundled inside the wheel, so pip install swmmer is self-contained on Linux, macOS, and Windows.

Optional extras:

pip install "swmmer[plot]"           # matplotlib, for swmmer.plot
pip install "swmmer[pandas,xarray]"  # SWMMResults.to_pandas() / to_xarray()

Usage

Build a design storm and write it as a SWMM rain file (pure and offline):

from swmmer import build_nrcs_hyetograph, write_rain_dat

hyeto = build_nrcs_hyetograph(150.0, storm_type="III", duration="24-hr")
write_rain_dat(hyeto, "rain.dat")

Run a model and read results by element name:

from swmmer import SWMMResults, SystemAttr, run_swmm

rpt, out = run_swmm("model.inp")
with SWMMResults(out) as res:
    t = res.times_hours
    q = res.system_series(SystemAttr.OUTFALL_FLOW)

Plot the network (requires the plot extra):

import swmmer

fig, ax = swmmer.plot.plot_network("model.inp", labels=True)

The example notebook in the documentation walks through the full workflow: run a model, plot the network, draw hydrographs and a profile, then analyze the results.

Contributing

Contributions are welcome. Please see CONTRIBUTING.md for details.

License

BSD 3-Clause License. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swmmer-0.1.1.tar.gz (1.0 MB view details)

Uploaded Source

Built Distributions

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

swmmer-0.1.1-py3-none-win_amd64.whl (1.1 MB view details)

Uploaded Python 3Windows x86-64

swmmer-0.1.1-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (466.5 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

swmmer-0.1.1-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (444.6 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

swmmer-0.1.1-py3-none-macosx_11_0_x86_64.whl (1.2 MB view details)

Uploaded Python 3macOS 11.0+ x86-64

swmmer-0.1.1-py3-none-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file swmmer-0.1.1.tar.gz.

File metadata

  • Download URL: swmmer-0.1.1.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swmmer-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c1ad6fdfdba965ee59a304075ed71544102ed27036357fca022d1b894a819b06
MD5 147377567c0a0adb93bb635d6f85c93b
BLAKE2b-256 e0491db3c9f1dd91e6a22f5169caea124b49ac83e3c1bcc2e1c221806406fd07

See more details on using hashes here.

File details

Details for the file swmmer-0.1.1-py3-none-win_amd64.whl.

File metadata

  • Download URL: swmmer-0.1.1-py3-none-win_amd64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swmmer-0.1.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 7e978f60bb42652b4a9702e227176a40f55ea0de4a6a4dd8f2ca0f4fae6ebe8a
MD5 e17156ae3e149a0a22eb3fde9c42e11c
BLAKE2b-256 e56942074a62ef227e2a9a1460b4bd67dcde2632e3af5117257a2db81a3f0ccf

See more details on using hashes here.

File details

Details for the file swmmer-0.1.1-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

  • Download URL: swmmer-0.1.1-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
  • Upload date:
  • Size: 466.5 kB
  • Tags: Python 3, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swmmer-0.1.1-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ca56e1e0a6fa64074bca63eb3221a5ce6fe4409d497882e4f8cd80f055c30585
MD5 306ed4fc20c7ee37843d3c25b17b5ea2
BLAKE2b-256 d8e1907cefb274c4f6548df0fc2a3174a9d2f637e9036d01dba79baf83a84a79

See more details on using hashes here.

File details

Details for the file swmmer-0.1.1-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

  • Download URL: swmmer-0.1.1-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
  • Upload date:
  • Size: 444.6 kB
  • Tags: Python 3, manylinux: glibc 2.17+ ARM64, manylinux: glibc 2.28+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swmmer-0.1.1-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2fb355a3a201fb8c1c3c86a761a64012e08b23c5690ae84e14aaa602e0d69add
MD5 68ba6315d5cc305de78fd27eefd6929f
BLAKE2b-256 99c4b8ac27de2d3a98278170faf45f5d18c096e1e67602566328867eefef42d8

See more details on using hashes here.

File details

Details for the file swmmer-0.1.1-py3-none-macosx_11_0_x86_64.whl.

File metadata

  • Download URL: swmmer-0.1.1-py3-none-macosx_11_0_x86_64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: Python 3, macOS 11.0+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swmmer-0.1.1-py3-none-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 75570be074baf544f108d3163cfac49d187a66955d99e5da4bc2530d0bb2c671
MD5 5b4a5a0379762dcce492fd7b970aad7f
BLAKE2b-256 1265efabb210e5fe29900cef0c86984be112e4cf4c67eabe1ce41a3a31bcb3e0

See more details on using hashes here.

File details

Details for the file swmmer-0.1.1-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: swmmer-0.1.1-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 3, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swmmer-0.1.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 57fa852547561f6e77e5b667e345bbcf3d8d42ca79e80dc4c025c99648f92dff
MD5 abb5e0e2fc25d8afd1abd7cd98b400d5
BLAKE2b-256 2b5f82ebaabed402bae8ea3541abf386bc94a320930bffeccfd6154642125f29

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