Command Line Interface¶
The get-weather command provides a CLI for common operations.
Setup¶
Download station data and build the database:
get-weather setup
Options:
--force: Rebuild even if database exists--no-ghcn: Skip GHCN stations--no-usaf: Skip USAF stations--no-zipcodes: Skip ZIP codes--no-index: Skip building closest stations index
Get Weather¶
Get weather for a single location and date — a ZIP code or “lat,lon” coordinates:
get-weather get 10001 2024-01-15
get-weather get "40.75,-73.99" 2024-01-15
get-weather get 10001 2024-01-15 --units imperial
get-weather get 10001 2024-01-15 --elements TMAX,PRCP
Output shows temperature, precipitation, and station info in a table; values are in the chosen unit system (metric by default).
With --online, the query goes straight to the NOAA CDO API — no
setup needed, but NCDC_TOKEN must be set
(free token: https://www.ncdc.noaa.gov/cdo-web/token):
get-weather get 10001 2024-01-15 --online
Process CSV¶
Add weather data to a CSV file:
get-weather process input.csv output.csv
Options:
--zip-column: Column name for ZIP codes (default: “zip”)--lat-column/--lon-column: Coordinate columns (take precedence over the ZIP column when both are present)--units: metric (default) or imperial output values--date-column: Column with date in YYYY-MM-DD format--year-column: Column for year (default: “year”)--month-column: Column for month (default: “month”)--day-column: Column for day (default: “day”)
A row that cannot be resolved gets its reason in the weather_error
output column; the job continues, and output is written incrementally.
Example with date column:
get-weather process data.csv output.csv --zip-column zipcode --date-column event_date
Info¶
Show database statistics:
get-weather info
Cache¶
Inspect or reclaim disk used by cached weather data:
get-weather cache info
get-weather cache clear --ghcn # yearly GHCN databases
get-weather cache clear --all --yes
Global Options¶
These options work with all commands:
-d, --database PATH: Use custom database path-v, --verbose: Enable verbose output--version: Show version--help: Show help