Skip to main content

grat

CI PyPI License: MIT

GRAT is a groundwater recharge assessment tool. It models how water available for recharge is allocated, day by day across a span of water years, to canals, basins and farm fields, and reports the resulting groundwater recharge.

Installation

pip install grat

Usage

Load the sites layer from a shapefile, file geodatabase, geopackage, geojson or csv. ArcGIS is not needed; only the attribute table is read.

from grat.loaders.get_sites import load_sites

rows = load_sites("OakValley/oakvalley.shp")
rows = load_sites("project.gdb", layer="sites", where="R_TYPE = 'OFR'")
rows = load_sites("sites.csv", attribute_renamer={"GRATID": "grat_id", "R_TYPE": "recharge_type"})

Run the model and produce reports:

from grat import read_report, run_grat

result = run_grat(sites, wafr, bottlenecks, crop_calendar, precip)

result["zip_path"]  # the results archive
result["reports"]  # the report names that were produced
result["series"]["unused_wafr"]  # the frontend visualisation data

run_grat returns a plain dict. To look at any report it produced, read it back by name as a pandas dataframe:

df = read_report(result["output_folder"], "annual_summary_recharge")
df = read_report(result["output_folder"], "daily_recharge_by_site", year=2001)

Reports are asked for by name, and a run only builds what those reports need:

result = run_grat(..., reports=["annual_summary_recharge", "acres_available_and_used"])

grat.reports.catalog.ALL_REPORTS lists everything available.

To drive the year loop yourself and work with the dataframes directly, without writing any csv files, pass None as the output folder:

from grat.model.engine import process_year
from grat.reports import report_picker

year = process_year(sites, bottlenecks, wafr, crop_calendar, precip)
reports = report_picker(
    ["annual_summary_recharge"], None, 2001, year["sites"], raw_wafr, year["wafr"], year["bottlenecks"]
)
reports["annual_summary_recharge"]

Documentation

  • docs/model.md — grat.model: sites, allocation order, bottlenecks, transfers, and running the year loop yourself.
  • docs/reports.md — grat.reports: the report catalog, what each report contains, and how to read one back.

Development

This project uses uv for dependency management.

uv sync                  # install dependencies (incl. dev group) into .venv
uv run pytest            # run tests
uv run ruff check .      # lint
uv run ruff format .     # format

License

MIT — see LICENSE.

Metadata

Release files for grat 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for grat 0.3.1
File Size Uploaded Provenance Actions
grat-0.3.1.tar.gz 803.5 kB With provenance Details for grat-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for grat 0.3.1
File Interpreter ABI Platform Actions
grat-0.3.1-py3-none-any.whl Python 3 none any Details for grat-0.3.1-py3-none-any.whl

Total release size: 1.6 MB

Release files / grat-0.3.1.tar.gz

Download URL grat-0.3.1.tar.gz
Size 803.5 kB
Tags Source
SHA-256 checksum
How to use checksums
da3029be47195ef8428d434c719b1d78257fad01aab9d242751beb5b76a423bb
BLAKE2b-256 checksum
How to use checksums
641573890343f283c835a7a44cf9fca1dfa52b7642927160cdd6f8a6f4979074
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

Release files / grat-0.3.1-py3-none-any.whl

Download URL grat-0.3.1-py3-none-any.whl
Size 747.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ace8315fb4393e27603c9437e760144e39dc2e0cd3ff798dd4ae4963c4f2ef56
BLAKE2b-256 checksum
How to use checksums
4b963701680b5d89a4c0aed1829b5e39e11c83584f05fb4d2089c246194ecacc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

Security for grat 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for grat-0.3.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page