Skip to main content

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),
)

Release files for ambient-rainfall 0.1.2

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

Source distribution (sdist)

Source distribution for ambient-rainfall 0.1.2
File Size Uploaded
ambient_rainfall-0.1.2.tar.gz 8.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ambient-rainfall 0.1.2
File Interpreter ABI Platform
ambient_rainfall-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 14.7 kB

Release files / ambient_rainfall-0.1.2.tar.gz

Download URL ambient_rainfall-0.1.2.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
30379c2441669302f6a1b3a670799898fd55090883acef5ed4390b359e8f96b0
BLAKE2b-256 checksum
How to use checksums
4b71b6491904a64c2475e691bf61eaeb91e830a60db105cbdb078d385ef019d4
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / ambient_rainfall-0.1.2-py3-none-any.whl

Download URL ambient_rainfall-0.1.2-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
45f523a28c27c8469eb6452e1fc1baba842cc33ec99094144d284ccbea8cd727
BLAKE2b-256 checksum
How to use checksums
e05d230a2f835b84e482b86e1e2ac34ce247185cc625ddde0a60d22b0a270c72
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

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