Skip to main content

The Zambretti Algorithm for weather forecasting

Project description

Zambretti Weather Forecasting in Python

This is a Python implementation of the Zambretti Weather Forecaster

The code is heavily based on the Zambretti Algorithm for Weather Forecasting ESP example

Further reading: Short-Range Local Forecasting with a Digital Barograph using an Algorithm based on the Zambretti Forecaster.

Python Package

This repository is available as a package in PyPi: https://pypi.org/project/zambretti-py/

Usage notes

Pressure data must be provided in millibars or hPa (those are equivalent). Elevation must be provided in meters. Temperature must be provided in degrees Celsius.

Minimum 6 readings of atmospheric pressure are required. Best results are when the pressure readings span the last three hours, but the code will run on any timespan.

Technical notes

This project has no dependencies, uses only functions from the Python Standard Library. It should run both in Python and MicroPython.

Example

Example usage with mock values:

import datetime

from zambretti_py import PressureData, WindDirection, Zambretti

now = datetime.datetime.now()
pressure_data = PressureData(
    [
        (now - datetime.timedelta(hours=2, minutes=59), 1050.0),
        (now - datetime.timedelta(hours=2, minutes=49), 1040.0),
        (now - datetime.timedelta(hours=2, minutes=39), 1030.0),
        (now - datetime.timedelta(hours=2, minutes=12), 1020.0),
        (now - datetime.timedelta(hours=1, minutes=19), 1010.0),
        (now - datetime.timedelta(minutes=20), 1000.0),
    ]
)
zambretti = Zambretti()

forecast = zambretti.forecast(
    elevation=90,
    temperature=25,
    pressure_data=pressure_data,
    wind_direction=WindDirection.NORTH,
)
print(forecast)

To calculate for forecast, the Zambretti algorithm requires:

  • elevation above sea level
  • current temperature
  • pressure data from the last three hours, or less.
    • data points older than three hours will be removed
    • the pressure data is expected to be provided as a list of tuples, each tuple consisting of a datetime.datetime object, and the pressure as float
  • optional wind direction, denoting the direction from which the wind is flowing. This has a minor effect on the forecast and can be omitted.

The result will be a text description of the forecasted weather.

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

zambretti_py-0.0.4.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

zambretti_py-0.0.4-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file zambretti_py-0.0.4.tar.gz.

File metadata

  • Download URL: zambretti_py-0.0.4.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for zambretti_py-0.0.4.tar.gz
Algorithm Hash digest
SHA256 54a118a91cc518261e9922fef22035734cffe12f12cd4259bda9fa5104098655
MD5 5ec567861f257352556264e422bcf0d2
BLAKE2b-256 d7c2e64d01e92e0ef118be1f7e7f5d0aa111a6a6ce19864e58230785495aefa3

See more details on using hashes here.

File details

Details for the file zambretti_py-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for zambretti_py-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 3d4cc536c598f8f316c14fe26ca46da47a3e58790fdc4f61d387e1a32c213db9
MD5 d6bf703fbbfa0534ff3bca6eed3b70a0
BLAKE2b-256 8519fc20b116e7f9e1208e8495d15b15a9f90a434061267b84390f72e4c0fe29

See more details on using hashes here.

Supported by

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