Skip to main content

airpyllution

codecov build deploy

airpyllution is a Python package for visualizing or obtaining future, historic and current air pollution data using the OpenWeather API. Our goal is to enable users the ability to explore air pollution levels in locations around the world by providing visual charts and graphs. We make the data accessible and easy to comprehend in just a few lines of code.

Although there is an abundance of python weather packages and APIs in the Python ecosystem (e.g. python-weather, weather-forecast), this particular package looks at specifically air pollution data and uses the Air Pollution API from OpenWeather. This is a unique package which provides simple and easy to use functions and allows users to quickly access and visualise data.

The data returned from the API includes the polluting gases such as Carbon monoxide (CO), Nitrogen monoxide (NO), Nitrogen dioxide (NO2), Ozone (O3), Sulphur dioxide (SO2), Ammonia (NH3), and particulates (PM2.5 and PM10).

Using the OpenWeatherMap API requires sign up to gain access to an API key.
For more information about API call limits and API care recommendations please visit the OpenWeather how to start page.

Functions

This package contains 3 functions:

  • get_air_pollution()
  • get_pollution_history()
  • get_pollution_forecast()

get_air_pollution()

Fetches the air pollution levels based on a location. Based on the values of the polluting gases, this package uses the Air Quality Index to determine the level of pollution for the location and produces a coloured map of the area displaying the varying regions of air quality.

get_pollution_history()

Requires a start and end date and fetches historic air pollution data for a specific location. The function returns a data frame with the values of the polluting gases over the specified date range.

get_pollution_forecast()

Fetches air pollution data for the next 5 days for a specific location. The function returns a time series plot of the predicted pollution levels.

Installation

$ pip install airpyllution

Usage and Example

readthedocs

  1. Create an OpenWeather API Key
  2. Install airpyllution
  3. Refer to ReadTheDocs for a usage guide and examples.

To use the package, import the package with the following commands:

from airpyllution.airpyllution import get_air_pollution
from airpyllution.airpyllution import get_pollution_history
from airpyllution.airpyllution import get_pollution_forecast

Retrieve historic pollution data with specified date range and location:

get_pollution_history(1606488670, 1606747870, 49.28, 123.12, api_key)

Generate an interactive map containing current pollution data by location:

get_air_pollution(49.28, 123.12, api_key, "Current Air Pollution")

Generate a time-series line chart of forecasted air pollution data:

import altair as alt
alt.renderers.enable("html");

get_pollution_forecast(49.28, 123.12, api_key)

Contributors

  • Christopher Alexander (@christopheralex)
  • Daniel King (@danfke)
  • Mel Liow (@mel-liow)

Contributing

Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.

License

airpyllution was created by Christopher Alexander, Daniel King, Mel Liow. It is licensed under the terms of the Hippocratic License 3.0.

Credits

airpyllution was created with cookiecutter and the py-pkgs-cookiecutter template.

Metadata

Release files for airpyllution 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for airpyllution 2.0.1
File Size Uploaded
airpyllution-2.0.1.tar.gz 14.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for airpyllution 2.0.1
File Interpreter ABI Platform
airpyllution-2.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 28.1 kB

Release files / airpyllution-2.0.1.tar.gz

Download URL airpyllution-2.0.1.tar.gz
Size 14.0 kB
Tags Source
SHA-256 checksum
How to use checksums
020e9503f71dbfb0a6cf15e193a2650119853097cb29e3197bbcf49324dd3d03
BLAKE2b-256 checksum
How to use checksums
2c2f19d6120226b742732355f320b65fae8579197d6a59d3ef7b24ce8f0b0fcc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Release files / airpyllution-2.0.1-py3-none-any.whl

Download URL airpyllution-2.0.1-py3-none-any.whl
Size 14.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0da433c8cf834cbfafcf0bacd701c3c2bc5f11800248207dcddaa837d71ab1e7
BLAKE2b-256 checksum
How to use checksums
9a95dd1d64188a58b7e868ca51c2539acf35618ba090b3019760734295bc92be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Release history Release notifications | RSS feed

This release

2.0.1 This release

2 release files

2.0.0

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page