npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aqi-bot

v1.1.4

Published

AQI Bot provide a detail result from AQI Calculation. It also support Nowcast calculation.

Downloads

162

Readme

NPM 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 ( #soon in the next release )

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 | :heavy_check_mark:| :heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:| | PM2.5 | 2.5 μm Particle Pollutant | μg/m3| PM2.5 | :heavy_check_mark:| :heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:| | O3 | Ozone | ppb| O3 | :heavy_check_mark:| :heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:| | CO | Carbon Monoxide | ppb| CO | :heavy_check_mark:|:x:|:heavy_check_mark:|:heavy_check_mark:| | SO2 | Sulfur Dioxide | ppb| SO2 | :heavy_check_mark:| :x:|:heavy_check_mark:|:heavy_check_mark:| | NO2 | Nitrogen Dioxide | ppb| NO2 | :heavy_check_mark:| :x:|:heavy_check_mark:|:heavy_check_mark:|

Installation

npm install aqi-bot --save

Extract the aqi-bot to use it

let aqibot = require('aqi-bot');

Quick Usage

For Regular AQI Calculation

2 required parameter is pollutant code and concentration

aqibot.AQICalculator.getAQIResult("PM10", 125).then((result) => {
    console.log(result);
  }).catch(err => {
    console.log(err);
  })

Or you might use the pollutant code constants from the aqibot: aqibot.AQICalculator.getAQIResult(aqibot.PollutantType.PM10, concentration)

And the result object there contains all the information that you need

{
    "pollutant": "PM10",
    "concentration": "125",
    "aqi": 86,
    "category": "Moderate",
    "generalMessage": "Unusually sensitive people should consider reducing prolonged or heavy outdoor exertion",
    "healthEffectsStatements": "Respiratory symptoms possible in unusually sensitive individuals; possible aggravation of heart or lung disease in people with cardiopulmonary disease and older adults",
    "guidanceStatement": "Unusually sensitive people should consider reducing prolonged or heavy exertion"
}

For Nowcast AQI Calculation

/* Example Data for Nowcast PM2.5 12h period - 30.5, 12.5, 14.3, 30, 32.4, 31.1, 28.2, 30.7, 32.8, 32.6, 33.1, 28.5 */

let concentrationData = [30.5, 12.5, 14.3, 30, 32.4, 31.1, 28.2, 30.7, 32.8, 32.6, 33.1, 28.5];

AQIBot.AQICalculator.getNowcastAQIResult(PollutantType.PM25, concentrationData).then((result)=>{
  console.log(result);
}).catch(err =>{
  console.log(err);
})

Please note that the concentration in result object here is the Nowcast Concentration

{
    "pollutant": "PM2.5",
    "concentration": 24,
    "aqi": 76,
    "category": "Moderate",
    "generalMessage": "Unusually sensitive people should consider reducing prolonged or heavy outdoor exertion",
    "healthEffectsStatements": "Respiratory symptoms possible in unusually sensitive individuals; possible aggravation of heart or lung disease in people with cardiopulmonary disease and older adults",
    "guidanceStatement": "Unusually sensitive people should consider reducing prolonged or heavy exertion"
}

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

  let concentrationData = [ 64, 63, -1, 77, 65, -1, 70, 71, -1, 57, 58, 64 ];

  AQIBot.AQICalculator.getNowcastAQIResult(PollutantType.PM10, concentrationData).then((result)=>{
    console.log(result);
  }).catch(err =>{
    console.log(err);
})
{
    "pollutant": "PM10",
    "concentration": 66,
    "aqi": 56,
    "category": "Moderate",
    "generalMessage": "Unusually sensitive people should consider reducing prolonged or heavy outdoor exertion",
    "healthEffectsStatements": "Respiratory symptoms possible in unusually sensitive individuals; possible aggravation of heart or lung disease in people with cardiopulmonary disease and older adults",
    "guidanceStatement": "Unusually sensitive people should consider reducing prolonged or heavy exertion"
}

AQI Calculation Turtorial

US EPA AQI Breakpoint

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:
  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.  

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.

Nowcast Rules

Handling Missing data

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

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