python-zamg
Python library to read 10 min weather data from GeoSphere Austria former ZAMG
About
This package allows you to read the weather data from weather stations of GeoSphere Austria weather service.
GeoSphere Austria joins Zentralanstalt für Meteorologie und Geodynamik (ZAMG) and the Geologische Bundesanstalt (GBA)
since 1st January 2023.
Installation
pip install zamg
Usage
Simple usage example to fetch specific data from the closest station.
"""Asynchronous Python client for GeoSphere Austria weather data."""
import asyncio
import src.zamg.zamg
from src.zamg.exceptions import ZamgError
async def main():
"""Sample of getting data"""
try:
async with src.zamg.zamg.ZamgData() as zamg:
zamg.verify_ssl = False
data = await zamg.closest_station(46.99, 15.499)
zamg.set_default_station(data)
print("closest_station = " + str(zamg.get_station_name) + " / " + str(data))
print(f"Possible station parameters: {zamg.get_all_parameters()}")
zamg.station_parameters = "TL,SO"
zamg.set_parameters(("TL", "SO"))
await zamg.update()
print(f"---------- Weather for station {zamg.get_station_name} ({data})")
for param in zamg.get_parameters():
print(
str(param)
+ " -> "
+ str(zamg.get_data(parameter=param, data_type="name"))
+ " -> "
+ str(zamg.get_data(parameter=param))
+ " "
+ str(zamg.get_data(parameter=param, data_type="unit"))
)
print("last update: %s", zamg.last_update)
except (ZamgError) as exc:
print(exc)
if __name__ == "__main__":
asyncio.run(main())
Contributions are welcome!
If you want to contribute to this please read the Contribution guidelines
Credits
Code template to read dataset API was mainly taken from @LuisTheOne's zamg-api-cli-client
Dataset API Dokumentation