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

Full docs, including an API reference generated from the docstrings, are published at https://blueraster.github.io/earth-genome-grat/. To preview them locally:

uv sync --group docs
uv run mkdocs serve
  • 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.3

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.3
File Size Uploaded Provenance Actions
grat-0.3.3.tar.gz 826.0 kB With provenance Details for grat-0.3.3.tar.gz

Built distribution (wheel)

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

Total release size: 1.6 MB

Release files / grat-0.3.3.tar.gz

Download URL grat-0.3.3.tar.gz
Size 826.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a84b4539c9c4348157cadb203f646b37bb8ee6cb3dda8d58b7ed9a958df38808
BLAKE2b-256 checksum
How to use checksums
ddb77d0d55dd5ce5325a369ecab15ff51c661ccc05bbfd9e6561a0f0e7538c5f
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 Nov 24, 2026.

Transparency log

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

Download URL grat-0.3.3-py3-none-any.whl
Size 748.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6be22cc9c120031dd03b847b5bb259a6eaabaa853c274071d78f110002a62b5e
BLAKE2b-256 checksum
How to use checksums
7f5390af161d1663bcb03a3bbff61be14fe4d9fdf74dcfa60057be6cad59d8ae
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 Nov 24, 2026.

Transparency log

Security for grat 0.3.3

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.3.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 Nov 24, 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