Rain gages#

Note

Engine: OpenSWMM 6 — refactored.

Rain gages drive rainfall onto subcatchments. The shape mirrors Nodes and Links — a collection on solver.gages that yields Gage wrappers.

Reference: openswmm_gages.h.


Quickstart#

from openswmm.engine import Solver, GageDataSource, GageRainType

with Solver("model.inp") as s:
    g = s.gages["RG1"]
    print(g.rain_type, g.data_source)

    # Read / inject runtime rainfall.
    print(g.rainfall)
    g.rainfall = 25.4

    # Bulk numpy read across all gages.
    arr = s.gages.rainfalls

Collection: Gages#

Operation

What it does

len(s.gages)

Gage count.

s.gages[key]

Returns a Gage (key is int or str).

for g in s.gages:

Yields a fresh Gage per index.

s.gages.get_index(id) / get_id(idx)

Id ↔ index lookup.

s.gages.add(id)

Append a gage. Returns the Gage.

s.gages.rename(key, new_id)

Rename in place. Invalidates wrappers.

s.gages.rainfalls

float64 numpy array, shape (n_gages,).

s.gages.ids

object numpy array of string ids.


Wrapper: Gage#

Property

Type

Mode

Meaning

id

str

read-only

index

int

read-only

rain_type

GageRainType

read/write

INTENSITY / VOLUME / CUMULATIVE.

data_source

GageDataSource

read/write

TIMESERIES / FILE.

rainfall

float

read/write

Runtime rainfall.

Methods:

Method

What it does

set_rain_interval(seconds)

Set the interval. Accepts float seconds or a timedelta.

set_timeseries(ts_id)

Configure data_source = TIMESERIES and bind the named time series.

set_file(path, station_id)

Configure data_source = FILE and bind the external file.

The wrapper has no sub-views (gages are simple). Staleness and equality follow the same model as Node / Link.


See also#