Skip to main content

weather

A deterministic weather generation library for games and simulations. Given a single time input (and optional location/climate parameters), it returns a complete, reproducible weather report. Features

  • Fully deterministic: Same input always yields the same output.
  • Flexible Time: Supports game minutes, real-time, or current UTC.
  • Geographic Context: Optional latitude, longitude, and elevation for fine-tuning.
  • Climate Profiles: Built-in Köppen climate profiles (extensible).
  • Comprehensive Data:
    • Temperature, pressure, humidity, dew point, wind (speed/direction/cardinal).
    • Precipitation probability, cloud cover, instability (CAPE-like).
    • 20+ weather conditions (clear, rain, snow, thunderstorm, blizzard, etc.).
    • Special atmospheric phenomena: aurora, rainbow, sun dog, halo.
    • Moon phase (with year drift) and seasonal events (equinoxes/solstices).
    • Flavor text and ASCII art for every condition.
  • Customizable: All disasters can be enabled/disabled per profile.
  • NEW: Per-trend memory isolation – pass a trend_id to keep smoothing separate for concurrent use.
  • NEW: WeatherArchive – persistent SQLite storage of sparse checkpoints, ensuring smooth weather even when jumping to arbitrary times. Installation Copy weather.py into your project and import: from weather import weather, WeatherData, list_koppen_codes, WeatherArchive

(No external dependencies – only the Python standard library.) Usage Basic – current weather at default location w = weather() print(f"{w.condition} at {w.temperature}°C") print(w.ascii_art) print(w.flavor)

Advanced Time & Location

Specify game minutes

w = weather(game_minutes=123456)

Use real time (UTC)

from datetime import datetime w = weather(real_time=datetime(2025, 6, 1, 12, 0))

Scale time (e.g., 1 real minute = 12 game minutes)

w = weather(real_time=datetime.now(), real_time_scale=12)

Set location (latitude affects aurora; elevation applies lapse rate)

w = weather(latitude=60.0, elevation=200, koppen="Dfd")

Isolate smoothing per trend

w1 = weather(game_minutes=1000, trend_id="siberia") w2 = weather(game_minutes=1000, trend_id="desert") ### separate memory

WeatherArchive – Persistent, Smooth Trends The WeatherArchive class stores weather checkpoints in a local SQLite database. When you request a time, it generates forward from the nearest checkpoint, ensuring smooth transitions without storing every minute. archive = WeatherArchive("my_weather.db")

Add a trend (location + climate)

trend_id = archive.add_trend( name="Siberian Outpost", latitude=60.0, longitude=120.0, elevation=200.0, koppen="Dfd" )

Get weather at game minute 5000

w = archive.get_weather(trend_id, 5000)

Later, get minute 6000 (uses checkpoint at 5000)

w2 = archive.get_weather(trend_id, 6000)

Read‑only mode (no new checkpoints saved)

w3 = archive.get_weather(trend_id, 7000, read_only=True)

Thread Safety: WeatherArchive is thread-safe. Concurrent requests for different trends run in parallel; requests for the same trend are serialized to preserve smoothing logic.

WeatherData Fields

Field Type Description
game_minutes int Internal game minute count
datetime_str str Formatted "Year X, Day Y, HH:MM"
temperature float Air temperature (°C)
feels_like float Apparent temperature (°C)
pressure float Atmospheric pressure (hPa)
humidity float Relative humidity (%)
dew_point float Dew point (°C)
wind_speed float Wind speed (m/s)
wind_direction float Wind direction (degrees)
wind_cardinal str Cardinal direction (N, NNE, etc.)
condition str Weather condition (e.g., "light rain")
cloud_cover int Cloud cover (%)
precipitation_prob float Precipitation probability (%)
instability float CAPE‑like instability (J/kg)
moon_phase str Moon phase name
moon_emoji str Moon phase emoji
season_event str/None Solstice/equinox if within ±2 days
flavor str Descriptive flavor text
ascii_art str ASCII art representing the condition

- Update LOGS -

-Update 0.0.1-

  • Basically added a way to ensure smoothness and do that even if multiple functions sre calling weather history function.
  • Added trend_id parameter to weather() for isolated smoothing memory.
  • Added WeatherArchive class for persistent, checkpoint-based storage.
  • Thread-safe archive with per-trend locks.

-Update 0.0.1dev1-

  • Bro, this is 0.0.1. Why you even looking here?

Metadata

Release files for weatherz 0.0.1

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

Source distribution (sdist)

Source distribution for weatherz 0.0.1
File Size Uploaded Provenance Actions
weatherz-0.0.1.tar.gz 20.5 kB Without provenance Details for weatherz-0.0.1.tar.gz

Built distribution (wheel)

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

Total release size: 39.7 kB

Release files / weatherz-0.0.1.tar.gz

Download URL weatherz-0.0.1.tar.gz
Size 20.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b551b93fca6d878253b61f5325ec5a1322eb9793197bff4aee7c9015a9f011dd
BLAKE2b-256 checksum
How to use checksums
c6c54e2c1d0d793620db6d173ebbedc625eb2da2368f6ce969c0dca3995b4290
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Release files / weatherz-0.0.1-py3-none-any.whl

Download URL weatherz-0.0.1-py3-none-any.whl
Size 19.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1aa506c554fa4df0fdaa2ac4cace601bbb85e7815fd178c13e1f7994863db7e6
BLAKE2b-256 checksum
How to use checksums
cc6adf42f5cf60e29c2951620721d0375fdc5bd19c2be83bd708a6082c7c7b89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Security for weatherz 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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