Skip to content

Rain gages

Call use_external_precipitation(rate) to make your application the persistent precipitation source. It selects the API source, marks the gage used, and unlinks any co-gage. Read external_precipitation_rate to check the selected value.

Use rainfall_override to mask the underlying source with a persistent scalar value. Assigning None clears that mask and resumes the source. Assigning zero means dry weather; it does not hand control back.

from swmmrs import Simulation

with Simulation("model.inp", "model.rpt") as simulation:
    gage = simulation.rain_gages["GAGE-1"]

    # Make the host application the persistent precipitation source.
    gage.use_external_precipitation(1.25)
    assert gage.external_precipitation_rate == 1.25

    # Temporarily mask that source, including with an explicitly dry rate.
    gage.rainfall_override = 2.0
    gage.rainfall_override = 0.0
    gage.rainfall_override = None  # Resume the 1.25 external source.

    simulation.start()
    while simulation.step() is not None:
        print(gage.rainfall, gage.snowfall, gage.total_precip)

Typed, generation-bound views over configured SWMM project objects.

All view instances retain the simulation and project generation that created them. They validate that identity before accessing native state, so retained views cannot silently address a subsequently reopened project.

CLASS DESCRIPTION
RainGage

Expose precipitation state and persistent forcing for one configured rain gage.

RainGage


              flowchart TD
              swmmrs.objects.RainGage[RainGage]
              swmmrs.objects._base._LiveView[_LiveView]

                              swmmrs.objects._base._LiveView --> swmmrs.objects.RainGage
                


              click swmmrs.objects.RainGage href "" "swmmrs.objects.RainGage"
              click swmmrs.objects._base._LiveView href "" "swmmrs.objects._base._LiveView"
            

Expose precipitation state and persistent forcing for one configured rain gage.

Notes

Values use the project's rainfall units. total_precip, rainfall, and snowfall report current effective precipitation. external_precipitation_rate selects the API as the persistent source; rainfall_override persistently masks every source until cleared.

METHOD DESCRIPTION
use_external_precipitation

Select persistent API precipitation. Lifecycle: OPEN, RUNNING, ENDED.

ATTRIBUTE DESCRIPTION
external_precipitation_rate

Return the selected external source rate, or None before selection.

TYPE: float | None

rainfall

Return current effective liquid rainfall in project rainfall units.

TYPE: float

rainfall_override

Rainfall override or None. Setter lifecycle: OPEN, RUNNING, ENDED.

TYPE: float | None

snowfall

Return current effective snowfall in project rainfall units.

TYPE: float

total_precip

Return current effective rain plus snow in project rainfall units.

TYPE: float

external_precipitation_rate property

external_precipitation_rate: float | None

Return the selected external source rate, or None before selection.

use_external_precipitation() selects the API as this gage's source, unlinks any co-gage, and persists until replaced or the simulation closes. A rate of 0.0 keeps the API source selected with dry precipitation. A rainfall override takes precedence while present.

rainfall property

rainfall: float

Return current effective liquid rainfall in project rainfall units.

rainfall_override property writable

rainfall_override: float | None

Rainfall override or None. Setter lifecycle: OPEN, RUNNING, ENDED.

Assigning a nonnegative finite rate masks every configured source without changing it; 0.0 forces dry precipitation. Assigning None clears the override and resumes the underlying source. Setting an override unlinks any co-gage, and clearing it does not restore that relationship.

snowfall property

snowfall: float

Return current effective snowfall in project rainfall units.

total_precip property

total_precip: float

Return current effective rain plus snow in project rainfall units.

use_external_precipitation

use_external_precipitation(rate: float) -> None

Select persistent API precipitation. Lifecycle: OPEN, RUNNING, ENDED.