Air Quality Index

Air quality index is calculated from the value of a pollutant concentration (pm2.5, pm10) and a table representing quality based on a standard. Each country has their own guidelines. For example, India’s ‘Poor’ category is equivalent to ‘Unhealthy’ in the US. It’s also interesting that it’s framed as pollution on India and China, but it’s framed as a health concern in the US.

Example of calculating air quality index using python for pm2.5 with the EPA’s breakpoints:

PM25_CONCENTRATION = 70.0

# A lookup table of concentration high, low, index high, low, and label
PM25_CATEGORIES = [
    (0.0, 12.0, 0, 50, "good"),
    (12.1, 35.4, 51, 100, "moderate"),
    (35.5, 55.4, 101, 150, "unhealthy for sensitive groups"),
    (55.5, 150.4, 151, 200, "unhealthy"),
    (150.5, 250.4, 201, 300, "very unhealthy"),
    (250.5, 350.4, 301, 400, "hazardous"),
    (350.5, 500.4, 401, 500, "hazardous"),
]

# Find the breakpoints using the table
if PM25_CONCENTRATION > 500.4:
    category = PM25_CATEGORIES[-1]
else:
    category = None
    for c in PM25_CATEGORIES:
        low, high, *_ = c
        if PM25_CONCENTRATION >= low and PM25_CONCENTRATION <= high:
            category = c
            break

c_low, c_high, i_low, i_high, _ = category

aqi = ((i_high - i_low) / (c_high - c_low)) * (PM25_CONCENTRATION - c_low) + i_low
aqi = round(aqi)

print(f"The air quality index is {aqi}")
The air quality index is 158
  • Measure Aqi Using the Sds011 Sensor

    The Nova SDS011 sensor is an inexpensive ($30) air quality sensor that uses laser scattering to detect particles at 2.5 and 10 nanometers (PM2.5 and PM10 respectively). By taking the concentration of particles you can calculate the air quality index.