Hydraulic Engine
| Testing | |
| Package | |
| Meta |
Python toolkit to run SWMM and EPANET simulations, work with their input and result files, and export results to a Giswater PostgreSQL database or a FROST SensorThings endpoint.
Features
- Run SWMM (pyswmm) and EPANET (WNTR) simulations, with optional progress callbacks
- Read and write SWMM / EPANET INP models
- Read SWMM RPT and OUT results, and EPANET BIN results
- Export simulation results to PostgreSQL (Giswater) or FROST
- Connect to PostgreSQL, SQLite, and GeoPackage
Installation
pip install hydraulic-engine
From source:
git clone https://github.com/Giswater/hydraulic-engine.git
cd hydraulic-engine
pip install -e .
For development:
pip install -e ".[dev]"
Quick start
Run a simulation
import hydraulic_engine as he
from hydraulic_engine.utils.enums import RunStatus
# SWMM
swmm = he.swmm.SwmmRunner(inp_path="drainage.inp")
swmm_result = swmm.run()
# EPANET
epanet = he.epanet.EpanetRunner(inp_path="network.inp")
epanet_result = epanet.run()
if swmm_result.status == RunStatus.SUCCESS:
print(f"SWMM finished in {swmm_result.duration_seconds:.2f}s")
Pass progress_callback=fn to either runner to receive progress updates during the run.
Work with model files
from hydraulic_engine.swmm import SwmmInpHandler
from hydraulic_engine.epanet import EpanetInpHandler
swmm_inp = SwmmInpHandler()
swmm_inp.load_file("drainage.inp")
print(swmm_inp.get_summary())
epanet_inp = EpanetInpHandler()
epanet_inp.load_file("network.inp")
print(epanet_inp.get_summary())
Result files use the matching handlers: SwmmRptHandler, SwmmOutHandler, and EpanetBinHandler.
Export results
After a successful run, push results to the database or to FROST:
import hydraulic_engine as he
runner = he.swmm.SwmmRunner(inp_path="drainage.inp")
runner.run()
dao = he.create_pg_connection(
host="localhost",
port=5432,
dbname="hydraulic_db",
user="user",
password="pass",
schema="my_schema",
)
runner.export_result(
to=he.ExportDataSource.DATABASE,
result_id="my_result", # must already exist in rpt_cat_result
client=dao,
)
The same export_result(..., to=he.ExportDataSource.FROST) path works for SensorThings via he.create_frost_connection(...). EPANET uses the same pattern on EpanetRunner.
Exported SWMM time series follow what the model’s [REPORT] section requests (nodes, links, subcatchments).
Database connections
import hydraulic_engine as he
pg = he.create_pg_connection(host="localhost", port=5432, dbname="db", user="u", password="p")
gpkg = he.create_gpkg_connection("project.gpkg")
sqlite = he.create_sqlite_connection("local.db")
he.close_connection()
Package layout
| Module | Role |
|---|---|
hydraulic_engine.swmm |
SWMM runner, INP / RPT / OUT handlers |
hydraulic_engine.epanet |
EPANET runner, INP / BIN handlers |
hydraulic_engine.utils |
DB / API / logging helpers, ExportDataSource, RunStatus |
hydraulic_engine.config |
Package configuration |
Development
pytest tests/
black src/
ruff check src/
License
GNU General Public License v3.0 or later — see LICENSE.
Authors
BGEO — info@bgeo.es
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hydraulic_engine-0.7.0.tar.gz.
File metadata
- Download URL: hydraulic_engine-0.7.0.tar.gz
- Upload date:
- Size: 100.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
182fa6ca9b9c905a73256e2c4f8f7e71558bbe9e58bd64d910c4f3e2688546da
|
|
| MD5 |
1b7b23c3f297756dea282d0093ab32ac
|
|
| BLAKE2b-256 |
d40dbc3555fa3a0d319e252aeb51f7dc590e3759a96d3c925ac75aed9d5fdb40
|
Provenance
The following attestation bundles were made for hydraulic_engine-0.7.0.tar.gz:
Publisher:
publish-to-pypi.yml on bgeo-gis/hydraulic-engine
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hydraulic_engine-0.7.0.tar.gz -
Subject digest:
182fa6ca9b9c905a73256e2c4f8f7e71558bbe9e58bd64d910c4f3e2688546da - Sigstore transparency entry: 2300629652
- Sigstore integration time:
-
Permalink:
bgeo-gis/hydraulic-engine@5ab083887dcd22abb4512a3cae1d924778be1ce4 -
Branch / Tag:
refs/tags/v0.7.0 - Owner: https://github.com/bgeo-gis
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@5ab083887dcd22abb4512a3cae1d924778be1ce4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file hydraulic_engine-0.7.0-py3-none-any.whl.
File metadata
- Download URL: hydraulic_engine-0.7.0-py3-none-any.whl
- Upload date:
- Size: 102.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97bc725d0a0de65dc8124ec055ab98a14f10ea6db18af7a5e6f4e17929cfb889
|
|
| MD5 |
88a1faebf4e2a5eddaab3ea5666d62ea
|
|
| BLAKE2b-256 |
c689f2a38bef2479ced71aa9e2434e8d89faaa526a9318ff31c32d7228498c0b
|
Provenance
The following attestation bundles were made for hydraulic_engine-0.7.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on bgeo-gis/hydraulic-engine
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hydraulic_engine-0.7.0-py3-none-any.whl -
Subject digest:
97bc725d0a0de65dc8124ec055ab98a14f10ea6db18af7a5e6f4e17929cfb889 - Sigstore transparency entry: 2300629698
- Sigstore integration time:
-
Permalink:
bgeo-gis/hydraulic-engine@5ab083887dcd22abb4512a3cae1d924778be1ce4 -
Branch / Tag:
refs/tags/v0.7.0 - Owner: https://github.com/bgeo-gis
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@5ab083887dcd22abb4512a3cae1d924778be1ce4 -
Trigger Event:
push
-
Statement type: