Skip to main content

gagely

gagely provides Python utilities for retrieving US weather, streamflow, rainfall, and related gage data from services such as Contrail and USGS, with helpers for writing time-series data to HEC-DSS through pydsstools.

The Python import package is named gagely.

Installation

Install from a local checkout:

python -m pip install .

For development:

python -m pip install -e ".[dev]"

Versioning

Package versions are derived from git tags with setuptools-scm.

Use tags such as:

git tag 0.1.0

Then build/install from that tagged checkout.

Basic Usage

USGS

The USGS package wraps dataretrieval.waterdata and adds DSS-write helpers. Set the personal access token once per process, then go through the daily or continuous submodule:

from gagely.usgs import configure_usgs, daily, continuous

configure_usgs("YOUR_USGS_API_KEY")

Daily values to DSS (period-mean, written as a regular 1DAY series — each row is shifted to the period-end timestamp DSS expects):

daily.flow_to_dss(
    output="flow.dss",
    site_id="08354900",
    sdate="2000-01-01",
)

Continuous (instantaneous) values to DSS (sampling interval is inferred per site from the data, e.g. 15MIN for a typical 15-minute gage; internal time gaps are filled with the no-data sentinel UNDEFINED):

continuous.to_dss(
    output="iv.dss",
    site_id="12362500",
    param="flow",
    sdate="2026-01-01",
)

Returning a DataFrame instead of writing to DSS:

df_daily = daily.get_flow("08354900", sdate="2020-01-01")
df_iv    = continuous.get_flow("12362500", sdate="2026-01-01")

site_id accepts a single id, a list, or a dict mapping label → id (the dict keys become the DSS APART). Bare USGS ids ("08354900") and prefixed ones ("USGS-08354900") are both accepted.

Each submodule exposes the same helper set: get_flow, get_stage, to_dss, flow_to_dss, stage_to_dss, plus the canonical endpoint-name function (get_daily or get_continuous) for arbitrary parameter / statistic combinations. The endpoint-name functions are also re-exported at the package level: from gagely.usgs import get_daily, get_continuous.

Contrail

from gagely.contrail import configure_contrail, fetch_to_dss

configure_contrail(url="https://contrail.example.com", system_key="YOUR_KEY")
fetch_to_dss(
    output="rainfall.dss",
    sensor_class=10,
    sdate="2000-01-01",
    or_site_id=200,
)

Resolve gage names to Contrail or_site_id values before fetching:

from gagely.contrail import get_site_metadata, validate_gages

site_meta = get_site_metadata()
gage_to_or_id = validate_gages(
    ["Station 2", "City Hall"],
    site_meta,
)

Site and sensor metadata can also be queried directly, filtered by site_id or or_site_id (and, for sensors, sensor_class):

from gagely.contrail import get_site_metadata, get_sensor_metadata

# Omit site_id / or_site_id to get metadata for every site/sensor
# accessible under the configured URL/system key.
site_meta = get_site_metadata(or_site_id="200")
sensor_meta = get_sensor_metadata(or_site_id="200", sensor_class=10)

Both return a list of dicts, one per <row> in the XML response (each dict maps child-element tag → text).

Contributing

Bug reports, feature requests, and pull requests are welcome — see CONTRIBUTING.md for guidelines. This project follows the Code of Conduct.

License

gagely is licensed under the MIT License.

Metadata

Release files for gagely 0.1.0

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

Built distribution (wheel)

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

Release files / gagely-0.1.0-py3-none-any.whl

Download URL gagely-0.1.0-py3-none-any.whl
Size 31.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dfdf5c027e32de8327dae157024ef6c15cebd6daf588ca3fb1c01da24739ab29
BLAKE2b-256 checksum
How to use checksums
2f2c1b3ed703a3bc650f060a7d6c05b1037dd5b36810ba4136a860b48eef3404
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file

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