Name | zambretti-py JSON |
Version |
0.0.5
JSON |
| download |
home_page | None |
Summary | The Zambretti Algorithm for weather forecasting |
upload_time | 2024-11-22 07:59:17 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | None |
keywords |
forecasting
weather
zambretti
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Zambretti Weather Forecasting in Python
This is a Python implementation of the [Zambretti Weather
Forecaster](https://en.wikipedia.org/wiki/Zambretti_Forecaster)
The code is heavily based on the [Zambretti Algorithm for Weather Forecasting
ESP
example](https://github.com/sassoftware/iot-zambretti-weather-forcasting?tab=readme-ov-file)
Further reading: [Short-Range Local Forecasting with a Digital Barograph using
an Algorithm based on the Zambretti
Forecaster.](https://integritext.net/DrKFS/zambretti.htm)
## Python Package
This repository is available as a package in PyPi: [https://pypi.org/project/zambretti-py/](https://pypi.org/project/zambretti-py/)
## Usage notes
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.
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.
## Examples
### Example usage with provided pressure data:
```
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)
```
### Example usage with loading pressure data from a CSV file:
If you have the pressure history in a CSV file such as this one:
| state | last_changed |
|----------------|---------------------------|
| 988.6 | 2024-11-19T11:33:32.706Z |
| 988.5 | 2024-11-19T11:34:06.863Z |
| 988.4 | 2024-11-19T11:37:06.887Z |
That file can be loaded into `PressureData` by using a `PressureData.from_csv_file`:
```
from zambretti_py import PressureData, WindDirection, Zambretti
pressure_data = PressureData.from_csv_file(
fname="history.csv",
timestamp_column_position=1,
pressure_column_position=0,
skip_header_rows=1,
strptime_template="%Y-%m-%dT%H:%M:%S.%fZ",
)
zambretti = Zambretti()
forecast = zambretti.forecast(
elevation=75,
temperature=3,
pressure_data=pressure_data,
wind_direction=WindDirection.SOUTH,
)
print(forecast)
```
### Example usage with a CSV file generated in Home Assistant:
When you have a sensor in Home Assistant, you can export its history from the
web interface, the result will be a CSV file with this schema:
| entity_id | state | last_changed |
|--------------|----------------|---------------------------|
| sensor.pressure | 988.6 | 2024-11-19T11:33:32.706Z |
| sensor.pressure | 988.5 | 2024-11-19T11:34:06.863Z |
| sensor.pressure | 988.4 | 2024-11-19T11:37:06.887Z |
That file can be loaded into `PressureData` by using `PressureData.from_home_assistant_csv`:
```
from zambretti_py import PressureData, WindDirection, Zambretti
pressure_data = PressureData.from_home_assistant_csv("history.csv")
zambretti = Zambretti()
forecast = zambretti.forecast(
elevation=75,
temperature=3,
pressure_data=pressure_data,
wind_direction=WindDirection.SOUTH,
)
print(forecast)
```
Raw data
{
"_id": null,
"home_page": null,
"name": "zambretti-py",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "forecasting, weather, zambretti",
"author": null,
"author_email": "STFN <stfndev@protonmail.com>",
"download_url": "https://files.pythonhosted.org/packages/92/10/f5d2f4b456b877252abcf496aef8c15e5a696fe9a4f326e1cf5a8de0c360/zambretti_py-0.0.5.tar.gz",
"platform": null,
"description": "# Zambretti Weather Forecasting in Python\n\nThis is a Python implementation of the [Zambretti Weather\nForecaster](https://en.wikipedia.org/wiki/Zambretti_Forecaster)\n\nThe code is heavily based on the [Zambretti Algorithm for Weather Forecasting\nESP\nexample](https://github.com/sassoftware/iot-zambretti-weather-forcasting?tab=readme-ov-file)\n\nFurther reading: [Short-Range Local Forecasting with a Digital Barograph using\nan Algorithm based on the Zambretti\nForecaster.](https://integritext.net/DrKFS/zambretti.htm)\n\n## Python Package\n\nThis repository is available as a package in PyPi: [https://pypi.org/project/zambretti-py/](https://pypi.org/project/zambretti-py/)\n\n## Usage notes\n\nTo calculate for forecast, the Zambretti algorithm requires:\n- elevation above sea level\n- current temperature\n- pressure data from the last three hours, or less.\n - data points older than three hours will be removed\n - the pressure data is expected to be provided as a list of tuples, each\n tuple consisting of a datetime.datetime object, and the pressure as float\n- optional wind direction, denoting the direction from which the wind is\n flowing. This has a minor effect on the forecast and can be omitted.\n\nThe result will be a text description of the forecasted weather. \n\nPressure data must be provided in millibars or hPa (those are equivalent).\nElevation must be provided in meters.\nTemperature must be provided in degrees Celsius.\n\nMinimum 6 readings of atmospheric pressure are required. Best results are when\nthe pressure readings span the last three hours, but the code will run on any timespan.\n\n## Technical notes\n\nThis project has no dependencies, uses only functions from the Python Standard\nLibrary. It should run both in Python and MicroPython.\n\n## Examples\n\n### Example usage with provided pressure data:\n\n```\nimport datetime\n\nfrom zambretti_py import PressureData, WindDirection, Zambretti\n\nnow = datetime.datetime.now()\npressure_data = PressureData(\n [\n (now - datetime.timedelta(hours=2, minutes=59), 1050.0),\n (now - datetime.timedelta(hours=2, minutes=49), 1040.0),\n (now - datetime.timedelta(hours=2, minutes=39), 1030.0),\n (now - datetime.timedelta(hours=2, minutes=12), 1020.0),\n (now - datetime.timedelta(hours=1, minutes=19), 1010.0),\n (now - datetime.timedelta(minutes=20), 1000.0),\n ]\n)\nzambretti = Zambretti()\n\nforecast = zambretti.forecast(\n elevation=90,\n temperature=25,\n pressure_data=pressure_data,\n wind_direction=WindDirection.NORTH,\n)\nprint(forecast)\n```\n\n### Example usage with loading pressure data from a CSV file:\n\nIf you have the pressure history in a CSV file such as this one:\n\n| state | last_changed |\n|----------------|---------------------------|\n| 988.6 | 2024-11-19T11:33:32.706Z |\n| 988.5 | 2024-11-19T11:34:06.863Z |\n| 988.4 | 2024-11-19T11:37:06.887Z |\n\nThat file can be loaded into `PressureData` by using a `PressureData.from_csv_file`:\n\n\n```\nfrom zambretti_py import PressureData, WindDirection, Zambretti\n\npressure_data = PressureData.from_csv_file(\n fname=\"history.csv\",\n timestamp_column_position=1,\n pressure_column_position=0,\n skip_header_rows=1,\n strptime_template=\"%Y-%m-%dT%H:%M:%S.%fZ\",\n)\n\nzambretti = Zambretti()\n\nforecast = zambretti.forecast(\n elevation=75,\n temperature=3,\n pressure_data=pressure_data,\n wind_direction=WindDirection.SOUTH,\n)\nprint(forecast)\n```\n\n### Example usage with a CSV file generated in Home Assistant:\n\nWhen you have a sensor in Home Assistant, you can export its history from the\nweb interface, the result will be a CSV file with this schema:\n\n| entity_id | state | last_changed |\n|--------------|----------------|---------------------------|\n| sensor.pressure | 988.6 | 2024-11-19T11:33:32.706Z |\n| sensor.pressure | 988.5 | 2024-11-19T11:34:06.863Z |\n| sensor.pressure | 988.4 | 2024-11-19T11:37:06.887Z |\n\nThat file can be loaded into `PressureData` by using `PressureData.from_home_assistant_csv`:\n\n```\nfrom zambretti_py import PressureData, WindDirection, Zambretti\n\npressure_data = PressureData.from_home_assistant_csv(\"history.csv\")\n\nzambretti = Zambretti()\n\nforecast = zambretti.forecast(\n elevation=75,\n temperature=3,\n pressure_data=pressure_data,\n wind_direction=WindDirection.SOUTH,\n)\nprint(forecast)\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "The Zambretti Algorithm for weather forecasting",
"version": "0.0.5",
"project_urls": {
"Homepage": "https://github.com/thestfndev/zambretti-py",
"Issues": "https://github.com/thestfndev/zambretti-py/issues"
},
"split_keywords": [
"forecasting",
" weather",
" zambretti"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "25002d3fe13431bb313c8259b1984590b0937ff7d2afe2364aa53d7d0a792019",
"md5": "449405ff748000933e436a4da4147061",
"sha256": "6c90c2f00ead4c68a0738f05145b25fc183df22296686f826b75662fe589213c"
},
"downloads": -1,
"filename": "zambretti_py-0.0.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "449405ff748000933e436a4da4147061",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 6149,
"upload_time": "2024-11-22T07:59:16",
"upload_time_iso_8601": "2024-11-22T07:59:16.260651Z",
"url": "https://files.pythonhosted.org/packages/25/00/2d3fe13431bb313c8259b1984590b0937ff7d2afe2364aa53d7d0a792019/zambretti_py-0.0.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9210f5d2f4b456b877252abcf496aef8c15e5a696fe9a4f326e1cf5a8de0c360",
"md5": "8cf9f641277dcbb19f801f63000bfb87",
"sha256": "6ddb1e4b34b276af360812020640671370f0488553231bb69670be44cfa0db03"
},
"downloads": -1,
"filename": "zambretti_py-0.0.5.tar.gz",
"has_sig": false,
"md5_digest": "8cf9f641277dcbb19f801f63000bfb87",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 6860,
"upload_time": "2024-11-22T07:59:17",
"upload_time_iso_8601": "2024-11-22T07:59:17.145382Z",
"url": "https://files.pythonhosted.org/packages/92/10/f5d2f4b456b877252abcf496aef8c15e5a696fe9a4f326e1cf5a8de0c360/zambretti_py-0.0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-22 07:59:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "thestfndev",
"github_project": "zambretti-py",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "zambretti-py"
}