Pywr

Build and run Pywr reservoir water-allocation models from GRanD dam data and VIC inflows.

155|6|Updated Mar 31, 2026
One-click install
npx skills add https://github.com/lzwei196/KISS-Knowledge-Infrastructure-for-Scientific-Simulation --skill pywr-lzwei196
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Pywr
Source: https://github.com/lzwei196/KISS-Knowledge-Infrastructure-for-Scientific-Simulation/tree/main/models/Pywr
Command: npx skills add https://github.com/lzwei196/KISS-Knowledge-Infrastructure-for-Scientific-Simulation --skill pywr-lzwei196

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pywr, numpy, pandas, geopandas, netCDF4, xarray, matplotlib, shapely, scipy, and includes scripts (resource) and references (resource) components.

What problem does it solve? Running the Pywr water resources model requires operational expertise scattered across source code and practice: finding dams, converting inflow units, writing operating rules, assembling valid JSON networks, and recovering from silent failures. This Skill packages that expertise so an AI agent can execute the full reservoir operations pipeline correctly. ## Core Features & Use Cases - Eight-stage pipeline: verify installation, find dams in the GRanD database (7,320 dams), build reservoir properties, convert VIC/observed inflows, generate operating rules and demand nodes, assemble the Pywr JSON model, then run, plot, and inject regulated releases into CaMa-Flood. - Diagnostic recovery: 15 symptom-diagnosis-remedy triplets in diagnostics/triplets.yaml cover GLPK solver failures, unit conversion errors (MCM to m3, mm/day to m3/s), InfeasibleError, and silent zero-inflow runs. - HydroCraft coupling: couples with VIC (inflow), CaMa-Flood (regulated routing), DSSAT (irrigation demand), and DLBreach (dam-break trigger via overtopping checks). - Use Case: Given a basin shapefile and VIC runoff output, autonomously locate dams, build a control-curve-regulated reservoir model with environmental and irrigation demands, run a 10-year daily simulation, and validate release discharge against NSE/PBIAS convention bands. ## Quick Start Run python preflight_check.py in this directory, then ask the agent to find dams in your basin shapefile and assemble and run a Pywr reservoir model using the tools under the tools/ directory.

Frequently Asked Questions about Pywr

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run a Pywr reservoir model from VIC model output?

Convert VIC runoff and baseflow to m3/s inflow with convert_vic_to_inflow.py, generate operating rules and demand nodes, assemble the JSON model with assemble_pywr_model.py, then execute run_pywr.py. The pipeline covers eight stages from dam discovery to plotting.

How do I find dams in a basin for water resources modeling?

Use find_dams_in_basin.py with a basin shapefile and the GRanD_allocated.csv database containing 7,320 dams. It outputs a JSON of dams within the basin, which build_reservoir_properties.py turns into capacity, area-volume, and dead storage parameters.

Why does Pywr raise InfeasibleError during model run?

InfeasibleError means demands exceed inflow plus available storage at some timestep with no slack path. Add a spill output node with high cost, reduce demand max_flow values, or lower min_volume; every storage node must have a spill path.

Why is my Pywr reservoir storage frozen or oscillating unrealistically?

A missing or unwired ControlCurveParameter makes the LP solver fill to max or empty to min with no intermediate regulation. Link a monthly control curve to the storage node cost, with above-curve cost exceeding downstream output benefit.

What unit conversions does Pywr require for GRanD and VIC data?

GRanD capacity in MCM must be multiplied by 1e6 to get m3 for Pywr volumes. VIC runoff in mm/day converts to m3/s inflow by multiplying by cell area in m2 and dividing by 1000 and 86400.

Does Pywr simulate rainfall-runoff or channel hydraulics?

No. Pywr is a network resource-allocation simulator that solves a per-timestep linear program; catchment inflows are exogenous forcing supplied as CSV timeseries. Rainfall-runoff must come from models like VIC, and hydraulic routing from models like CaMa-Flood.