-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathforecast.py
More file actions
34 lines (26 loc) · 1.28 KB
/
Copy pathforecast.py
File metadata and controls
34 lines (26 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# pylint: disable=W0621
"""Asynchronous Python client for GeoSphere Austria forecast 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_instance:
# option to disable verify of ssl check
zamg_instance.verify_ssl = False
# trying to read GeoSphere Austria station id of the closest station
data = await zamg_instance.closest_station(46.99, 15.499)
# set closest station as default one to read
zamg_instance.set_default_station(data)
# print(f"forecast_metadata: {zamg_instance.forecast_metadata}")
# print(f"get_forecast_all_parameters: {zamg_instance.get_forecast_all_parameters()}")
data = await zamg_instance.get_forecast("46.99,15.499", current_only=True)
print(f"get_forecast(current_only=True): {data}")
# get forecast for the default station (closest station) with all parameters
data = await zamg_instance.get_forecast(current_only=False)
print(f"get_forecast(current_only=False): {data}")
except ZamgError as exc:
print(exc)
if __name__ == "__main__":
asyncio.run(main())