Skip to main content

aqicalc

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)

  • Central Pollution Control Board (CPCB) India

Forked from python-aqi library

Changes from the original library

  • Added CPCB AQI Calculation

  • Added IEMA Brazil AQI Calculation

  • Added Kuwait AQI

  • Added Unit Conversion Functions

  • Added Exception Handling (returns the number or NaN back if it can’t convert)

license BSD 3-Clause

Install

$ pip install aqicalc

Usage

Library

NOTE: Different standards use different units for calculating AQI, use the appropriate units to get correct results. Examples for getting the units for each standards as well as unit conversion is avaiable (examples soon!)

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

import aqicalc as 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 aqicalc as 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 aqicalc as 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

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

Metadata

Release files for aqicalc 0.0.8.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 aqicalc 0.0.8.1
File Size Uploaded Provenance Actions
aqicalc-0.0.8.1.tar.gz 12.5 kB Without provenance Details for aqicalc-0.0.8.1.tar.gz

Built distribution (wheel)

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

Total release size: 25.9 kB

Release files / aqicalc-0.0.8.1.tar.gz

Download URL aqicalc-0.0.8.1.tar.gz
Size 12.5 kB
Tags Source
SHA-256 checksum
How to use checksums
bf8c43fc20b4c0d610ecc0dff1f4ba301e9bf91460b4cab0eac51b61a25af24b
BLAKE2b-256 checksum
How to use checksums
17468469fa89075ab91afd46682326b623d2541d4d2aa05cf6f088d59934140b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Release files / aqicalc-0.0.8.1-py3-none-any.whl

Download URL aqicalc-0.0.8.1-py3-none-any.whl
Size 13.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
12d3b97a0d9de2b6d1c973f47c6e26b19e2cc8b63ae9ff8dc614c7ed1ac92c65
BLAKE2b-256 checksum
How to use checksums
4948aa0148956b1c4d9e9fd0a065520455db7d62dab758db7029325523e95a83
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Security for aqicalc 0.0.8.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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