Skip to content

A Maven Project Air Quality Index Calculator using US EPA Formula, which support AQI for pollutant, and also with Nowcast AQI

License

Notifications You must be signed in to change notification settings

jiaanliux/aqi-calculator

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation




Maven AQI Calculator

Foreword

All methods, constraints use in this project follows US EPA AQI Calculation Method (which includes breakpoint table and calculation formulas) . Since each country issues different AQI calculation methods, using this package might be inappropriate, consider your usage.

This project is intended to community target for free use. The author is not associated with USA government, nor United States Environmental Protection Agency (a.k.a US EPA)

Highlights

  • Calculate AQI from raw concentration
  • The result from calculation includes Air Quality Index, AQI Category, General Message, Specific Health Effects Statements for the pollutant and the corresponding guidance message.
  • Support Nowcast Concentration

Support the following pollutants

Pollutant Scientific name Unit of Measurement Input Code Usage Regular Calculation Support Nowcast Support Health Effects Statements Guidance Message
PM10 10 μm Particle Pollutant μg/m3 PM10 ✔️ ✔️ ✔️ ✔️
PM2.5 2.5 μm Particle Pollutant μg/m3 PM2.5 ✔️ ✔️ ✔️ ✔️
O3 Ozone ppb O3 ✔️ ✔️ ✔️ ✔️
CO Carbon Monoxide ppb CO ✔️ ✔️ ✔️
SO2 Sulfur Dioxide ppb SO2 ✔️ ✔️ ✔️
NO2 Nitrogen Dioxide ppb NO2 ✔️ ✔️ ✔️

Installation

Using Maven Dependency

<!-- https://mvnrepository.com/artifact/com.github.thanglequoc/aqi-calculator -->
<dependency>
    <groupId>com.github.thanglequoc</groupId>
    <artifactId>aqi-calculator</artifactId>
    <version>1.2.2</version>
</dependency>

Or for other stuff like Gradle, SBT, Ivy,.. you may find it on Maven Central Repository

Using Plug-n-play jar file:

Grab the target jar in target-jar folder and add the jar to your project.

Quick Usage

For Regular AQI Calculation

Using old method (it only give you plain AQI, and nothing more):

@Obsoleted: getAQIforPollutant is obsoleted and will be removed in the near future. Consider using AQIResult object insteads

AQICalculator calculator = AQICalculator.getAQICalculatorInstance();
calculator.getAQIforPollutant("PM10", 134.12);

90

Using AQIResult Object (new replacement, AQI now comes in more detail 💪 ):
AQICalculator calculator = AQICalculator.getAQICalculatorInstance();
AQIResult result = calculator.getAQI("PM10", 99);

Now AQIResult store all the related information that you might need, query them by the following methods

  • Get the Air Quality Index (AQI)

result.getAqi();

73

  • Get the AQI Category

result.getCategory();

Moderate

  • Get the general message of the AQI Category

result.getGeneralMessage();

Unusually sensitive people should consider reducing prolonged or heavy outdoor exertion

  • Get the health effects statement for the pollutant with that level

result.getHealthEffectsStatement();

Respiratory symptoms possible in unusually sensitive individuals; possible aggravation of heart or lung disease in people with cardiopulmonary disease and older adults

  • Get the guidance message for the pollutant with that level

result.getGuidanceStatement();

Unusually sensitive people should consider reducing prolonged or heavy exertion

For Nowcast AQI Calculation

/* Example Data for Nowcast PM10 12h period - 64, 63, 72, 77, 65, 61, 70, 71, 64, 57, 58, 64 */
AQICalculator calculator = AQICalculator.getAQICalculatorInstance();

double[] data = { 64, 63, 72, 77, 65, 61, 70, 71, 64, 57, 58, 64 };`
AQIResult result = calculator.getNowcastAQI("PM10", data);

result.getAqi();

57

The first value in the array is the avg value in the current hour, and the upcoming element in the array represent one step hour before current hour.

If the hour doesn't have data, replace missing data in the hour with -1

Example Nowcast Dataset for PM10: (have some missing data in hour)
Hour Avg Concentration
14 64 ppb
13 63 ppb
12 ----
11 77 ppb
10 65 ppb
9 ----
8 70 ppb
7 71 ppb
6 ----
5 57 ppb
4 58 ppb
3 64 ppb

Presume that you want to calculate Nowcast AQI for PM10 at 14, the data array should be

double[] data = { 64, 63, -1, 77, 65, -1, 70, 71, -1, 57, 58, 64 };`
AQIResult result = calculator.getNowcastAQI("PM10", data);
result.getAqi();

56

AQI Calculation Turtorial

US EPA AQI Breakpoint

2017_07_20_15_22_21

Image from Wikipedia

Calculation Formula

The AQI is the highest value calculated for each pollutant as follows:

  1. Identify the highest concentration among all of the monitors within each reporting area and truncate as follows:

2017_07_20_15_27_19

  1. Using US EPA AQI Breakpoint, find the two breakpoints that contain the concentration.
  2. Using AQI Equation , calculate the index.
  3. Round the index to the nearest integer.  

2017_07_20_15_25_59

Nowcast for PM and Ozone

The concentration of PM10, PM2.5 is so dynamic since wind can completely clean the air in less than 30 minutes, or a wildfire can raise the concentration with a very fast rate in an hour. So Nowcast is introduced, it mainly focus on detect the average changing of the period hour and perform counter balancing.

2017_07_20_15_30_08

Nowcast Rules

image

Handling Missing data

To compute a valid NowCast, you must have at least two of the most recent 3 hours

image

Extra Documents and Tools that you might needs

Air Now AQI Calculator: Concentration to AQI

Air Now Nowcast Calculator

Daily and Hourly AQI - PM2.5 and PM10

Daily and Hourly AQI - PM2.5 and PM10

US EPA AQI Brochure

US EPA AQI Technical Assistance Document

US EPA Nowcast Overview

Demonstration images for nowcast in this tutorial are from US EPA Nowcast Overview document

About

A Maven Project Air Quality Index Calculator using US EPA Formula, which support AQI for pollutant, and also with Nowcast AQI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%