Skip to main content

A package to access meteorological data from Environment Canada

Project description

Environment Canada (env_canada)

This package provides access to various data sources published by Environment and Climate Change Canada.

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, and format (one of xml or csv). 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, 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")

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)

License

The code is available under terms of MIT License

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

env_canada-0.5.10.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

env_canada-0.5.10-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file env_canada-0.5.10.tar.gz.

File metadata

  • Download URL: env_canada-0.5.10.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for env_canada-0.5.10.tar.gz
Algorithm Hash digest
SHA256 04ff627a01c01fd07754821c74495681b474b4f8cfe5b29c54be4d1964389030
MD5 017b8b1d51990992bafb081ed5e3c94f
BLAKE2b-256 ad8481a13f097972b6457f4612ab6c81bb959d8f15349fe951e330501f14c4d3

See more details on using hashes here.

File details

Details for the file env_canada-0.5.10-py3-none-any.whl.

File metadata

  • Download URL: env_canada-0.5.10-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for env_canada-0.5.10-py3-none-any.whl
Algorithm Hash digest
SHA256 fb8e00bf2c82e437b5a0df0f52c0f7d258aedf974b20671453d8f9c83e6257b2
MD5 51c6e83e227c743e95fdfe45fdba9053
BLAKE2b-256 32792fa00c73c36dddbf3eb4f19f2fbd0f24cbafaccd999038fafc1c7a0dd230

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page