Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ A library to convert between AQI value and pollutant concentration

* United States Environmental Protection Agency (EPA)
* China Ministry of Environmental Protection (MEP)
* European Common Air Quality Index (CAQI)

.. image:: https://travis-ci.org/hrbonz/python-aqi.svg?branch=master
:target: https://travis-ci.org/hrbonz/python-aqi
Expand Down Expand Up @@ -128,6 +129,7 @@ Resources
* GB3095—2012 (2012/02/29) found at http://www.mep.gov.cn/gkml/hbb/bwj/201203/t20120302_224147.htm
* HJ633-2012 (2012/02/29) found at http://www.zzemc.cn/em_aw/Content/HJ633-2012.pdf

* CAQI: CAQI Air quality index https://www.airqualitynow.eu/download/CITEAIR-Comparing_Urban_Air_Quality_across_Borders.pdf

License
=======
Expand Down
3 changes: 2 additions & 1 deletion aqi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from aqi.constants import (POLLUTANT_PM25, POLLUTANT_PM10,
POLLUTANT_O3_8H, POLLUTANT_O3_1H,
POLLUTANT_CO_8H, POLLUTANT_SO2_1H,
POLLUTANT_NO2_1H, ALGO_EPA, ALGO_MEP)
POLLUTANT_NO2_1H, ALGO_EPA, ALGO_MEP,
ALGO_CAQI)

from aqi.algos import get_algo, list_algos

Expand Down
82 changes: 82 additions & 0 deletions aqi/algos/caqi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# -*- coding: utf-8 -*-

from decimal import *

from aqi.constants import (POLLUTANT_PM25, POLLUTANT_PM10,
POLLUTANT_O3_1H, POLLUTANT_CO_8H, POLLUTANT_SO2_1H,
POLLUTANT_NO2_1H)
from aqi.algos.base import PiecewiseAQI


class AQI(PiecewiseAQI):
"""Implementation of the CAQI algorithm.
"""

piecewise = {
'aqi': [
(Decimal(0), Decimal(24.99)),
(Decimal(25), Decimal(49.99)),
(Decimal(50), Decimal(74.99)),
(Decimal(75), Decimal(99.99)),
(Decimal(100), Decimal(1000))],
'bp': {
POLLUTANT_NO2_1H: [
(Decimal('0'), Decimal('49.99')),
(Decimal('50'), Decimal('99.99')),
(Decimal('100'), Decimal('199.99')),
(Decimal('200'), Decimal('399.99')),
(Decimal('400'), Decimal('inf')),
],
POLLUTANT_O3_1H: [
(Decimal('0.0'), Decimal('60.000')),
(Decimal('60.001'), Decimal('120.000')),
(Decimal('120.001'), Decimal('180.000')),
(Decimal('180.001'), Decimal('240.000')),
(Decimal('240.001'), Decimal('inf')),
],
POLLUTANT_PM10: [
(Decimal('0'), Decimal('25')),
(Decimal('25.01'), Decimal('50')),
(Decimal('50.01'), Decimal('90')),
(Decimal('90.01'), Decimal('180')),
(Decimal('180.01'), Decimal('inf')),
],
POLLUTANT_PM25: [
(Decimal('0.0'), Decimal('15.0')),
(Decimal('15.01'), Decimal('30.0')),
(Decimal('30.01'), Decimal('55.0')),
(Decimal('55.01'), Decimal('110.0')),
(Decimal('110.01'), Decimal('inf')),
],
POLLUTANT_CO_8H: [
(Decimal('0.0'), Decimal('5000.0')),
(Decimal('5000.01'), Decimal('7500.0')),
(Decimal('7500.01'), Decimal('10000.0')),
(Decimal('10000.01'), Decimal('20000.0')),
(Decimal('20000.01'), Decimal('inf')),
],
POLLUTANT_SO2_1H: [
(Decimal('0'), Decimal('50')),
(Decimal('50.01'), Decimal('100')),
(Decimal('100.01'), Decimal('350')),
(Decimal('350.01'), Decimal('500')),
(Decimal('500.01'), Decimal('inf')),
],
},
'prec': {
POLLUTANT_O3_1H: Decimal('.001'),
POLLUTANT_PM10: Decimal('.1'),
POLLUTANT_PM25: Decimal('.1'),
POLLUTANT_CO_8H: Decimal('.1'),
POLLUTANT_SO2_1H: Decimal('1.'),
POLLUTANT_NO2_1H: Decimal('1.'),
},
'units': {
POLLUTANT_O3_1H: 'µg/m³',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are those units correct? O3, CO, SO2, NO2 are traditionally measured in ppm/ppb

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

POLLUTANT_PM10: 'µg/m³',
POLLUTANT_PM25: 'µg/m³',
POLLUTANT_CO_8H: 'µg/m³',
POLLUTANT_SO2_1H: 'µg/m³',
POLLUTANT_NO2_1H: 'µg/m³',
},
}
1 change: 1 addition & 0 deletions aqi/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
# constants for algorithms, canonical module name
ALGO_EPA = 'aqi.algos.epa'
ALGO_MEP = 'aqi.algos.mep'
ALGO_CAQI = 'aqi.algos.caqi'