env_canada
Provides access to various data sources published by Environment and Climate Change Canada.
https://github.com/michaeldavie/env_canada
Category: Sustainable Development
Sub Category: Data Catalogs and Interfaces
Keywords from Contributors
varta varta-storage sensor asyncio water public-transportation static-analysis static-code-analysis certificate report
Last synced: about 14 hours ago
JSON representation
Repository metadata
Environment Canada Weather Data
- Host: GitHub
- URL: https://github.com/michaeldavie/env_canada
- Owner: michaeldavie
- License: mit
- Created: 2018-07-30T03:14:30.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-04-14T17:08:49.000Z (12 days ago)
- Last Synced: 2025-04-20T09:44:36.146Z (7 days ago)
- Language: Python
- Homepage:
- Size: 687 KB
- Stars: 93
- Watchers: 9
- Forks: 20
- Open Issues: 3
- Releases: 66
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
README.md
Environment Canada (env_canada)
This package provides access to various data sources published by Environment and Climate Change Canada.
[!IMPORTANT]
If you're using the library in a Jupyter notebook, replaceasyncio.run(...)
withawait ...
in the examples below. For example:asyncio.run(ec_en.update())
becomes
await ec_en.update()
Weather Observations and Forecasts
ECWeather
provides current conditions and forecasts. It automatically determines which weather station to use based on latitude/longitude provided. It is also possible to specify a specific station code of the form AB/s0000123
based on those listed in this CSV file. For example:
import asyncio
from env_canada import ECWeather
ec_en = ECWeather(coordinates=(50, -100))
ec_fr = ECWeather(station_id="ON/s0000430", language="french")
asyncio.run(ec_en.update())
# current conditions
ec_en.conditions
# daily forecasts
ec_en.daily_forecasts
# hourly forecasts
ec_en.hourly_forecasts
# alerts
ec_en.alerts
Weather Radar
ECRadar
provides Environment Canada meteorological radar imagery.
import asyncio
from env_canada import ECRadar
radar_coords = ECRadar(coordinates=(50, -100))
# Conditions Available
animated_gif = asyncio.run(radar_coords.get_loop())
latest_png = asyncio.run(radar_coords.get_latest_frame())
Air Quality Health Index (AQHI)
ECAirQuality
provides Environment Canada air quality data.
import asyncio
from env_canada import ECAirQuality
aqhi_coords = ECAirQuality(coordinates=(50, -100))
asyncio.run(aqhi_coords.update())
# Data available
aqhi_coords.current
aqhi_coords.forecasts
Water Level and Flow
ECHydro
provides Environment Canada hydrometric data.
import asyncio
from env_canada import ECHydro
hydro_coords = ECHydro(coordinates=(50, -100))
asyncio.run(hydro_coords.update())
# Data available
hydro_coords.measurements
Historical Weather Data
ECHistorical
provides historical daily weather data.
The ECHistorical object is instantiated with a station ID, year, language, format (one of xml or csv) and granularity (hourly, daily data).
Once updated asynchronously, historical weather data is contained with the station_data
property. If xml
is requested, station_data
will appear in a dictionary form. If csv
is requested, station_data
will contain a CSV-readable buffer. For example:
import asyncio
from env_canada import ECHistorical
from env_canada.ec_historical import get_historical_stations
# search for stations, response contains station_ids
coordinates = [53.916944, -122.749444] # [lat, long]
# coordinates: [lat, long]
# radius: km
# limit: response limit, value one of [10, 25, 50, 100]
# The result contains station names and ID values.
stations = asyncio.run(get_historical_stations(coordinates, radius=200, limit=100))
ec_en_xml = ECHistorical(station_id=31688, year=2020, language="english", format="xml")
ec_fr_xml = ECHistorical(station_id=31688, year=2020, language="french", format="xml")
ec_en_csv = ECHistorical(station_id=31688, year=2020, language="english", format="csv")
ec_fr_csv = ECHistorical(station_id=31688, year=2020, language="french", format="csv")
# timeframe argument can be passed to change the granularity
# timeframe=1 hourly (need to create of for every month in that case, use ECHistoricalRange to handle it automatically)
# timeframe=2 daily (default)
ec_en_xml = ECHistorical(
station_id=31688, year=2020, month=1, language="english", format="xml", timeframe=1
)
ec_en_csv = ECHistorical(
station_id=31688, year=2020, month=1, language="english", format="csv", timeframe=1
)
asyncio.run(ec_en_xml.update())
asyncio.run(ec_en_csv.update())
# metadata describing the station
ec_en_xml.metadata
# historical weather data, in dictionary form
ec_en_xml.station_data
# csv-generated responses return csv-like station data
import pandas as pd
df = pd.read_csv(ec_en_csv.station_data)
ECHistoricalRange
provides historical weather data within a specific range and handles the update by itself.
The ECHistoricalRange object is instantiated with at least a station ID and a daterange.
One could add language, and granularity (hourly, daily (default)).
The data can then be used as pandas DataFrame, XML (requires pandas >=1.3.0) and csv
For example :
import pandas as pd
import asyncio
from env_canada import ECHistoricalRange
from env_canada.ec_historical import get_historical_stations
from datetime import datetime
coordinates = ["48.508333", "-68.467667"]
stations = pd.DataFrame(
asyncio.run(
get_historical_stations(
coordinates, start_year=2022, end_year=2022, radius=200, limit=100
)
)
).T
ec = ECHistoricalRange(
station_id=int(stations.iloc[0, 2]),
timeframe="daily",
daterange=(datetime(2022, 7, 1, 12, 12), datetime(2022, 8, 1, 12, 12)),
)
ec.get_data()
# yield an XML formated str.
# For more options, use ec.to_xml(*arg, **kwargs) with pandas options
ec.xml
# yield an CSV formated str.
# For more options, use ec.to_csv(*arg, **kwargs) with pandas options
ec.csv
In this example ec.df
will be:
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 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 | ||||||||||||||||
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 | ||||||||||||||||
… | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … | … |
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 | ||||||||||||||||
2022-08-01 | -68,47 | 48,51 | POINTE-AU-PERE (INRS) | 7056068 | 2022 | 8 | 1 | 23 | 15 | 19 | 0 | 1 | 0 | 21 | 35 |
One should note that july 1st is excluded as the time provided contains specific hours, so it yields only data after or at exactly
the time provided.
To have all the july 1st data in that case, one can provide a datarange without time: datetime(2022, 7, 7)
instead
of datetime(2022, 7, 1, 12, 12)
License
The code is available under terms of MIT License
Owner metadata
- Name: Michael Davie
- Login: michaeldavie
- Email:
- Kind: user
- Description:
- Website:
- Location:
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/16008714?u=e6ccebf558d0e63d08acc061ab68c3ae247ffa27&v=4
- Repositories: 5
- Last ynced at: 2023-03-03T21:25:13.574Z
- Profile URL: https://github.com/michaeldavie
GitHub Events
Total
- Create event: 8
- Issues event: 3
- Release event: 7
- Watch event: 11
- Delete event: 2
- Member event: 1
- Issue comment event: 12
- Push event: 14
- Pull request review event: 5
- Pull request review comment event: 3
- Pull request event: 19
- Fork event: 1
Last Year
- Create event: 8
- Issues event: 3
- Release event: 7
- Watch event: 11
- Delete event: 2
- Member event: 1
- Issue comment event: 12
- Push event: 14
- Pull request review event: 5
- Pull request review comment event: 3
- Pull request event: 19
- Fork event: 1
Committers metadata
Last synced: 4 days ago
Total Commits: 309
Total Committers: 18
Avg Commits per committer: 17.167
Development Distribution Score (DDS): 0.304
Commits in past year: 67
Committers in past year: 7
Avg Commits per committer in past year: 9.571
Development Distribution Score (DDS) in past year: 0.403
Name | Commits | |
---|---|---|
michaeldavie | m****e@g****m | 215 |
Glenn Waters | g****n@w****a | 42 |
Brian Fitzgerald | f****b | 13 |
Glenn Waters | g****s@g****m | 10 |
lletac | l****c@3****a | 8 |
JM Lopez | j****z@u****a | 4 |
snyk-bot | s****t@s****o | 3 |
MrDizzystick | M****k | 3 |
Marc-Antoine Ruel | m****l@g****m | 2 |
everett | e****r@g****m | 1 |
Shixian Sheng | s****2@f****u | 1 |
Rob Leveille | r****e@g****m | 1 |
Marc Mueller | 3****p | 1 |
Fabian Affolter | f****n@a****h | 1 |
Darren Wiens | d****s@g****m | 1 |
Andreas Billmeier | b@e****t | 1 |
marawan31 | m****1@g****m | 1 |
stevendinardo | 1****o | 1 |
Committer domains:
- edevau.net: 1
- affolter-engineering.ch: 1
- fsu.edu: 1
- snyk.io: 1
- utoronto.ca: 1
- 3eing.ca: 1
- watrs.ca: 1
Issue and Pull Request metadata
Last synced: 1 day ago
Total issues: 61
Total pull requests: 47
Average time to close issues: 3 months
Average time to close pull requests: 9 days
Total issue authors: 40
Total pull request authors: 18
Average comments per issue: 2.9
Average comments per pull request: 1.02
Merged pull request: 43
Bot issues: 0
Bot pull requests: 0
Past year issues: 4
Past year pull requests: 17
Past year average time to close issues: about 7 hours
Past year average time to close pull requests: 3 days
Past year issue authors: 4
Past year pull request authors: 6
Past year average comments per issue: 2.5
Past year average comments per pull request: 1.41
Past year merged pull request: 16
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- gwww (8)
- fitzb (3)
- glassbase (3)
- alexandery (3)
- jm66 (2)
- ikifar2012 (2)
- michaeldavie (2)
- cpw (2)
- maruel (2)
- A-c0rN (2)
- deftdawg (2)
- PhilBaobab (2)
- Deurnieur (1)
- rcblackwell (1)
- pgsylvestre (1)
Top Pull Request Authors
- gwww (20)
- michaeldavie (5)
- jm66 (4)
- maruel (2)
- fitzb (2)
- Biorix (2)
- darrenwiens (1)
- marawan31 (1)
- stevendinardo (1)
- sylvainletourneau (1)
- KPCOFGS (1)
- ontarionick (1)
- everettsp (1)
- cdce8p (1)
- infectedroot (1)
Top Issue Labels
- enhancement (4)
- bug (2)
Top Pull Request Labels
Package metadata
- Total packages: 1
-
Total downloads:
- pypi: 11,993 last-month
- Total docker downloads: 757,189,253
- Total dependent packages: 2
- Total dependent repositories: 19
- Total versions: 103
- Total maintainers: 1
pypi.org: env-canada
A package to access meteorological data from Environment Canada
- Homepage: https://github.com/michaeldavie/env_canada
- Documentation: https://github.com/michaeldavie/env_canada
- Licenses: Copyright (c) 2018 The Python Packaging Authority Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
- Latest release: 0.10.1 (published 13 days ago)
- Last Synced: 2025-04-25T12:10:33.925Z (1 day ago)
- Versions: 103
- Dependent Packages: 2
- Dependent Repositories: 19
- Downloads: 11,993 Last month
- Docker Downloads: 757,189,253
-
Rankings:
- Docker downloads count: 0.168%
- Dependent packages count: 3.245%
- Dependent repos count: 3.358%
- Downloads: 3.653%
- Average: 4.724%
- Stargazers count: 8.313%
- Forks count: 9.608%
- Maintainers (1)
Dependencies
- actions/checkout v3 composite
- github/codeql-action/analyze v2 composite
- github/codeql-action/autobuild v2 composite
- github/codeql-action/init v2 composite
- actions/checkout v2 composite
- actions/setup-python v2 composite
- actions/checkout v2 composite
- actions/setup-python v2 composite
- Pillow *
- aiohttp *
- defusedxml *
- geopy *
- imageio *
- lxml *
- pandas >=1.3.0
- python-dateutil *
- voluptuous *
- Pillow *
- aiohttp *
- defusedxml *
- geopy *
- imageio *
- lxml *
- pandas >=1.3.0
- python-dateutil *
- voluptuous *
Score: 27.89985966860593