Skip to main content

A wrapper around the Ambient Weather API for pulling historical station data and calculating rainfall totals over a date range.

Project description

ambient-rainfall

A small wrapper around the Ambient Weather API for pulling historical station data and calculating total rainfall over a date range.

Requirements

Installation

Install with uv:

uv sync

or with pip, into a virtual environment:

pip install .

For development (editable install with test/lint tools):

uv sync --group dev
# or: pip install -e ".[dev]"

Create a .env file in the project root with your Ambient Weather credentials:

AMBIENT_API_KEY=your-api-key
AMBIENT_APPLICATION_KEY=your-application-key

Optionally set AMBIENT_RAINFALL_CACHE_DIR to control where the default-device cache is stored (defaults to .cache in the project root).

Optionally set AMBIENT_HOUR to control the hour (0-23) used for the start/end datetime defaults described below (defaults to 0).

Usage

Installing the package exposes a console script:

ambient-rainfall --start 2026-07-22T08:00:00 --end 2026-07-23T08:00:00

--start and --end accept ISO-formatted datetimes (e.g. 2026-07-22 or 2026-07-22T08:00:00). If omitted, --end defaults to today and --start defaults to yesterday, both at the hour set by --hour (or the AMBIENT_HOUR environment variable, or 0 if neither is set). If --start/--end are given but omit a time component (e.g. 2026-07-22), that same hour is filled in; an explicit time in the string (e.g. 2026-07-22T08:00:00) is always kept as-is.

Each run prints the total rainfall for the requested range and writes a CSV (rainfall_<start>_<end>.csv) with the hourly rainfall values used in the calculation.

By default, the script uses the first weather station found on your account (cached for 7 days). Pass a specific station with --device <mac-address>, or the device argument when calling the library functions directly.

Library usage

from datetime import datetime
from ambient_rainfall.core import get_total_rainfall_for_date_range

rainfall = get_total_rainfall_for_date_range(
    start_datetime=datetime(2026, 7, 22, 8),
    end_datetime=datetime(2026, 7, 23, 8),
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ambient_rainfall-0.1.0.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ambient_rainfall-0.1.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file ambient_rainfall-0.1.0.tar.gz.

File metadata

  • Download URL: ambient_rainfall-0.1.0.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for ambient_rainfall-0.1.0.tar.gz
Algorithm Hash digest
SHA256 608a4fd8c5b332591e2d34c1525052a70a00dd40aadd88ce7ff50fdd9157d04a
MD5 2438c1a18f2eb8b9ca83a3d4a9955de5
BLAKE2b-256 53826cec2a290761ef4bec71659d5f45141d45563f64c0128d5e997b653fb3df

See more details on using hashes here.

File details

Details for the file ambient_rainfall-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ambient_rainfall-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for ambient_rainfall-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ff865bbd550cd9fc669bb6b3b6b640e4c00da61eb13d7a1596453a26e298fbd6
MD5 76dce423f41f4d6a2d8af8e53feda3d4
BLAKE2b-256 cf1221168868bbc117385b7e8ddb4d0d7a519a968e473bdc81f5ee0c17aa8fc5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page