env-canada 0.6.0__py3-none-any.whl → 0.6.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
env_canada/__init__.py CHANGED
@@ -1,5 +1,5 @@
1
- from .ec_aqhi import *
2
- from .ec_historical import *
3
- from .ec_hydro import *
4
- from .ec_radar import *
5
- from .ec_weather import *
1
+ from .ec_aqhi import ECAirQuality
2
+ from .ec_historical import ECHistorical, ECHistoricalRange
3
+ from .ec_hydro import ECHydro
4
+ from .ec_radar import ECRadar
5
+ from .ec_weather import ECWeather
env_canada/constants.py CHANGED
@@ -1 +1 @@
1
- USER_AGENT = "env_canada/0.6.0"
1
+ USER_AGENT = "env_canada/0.6.2"
env_canada/ec_radar.py CHANGED
@@ -1,17 +1,18 @@
1
- from aiohttp.client_exceptions import ClientConnectorError
2
1
  import asyncio
3
2
  import datetime
4
- from io import BytesIO
5
3
  import logging
6
4
  import math
7
5
  import os
8
- from PIL import Image, ImageDraw, ImageFont
6
+ from io import BytesIO
9
7
 
10
- from .ec_cache import CacheClientSession as ClientSession
11
8
  import dateutil.parser
12
9
  import defusedxml.ElementTree as et
13
10
  import imageio.v2 as imageio
14
11
  import voluptuous as vol
12
+ from aiohttp.client_exceptions import ClientConnectorError
13
+ from PIL import Image, ImageDraw, ImageFont
14
+
15
+ from .ec_cache import CacheClientSession as ClientSession
15
16
 
16
17
  ATTRIBUTION = {
17
18
  "english": "Data provided by Environment Canada",
@@ -331,6 +332,17 @@ class ECRadar(object):
331
332
  async def get_loop(self, fps=5):
332
333
  """Build an animated GIF of recent radar images."""
333
334
 
335
+ def build_image():
336
+ gif_frames = [imageio.imread(f, mode="RGBA") for f in frames]
337
+ gif_bytes = imageio.mimwrite(
338
+ imageio.RETURN_BYTES,
339
+ gif_frames,
340
+ format="GIF",
341
+ duration=duration,
342
+ subrectangles=True,
343
+ )
344
+ return gif_bytes
345
+
334
346
  """Build list of frame timestamps."""
335
347
  start, end = await self._get_dimensions()
336
348
  frame_times = [start]
@@ -361,12 +373,6 @@ class ECRadar(object):
361
373
  """Assemble animated GIF."""
362
374
  duration = 1000 / fps
363
375
 
364
- gif_frames = [imageio.imread(f, mode="RGBA") for f in frames]
365
- gif_bytes = imageio.mimwrite(
366
- imageio.RETURN_BYTES,
367
- gif_frames,
368
- format="GIF",
369
- duration=duration,
370
- subrectangles=True,
371
- )
376
+ loop = asyncio.get_running_loop()
377
+ gif_bytes = await loop.run_in_executor(None, build_image)
372
378
  return gif_bytes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
- Name: env-canada
3
- Version: 0.6.0
2
+ Name: env_canada
3
+ Version: 0.6.2
4
4
  Summary: A package to access meteorological data from Environment Canada
5
5
  Home-page: https://github.com/michaeldavie/env_canada
6
6
  Author: Michael Davie
@@ -11,7 +11,7 @@ Classifier: License :: OSI Approved :: MIT License
11
11
  Classifier: Operating System :: OS Independent
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
- Requires-Dist: aiohttp
14
+ Requires-Dist: aiohttp >=3.9.0
15
15
  Requires-Dist: defusedxml
16
16
  Requires-Dist: geopy
17
17
  Requires-Dist: imageio >=2.28.0
@@ -23,8 +23,9 @@ Requires-Dist: python-dateutil
23
23
  Requires-Dist: voluptuous
24
24
 
25
25
  # Environment Canada (env_canada)
26
+
26
27
  [![PyPI version](https://badge.fury.io/py/env-canada.svg)](https://badge.fury.io/py/env-canada)
27
- [![Snyk rating](https://snyk-widget.herokuapp.com/badge/pip/env-canada/badge.svg)](https://snyk.io/vuln/pip:env-canada@0.6.0?utm_source=badge)
28
+ [![Snyk rating](https://snyk-widget.herokuapp.com/badge/pip/env-canada/badge.svg)](https://snyk.io/vuln/pip:env-canada@0.6.2?utm_source=badge)
28
29
 
29
30
  This package provides access to various data sources published by [Environment and Climate Change Canada](https://www.canada.ca/en/environment-climate-change.html).
30
31
 
@@ -115,7 +116,8 @@ Once updated asynchronously, historical weather data is contained with the `stat
115
116
  ```python
116
117
  import asyncio
117
118
 
118
- from env_canada import ECHistorical, get_historical_stations
119
+ from env_canada import ECHistorical
120
+ from env_canada.ec_historical import get_historical_stations
119
121
 
120
122
  # search for stations, response contains station_ids
121
123
  coordinates = [53.916944, -122.749444] # [lat, long]
@@ -164,7 +166,8 @@ For example :
164
166
  ```python
165
167
  import pandas as pd
166
168
  import asyncio
167
- from env_canada import ECHistoricalRange, get_historical_stations
169
+ from env_canada import ECHistoricalRange
170
+ from env_canada.ec_historical import get_historical_stations
168
171
  from datetime import datetime
169
172
 
170
173
  coordinates = ['48.508333', '-68.467667']
@@ -177,33 +180,30 @@ ec = ECHistoricalRange(station_id=int(stations.iloc[0,2]), timeframe="daily",
177
180
 
178
181
  ec.get_data()
179
182
 
180
- #yield an XML formated str.
183
+ #yield an XML formated str.
181
184
  # For more options, use ec.to_xml(*arg, **kwargs) with pandas options
182
185
  ec.xml
183
-
186
+
184
187
  #yield an CSV formated str.
185
188
  # For more options, use ec.to_csv(*arg, **kwargs) with pandas options
186
189
  ec.csv
187
190
  ```
188
191
 
189
- In this example ```ec.df``` will be:
190
-
191
- | Date/Time | Longitude (x) | Latitude (y) | Station Name | Climate ID | Year | Month | Day | Data Quality | Max Temp (°C) | Max Temp Flag | Min Temp (°C) | Min Temp Flag | Mean Temp (°C) | Mean Temp Flag | Heat Deg Days (°C) | Heat Deg Days Flag | Cool Deg Days (°C) | Cool Deg Days Flag | Total Rain (mm) | Total Rain Flag | Total Snow (cm) | Total Snow Flag | Total Precip (mm) | Total Precip Flag | Snow on Grnd (cm) | Snow on Grnd Flag | Dir of Max Gust (10s deg) | Dir of Max Gust Flag | Spd of Max Gust (km/h) | Spd of Max Gust Flag | |
192
- |--- |--- |--- |--- |--- |--- |--- |--- |--- |--- |--- |--- |--- |--- |--- |--- |--- |--- |--- |--- |--- |--- |--- |--- |--- |--- |--- |--- |--- |--- |--- |--- |
193
- | 2022-07-02 | -68,47 | 48,51 | POINTE-AU-PERE (INRS) | 7056068 | 2022 | 7 | 2 | | 22,8 | | 12,5 | | 17,7 | | 0,3 | | 0 | | | | | | 0 | | | | 26 | | 37 | | |
194
- | 2022-07-03 | -68,47 | 48,51 | POINTE-AU-PERE (INRS) | 7056068 | 2022 | 7 | 3 | | 21,7 | | 10,1 | | 15,9 | | 2,1 | | 0 | | | | | | 0,4 | | | | 28 | | 50 | | |
195
- | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … |
196
- | 2022-07-31 | -68,47 | 48,51 | POINTE-AU-PERE (INRS) | 7056068 | 2022 | 7 | 31 | | 23,5 | | 14,1 | | 18,8 | | 0 | | 0,8 | | | | | | 0 | | | | 23 | | 31 | | |
197
- | 2022-08-01 | -68,47 | 48,51 | POINTE-AU-PERE (INRS) | 7056068 | 2022 | 8 | 1 | | 23 | | 15 | | 19 | | 0 | | 1 | | | | | | 0 | | | | 21 | | 35 | | |
192
+ In this example `ec.df` will be:
198
193
 
194
+ | Date/Time | Longitude (x) | Latitude (y) | Station Name | Climate ID | Year | Month | Day | Data Quality | Max Temp (°C) | Max Temp Flag | Min Temp (°C) | Min Temp Flag | Mean Temp (°C) | Mean Temp Flag | Heat Deg Days (°C) | Heat Deg Days Flag | Cool Deg Days (°C) | Cool Deg Days Flag | Total Rain (mm) | Total Rain Flag | Total Snow (cm) | Total Snow Flag | Total Precip (mm) | Total Precip Flag | Snow on Grnd (cm) | Snow on Grnd Flag | Dir of Max Gust (10s deg) | Dir of Max Gust Flag | Spd of Max Gust (km/h) | Spd of Max Gust Flag | |
195
+ | ---------- | ------------- | ------------ | --------------------- | ---------- | ---- | ----- | --- | ------------ | -------------- | ------------- | -------------- | ------------- | --------------- | -------------- | ------------------- | ------------------ | ------------------- | ------------------ | --------------- | --------------- | --------------- | --------------- | ----------------- | ----------------- | ----------------- | ----------------- | ------------------------- | -------------------- | ---------------------- | -------------------- | --- |
196
+ | 2022-07-02 | -68,47 | 48,51 | POINTE-AU-PERE (INRS) | 7056068 | 2022 | 7 | 2 | | 22,8 | | 12,5 | | 17,7 | | 0,3 | | 0 | | | | | | 0 | | | | 26 | | 37 | | |
197
+ | 2022-07-03 | -68,47 | 48,51 | POINTE-AU-PERE (INRS) | 7056068 | 2022 | 7 | 3 | | 21,7 | | 10,1 | | 15,9 | | 2,1 | | 0 | | | | | | 0,4 | | | | 28 | | 50 | | |
198
+ | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … |
199
+ | 2022-07-31 | -68,47 | 48,51 | POINTE-AU-PERE (INRS) | 7056068 | 2022 | 7 | 31 | | 23,5 | | 14,1 | | 18,8 | | 0 | | 0,8 | | | | | | 0 | | | | 23 | | 31 | | |
200
+ | 2022-08-01 | -68,47 | 48,51 | POINTE-AU-PERE (INRS) | 7056068 | 2022 | 8 | 1 | | 23 | | 15 | | 19 | | 0 | | 1 | | | | | | 0 | | | | 21 | | 35 | | |
199
201
 
200
202
  One should note that july 1st is excluded as the time provided contains specific hours, so it yields only data after or at exactly
201
203
  the time provided.
202
204
 
203
- To have all the july 1st data in that case, one can provide a datarange without time: ```datetime(2022, 7, 7)``` instead
204
- of ```datetime(2022, 7, 1, 12, 12)```
205
-
206
-
205
+ To have all the july 1st data in that case, one can provide a datarange without time: `datetime(2022, 7, 7)` instead
206
+ of `datetime(2022, 7, 1, 12, 12)`
207
207
 
208
208
  # License
209
209
 
@@ -1,16 +1,16 @@
1
1
  env_canada/10x20.pbm,sha256=ClKTs2WUmhUhTHAQzPuGwPTICGVBzCvos5l-vHRBE5M,2463
2
2
  env_canada/10x20.pil,sha256=Oki6-TD7b0xFtfm6vxCKsmpEpsZ5Jaia_0v_aDz8bfE,5143
3
- env_canada/__init__.py,sha256=wQpbGVmwROrIR06RWinatD-qX7fbJvxBFOd6U0xoek4,126
4
- env_canada/constants.py,sha256=J9f7pzgc6vMFnvfldxKb1ny3wprK1h71zhyANKyNOnw,32
3
+ env_canada/__init__.py,sha256=wEx1BCwVUH__GoosSlhNMHuUKCKNZAvv5uuSa5ZWq_g,187
4
+ env_canada/constants.py,sha256=aVL9KzeCGoOZ2odaGXcKNqcxHZRamfD0CLXSFmyoZSM,32
5
5
  env_canada/ec_aqhi.py,sha256=kJQ8xEgFnujGMYdxRXpoEK17B5e-ya-Y7rK0vLo_-w0,7768
6
6
  env_canada/ec_cache.py,sha256=qoFxmO-kOBT8jhgPeNWtVBRmguXcARIIOI54OaDh-20,1171
7
7
  env_canada/ec_exc.py,sha256=SBJwzmLf94lTx7KYVLfQYrMXYNYUoIxeVXc-BLkuXoE,67
8
8
  env_canada/ec_historical.py,sha256=slHaFwsoyW16uCVtE3_-IF3_BFhFD4IuWl7rpIRsCm4,15901
9
9
  env_canada/ec_hydro.py,sha256=LBsWreTlaTKec6ObjI0ih8-zOKBNjD02oiXKTyUa1EQ,4898
10
- env_canada/ec_radar.py,sha256=WaJHtNnuQa3XoidvymOjJxNHqRLORTcy6_mczjIwd_A,12217
10
+ env_canada/ec_radar.py,sha256=TPzIlzwkgnsCSbN9Isdo_Q-1ORemNdYEBCcKfl_-ZcE,12415
11
11
  env_canada/ec_weather.py,sha256=uBY6qd0-hVyZDhqPcpipfMDImXpJGiNIzMOjIzqNBfo,17358
12
- env_canada-0.6.0.dist-info/LICENSE,sha256=c037dTHQWAgRgDqZNN-5d-CZvcteSYN37u39SNklO0I,1072
13
- env_canada-0.6.0.dist-info/METADATA,sha256=QrC0LVs2eV6nvPYvEH-1K8fNG7Q5j2SYT5evLaYFPU4,8374
14
- env_canada-0.6.0.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
15
- env_canada-0.6.0.dist-info/top_level.txt,sha256=fw7Pcl9ULBXYvqnAdyBdmwPXW8GSRFmhO0sLZWVfOCc,11
16
- env_canada-0.6.0.dist-info/RECORD,,
12
+ env_canada-0.6.2.dist-info/LICENSE,sha256=c037dTHQWAgRgDqZNN-5d-CZvcteSYN37u39SNklO0I,1072
13
+ env_canada-0.6.2.dist-info/METADATA,sha256=0-49I2ZCrOoguMf9YnoCrmV3I0eR_Pn-l2_Rvvkpwxw,10652
14
+ env_canada-0.6.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
15
+ env_canada-0.6.2.dist-info/top_level.txt,sha256=fw7Pcl9ULBXYvqnAdyBdmwPXW8GSRFmhO0sLZWVfOCc,11
16
+ env_canada-0.6.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.2)
2
+ Generator: bdist_wheel (0.43.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5