mirror of
https://github.com/jdejaegh/python-irceline.git
synced 2025-06-26 19:35:40 +02:00
Update README
This commit is contained in:
parent
7e5a1da012
commit
74dfd6b8aa
1 changed files with 13 additions and 15 deletions
28
README.md
28
README.md
|
@ -24,9 +24,8 @@ pip install open-irceline
|
||||||
```python
|
```python
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import asyncio
|
import asyncio
|
||||||
from datetime import datetime, date
|
from datetime import datetime
|
||||||
|
from open_irceline import IrcelineRioClient, IrcelineForecastClient, ForecastFeature, RioFeature
|
||||||
from open_irceline import IrcelineRioClient, RioFeature, IrcelineForecastClient, ForecastFeature, belaqi_index_rio_hourly
|
|
||||||
|
|
||||||
|
|
||||||
async def get_rio_interpolated_data():
|
async def get_rio_interpolated_data():
|
||||||
|
@ -43,12 +42,11 @@ async def get_rio_interpolated_data():
|
||||||
print(f"PM10 {result[RioFeature.PM10_HMEAN]['value']} µg/m³")
|
print(f"PM10 {result[RioFeature.PM10_HMEAN]['value']} µg/m³")
|
||||||
|
|
||||||
|
|
||||||
async def get_forecast():
|
async def get_o3_forecast():
|
||||||
"""Get forecast for O3 concentration for Brussels for the next days"""
|
"""Get forecast for O3 concentration for Brussels for the next days"""
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
client = IrcelineForecastClient(session)
|
client = IrcelineForecastClient(session)
|
||||||
result = await client.get_data(
|
result = await client.get_data(
|
||||||
timestamp=date.today(),
|
|
||||||
features=[ForecastFeature.O3_MAXHMEAN],
|
features=[ForecastFeature.O3_MAXHMEAN],
|
||||||
position=(50.85, 4.35) # (lat, lon) for Brussels
|
position=(50.85, 4.35) # (lat, lon) for Brussels
|
||||||
)
|
)
|
||||||
|
@ -57,28 +55,28 @@ async def get_forecast():
|
||||||
print(f"{feature} {day} {v['value']} µg/m³")
|
print(f"{feature} {day} {v['value']} µg/m³")
|
||||||
|
|
||||||
|
|
||||||
async def get_current_belaqi():
|
async def get_belaqi_forecast():
|
||||||
"""Get current BelAQI index from RIO interpolated values"""
|
"""Get current BelAQI index from RIO interpolated values"""
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
client = IrcelineRioClient(session)
|
client = IrcelineForecastClient(session)
|
||||||
result = await belaqi_index_rio_hourly(
|
result = await client.get_data(
|
||||||
rio_client=client,
|
features=[ForecastFeature.BELAQI],
|
||||||
timestamp=datetime.utcnow(), # must be timezone aware
|
|
||||||
position=(50.85, 4.35) # (lat, lon) for Brussels
|
position=(50.85, 4.35) # (lat, lon) for Brussels
|
||||||
)
|
)
|
||||||
|
|
||||||
print(f"Current BelAQI index for Brussels: {result.get('value')}")
|
for (_, day), value in result.items():
|
||||||
|
print(day, value['value'])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print("RIO interpolated data")
|
print("\nInterpolated data")
|
||||||
asyncio.run(get_rio_interpolated_data())
|
asyncio.run(get_rio_interpolated_data())
|
||||||
|
|
||||||
print("\nO3 forecast for Brussels")
|
print("\nO3 forecast for Brussels")
|
||||||
asyncio.run(get_forecast())
|
asyncio.run(get_o3_forecast())
|
||||||
|
|
||||||
print("\nCurrent BelAQI index")
|
print("\nForecast BelAQI index")
|
||||||
asyncio.run(get_current_belaqi())
|
asyncio.run(get_belaqi_forecast())
|
||||||
```
|
```
|
||||||
|
|
||||||
## Attribution
|
## Attribution
|
||||||
|
|
Loading…
Add table
Reference in a new issue