Skip to main content

A library to convert between AQI value and pollutant concentration (µg/m³ or ppm) using the following algorithms:

  • United States Environmental Protection Agency (EPA)

  • China Ministry of Environmental Protection (MEP)

Testing Status Documentation Status license BSD 3-Clause

Install

$ pip install python-aqi

Usage

Library

Convert a pollutant to its IAQI (Intermediate Air Quality Index):

import aqi
myaqi = aqi.to_iaqi(aqi.POLLUTANT_PM25, '12', algo=aqi.ALGO_EPA)

Get an AQI out of several pollutant concentrations, default algorithm is EPA:

import aqi
myaqi = aqi.to_aqi([
    (aqi.POLLUTANT_PM25, '12'),
    (aqi.POLLUTANT_PM10, '24'),
    (aqi.POLLUTANT_O3_8H, '0.087')
])

Convert an IAQI to its pollutant concentration:

import aqi
mycc = aqi.to_cc(aqi.POLLUTANT_PM25, '22', algo=aqi.ALGO_EPA)

Command line

List supported algorithms and pollutants:

$ aqi -l
aqi.algos.epa: pm10 (µg/m³), o3_8h (ppm), co_8h (ppm), no2_1h (ppb), o3_1h (ppm), so2_1h (ppb), pm25 (µg/m³)
aqi.algos.mep: no2_24h (µg/m³), so2_24h (µg/m³), no2_1h (µg/m³), pm10 (µg/m³), o3_1h (µg/m³), o3_8h (µg/m³), so2_1h (µg/m³), co_1h (mg/m³), pm25 (µg/m³), co_24h (mg/m³)

Convert PM2.5 to IAQI using EPA algorithm:

$ aqi aqi.algos.epa pm25:12
50

Convert PM2.5 to IAQI using EPA algorithm (full length):

$ aqi -c aqi aqi.algos.epa pm25:12
50

Convert pollutants concentrations to AQI using EPA algorithm:

$ aqi aqi.algos.epa pm25:40.9 o3_8h:0.077 co_1h:8.4
114

Convert pollutants concentrations to AQI using EPA algorithm, display IAQIs:

$ aqi -v aqi.algos.epa pm25:40.9 o3_8h:0.077 co_1h:8.4
pm25:102 o3_8h:104 co_1h:90
114

Convert PM2.5 IAQI to concentration using EPA algorithm:

$ aqi -c cc aqi.algos.epa pm25:39
pm2.5:9.3

Development

To install the development environment:

$ pip install -r dev_requirements.txt

Test

Test the package:

$ python -m unittest discover

Automatic testing in various environments:

$ tox

Release

Use bumpr to release the package:

$ bumpr -b -m

Project

Resources

License

python-aqi is published under a BSD 3-clause license, see the LICENSE file distributed with the project.

Release files for python-aqi 0.6.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 python-aqi 0.6.1
File Size Uploaded
python-aqi-0.6.1.tar.gz 9.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-aqi 0.6.1
File Interpreter ABI Platform
python_aqi-0.6.1-py2-none-any.whl Python 2 none any Details

Total release size: 20.2 kB

Release files / python-aqi-0.6.1.tar.gz

Download URL python-aqi-0.6.1.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
141a03a0fed48880dc8706ca57b03f30fa91ab60e9330474bf9c9a8fb9b96020
BLAKE2b-256 checksum
How to use checksums
418942266c6fb056ef52776effba731acaf2bf3b564f7845ef970918ee9f68f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.18.4 setuptools/36.5.0 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/2.7.13

Release files / python_aqi-0.6.1-py2-none-any.whl

Download URL python_aqi-0.6.1-py2-none-any.whl
Size 11.1 kB
Tags Python 2
SHA-256 checksum
How to use checksums
325ff7a76b66b9045e042c8086e4debd1422079b9a72cc5a072951a67b344904
BLAKE2b-256 checksum
How to use checksums
f0612962b405ef1a1663c8d5fc8f888118fe6d123c63c93f0245d94b03defc31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.18.4 setuptools/36.5.0 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/2.7.13

Release history Release notifications | RSS feed

This release

0.6.1 This release

2 release files

0.5.1

3 release files

0.5.0

2 release files

0.4.2

2 release files

0.4.1

0.4

0.3

0.2

0.1

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