https://github.com/adametherzlab/rain-gauge
Rain gauge logger — totals, rolling averages, drought detection
https://github.com/adametherzlab/rain-gauge
bun gauge precipitation rain typescript weather
Last synced: 9 days ago
JSON representation
Rain gauge logger — totals, rolling averages, drought detection
- Host: GitHub
- URL: https://github.com/adametherzlab/rain-gauge
- Owner: AdametherzLab
- License: mit
- Created: 2026-03-06T01:09:49.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2026-03-08T04:13:42.000Z (about 1 month ago)
- Last Synced: 2026-03-08T09:41:30.359Z (about 1 month ago)
- Topics: bun, gauge, precipitation, rain, typescript, weather
- Language: TypeScript
- Size: 14.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
[](https://github.com/AdametherzLab/rain-gauge/actions) [](https://www.typescriptlang.org/) [](LICENSE)
# rain-gauge
Type-safe rainfall measurement logger with drought detection, temporal analytics, and optional persistence.
## Features
- **Branded types** — `Millimeters` and `Days` prevent unit mix-ups at compile time
- **Drought detection** — Configurable severity thresholds (mild/moderate/severe)
- **Temporal analytics** — Daily, weekly, or monthly totals with rolling averages
- **Intensity classification** — Light/moderate/heavy/violent per WMO guidelines
- **Persistence** — Save/load data to JSON files or SQLite databases
- **CLI included** — Log and report from the command line without writing code
- **Zero required dependencies** — Pure TypeScript core, optional `better-sqlite3` for DB storage
## Installation
bash
npm install @adametherzlab/rain-gauge
## Usage
### Library API
import { RainGaugeLogger, FileStore, type Millimeters, type Days } from '@adametherzlab/rain-gauge';
const logger = new RainGaugeLogger({
store: new FileStore('./rainfall.json')
});
// Record rainfall
logger.record({
timestamp: new Date(),
amount: 15.5 as Millimeters
});
// Get monthly totals
const totals = logger.getTotals(
{ startDate: new Date('2024-01-01'), endDate: new Date() },
'monthly'
);
// Check for drought
const drought = logger.detectDrought(
{ startDate: new Date('2024-01-01'), endDate: new Date() },
7 as Days
);
### CLI Usage
Rain Gauge includes a command-line interface for quick manual entry and reports.
bash
# Log rainfall (amount in mm)
npx rain-gauge log 25.4 --date 2024-03-15
# View daily/weekly/monthly report
npx rain-gauge report --period monthly
# Check drought status
npx rain-gauge drought --threshold 5
# Use SQLite storage
npx rain-gauge log 10.5 --store ./rain.db
#### CLI Commands
**log ** - Record rainfall amount
- `-d, --date ` - Date of measurement (default: now)
- `-s, --store ` - Data file (.json or .db)
**report** - Show rainfall totals
- `-p, --period ` - Aggregation period (default: daily)
- `-f, --format ` - Output format (default: table)
**drought** - Check drought conditions
- `-t, --threshold ` - Dry days threshold (default: 3)
- `-f, --format ` - Output format
**clear** - Remove all data
- `-s, --store ` - Target data file
#### CLI Examples
bash
# Log today's rainfall
rain-gauge log 25.4
# View monthly totals for last 30 days
rain-gauge report --period monthly --format json
# Check for drought (5+ dry days)
rain-gauge drought --threshold 5
# Clear all data
rain-gauge clear --store ./rain.json
## License
MIT