@shootismoke/aqi
v0.1.15
Published
Easily convert between US AQI, CN AQI and raw concentrations in ug/m3
Downloads
2
Readme
@shootismoke/aqi
A library to convert between AQI (US or CN) value and pollutant concentration (µg/m³ or ppm) using the following standards:
- US AQI: United States Environmental Protection Agency (EPA)
- CN AQI: China Ministry of Environmental Protection (MEP)
⚡ Get Started
Install the package
yarn install @shootismoke/aqi
aqiToRaw(pollutant: Pollutant, aqi: number, aqiType: AqiType = 'US'): number
Converts an AQI value to raw concentration (µg/m³ or ppm).
Arguments:
pollutant: Pollutant
: One of'co' | 'h' | 'no2' | 'o3' | 'p' | 'pm10' | 'pm25' | 'so2' | 't' | 'w'
aqi: number
: The AQI valueaqiType: AqiType
: One of'US' | 'CN'
import { aqiToRaw } from '@shootismoke/aqi';
const raw = aqiToRaw('pm25', 57, 'US');
console.log(raw); // 15
aqiToRaw(pollutant: Pollutant, raw: number, aqiType: AqiType = 'US'): number
Converts a raw concentration (µg/m³ or ppm) to AQI value.
Arguments:
pollutant: Pollutant
: One of'co' | 'h' | 'no2' | 'o3' | 'p' | 'pm10' | 'pm25' | 'so2' | 't' | 'w'
raw: number
: The raw concentrationaqiType: AqiType
: One of'US' | 'CN'
import { rawToAqi } from '@shootismoke/aqi';
const aqi = aqiToRaw('pm25', 15, 'US');
console.log(aqi); // 57
getUnit(pollutant: Pollutant): Unit
Gets the unit of a pollutant (µg/m³ or ppm).
Arguments:
pollutant: Pollutant
: One of'co' | 'h' | 'no2' | 'o3' | 'p' | 'pm10' | 'pm25' | 'so2' | 't' | 'w'
import { getUnit } from '@shootismoke/aqi';
const unit = getUnit('pm25');
console.log(unit); // 'µg/m³'
:raising_hand: Contribute
- Fork the repo
- Make your changes in your own fork
- Create a Pull Request on this repo
:microscope: Tests
Look out for *.spec.ts
in the codebase.
yarn test
:books: Resources
- EPA AQI: Technical Assistance Document for the Reporting of Daily Air Quality – the Air Quality Index (AQI) December 2013) found at http://www.epa.gov/airnow/aqi-technical-assistance-document-dec2013.pdf
- National Ambient Air Quality Standards for Particulate Matter found at http://www.gpo.gov/fdsys/pkg/FR-2013-01-15/pdf/2012-30946.pdf
- MEP AQI:
- 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
:newspaper: License
GPL-3.0. See LICENSE file for more information.