Observations#
Construct a flat Box observation by chaining collectors on an
ObservationBuilder.
from openswmm_gymnasium.observations import ObservationBuilder
obs = (
ObservationBuilder()
.add_node_depths(["J1", "J2"])
.add_node_heads(["J1"])
.add_node_inflows(["J1"])
.add_node_overflows(["J1"])
.add_link_flows(["C1"])
.add_link_depths(["C1"])
.add_link_settings(["ORIF"])
.add_subcatch_runoff(["S1"])
.add_rainfall(["RainGage"])
.add_clock() # hour_sin, hour_cos, elapsed_frac
)
obs.space() returns the resulting
Box(low=-inf, high=+inf, shape=(N,), dtype=float32).
Available collectors#
Builder method |
Engine surface |
Notes |
|---|---|---|
|
|
Instantaneous water depth |
|
|
Hydraulic head |
|
|
Total inflow rate |
|
|
Flooding rate |
|
|
Instantaneous flow |
|
|
Instantaneous depth in link |
|
|
Current setting in |
|
|
Subcatchment runoff rate |
|
|
Per-gage rainfall intensity |
|
n/a |
3 features: |
Forecast injection#
For lookahead features, wrap the env with
ForecastObservation:
from openswmm_gymnasium.wrappers import ForecastObservation
import numpy as np
def perfect_rainfall_lookahead(env, info):
elapsed_days = info.get("elapsed_days", 0.0)
# ...look up next H samples of the timeseries...
return np.array([...], dtype=np.float32)
env = ForecastObservation(env, perfect_rainfall_lookahead, horizon=12)