Open RocketD0g opened 6 years ago
Here's a python library I found that does AQI conversion: https://github.com/hrbonz/python-aqi The EPA document version is from 2013 though, not sure how outdated it is.
Here is a Kotlin (100% interoperable with Java) library and CLI I work on, still WIP > https://github.com/thegrxp/Aqi-Kotlin
And here's a TypeScript library that does the conversion: https://github.com/shootismoke/common/tree/master/packages/convert 🚀
Thanks for sharing this, @amaurymartiny!
This issue provide specifications for building a US EPA-like* AQI Wrapper on top of the OpenAQ Platform for a single pollutant, such as PM2.5. This is also a community wish list item, which can be found here.
Access hourly PM2.5 data (or create hourly data from sub-hourly measurements).
Use the following equation for a given hourly value:
Above is from Page 11 here.
Above is from Page 13 here.
An example (with ozone):![screen shot 2017-11-17 at 5 43 19 pm](https://user-images.githubusercontent.com/13404290/32972216-18b388a0-cbbf-11e7-8004-ef54942ae7dc.png)
You can double check your work by using this simple calculator that converts back and forth from physical PM2.5 (in ug/m^3) to AQI.
*Important notes and caveats:
There are many types of Air Quality Indices that vary from country to country and are sometimes created by non-government entities, like app development companies. This focuses on a US-centric approach. Read more about AQI here.
This outline explains a single-pollutant calculation of AQI. See here. if you want to do multi-pollutant calculations for a US EPA-like or a US EPA AQI. An AQI system that takes a different approach to combining pollutants' health effects is the Canadian AQHI.
This outline explains how to convert raw, physical station-level data into a an hourly AQI based on hourly data, as calculated using US EPA methods, but not using the NowCast or full AQI that use the last 12 and 24 hours of data, respectively. This is done for simplicity's sake and timeliness. The NowCast method is not simple to calculate and less transparent what precisely what one is viewing. The normally-calculated AQI for PM2.5 is based on 24 hours of data, which is less timely though is based on health impacts. This method of calculating the 'hourly' AQI is not used by the EPA, though it is used by the US Embassy and US Consulates in China (see here)
For more information on calculating the NowCast AQI, see this explainer) for calculating the US EPA AirNow NowCast method for PM2.5 and O3.