Code Monkey home page Code Monkey logo

aqi-calculator's Introduction

Air Quality Index (AQI) Calculator

The package calculates AQI according to the Indian National AQI Standards. This can change in the future as per standards. This is just first version of AQI calculation and we are still awaiting a very standard and clear way of calculating AQI.

aqi-calculator is an NPM package that allows you to calculate Air Quality Index (AQI) with the help of pollutant concentrations ranging from PM2.5 PM10 SO2 NOX O3 CO.

Why aqi-calculator?

We make use of AQI calculations to power our air quality application (BreeZo) and its API. Therefore, we are making this independent calculator to set the same standard of calculation across all our applications.

Installation

Using Browser

<script src="https://unpkg.com/[email protected]/dist/aqi-calculator.min.js"></script>

Using NPM

npm install aqi-calculator

Client-Side Example - Browser

<!DOCTYPE html>
<html>
  <head>
    <title>Example AQI Calculator</title>
  </head>
  <body>
    <script src="https://unpkg.com/[email protected]/dist/aqi-calculator.min.js"></script>
    <script>
      var DATA = [
        {
          datetime: "2020-03-27T13:00:00.000Z", //Taking the 24-hour average concentration  - change when you use this example
          pm25: null,
          pm10: null,
          so2: null,
          no: null,
          nox: null,
          no2: null,
          o3: null,
          co: null,
        },
        {
          datetime: "2020-03-27T14:00:00.000Z", //Taking the 24-hour average concentration  - change when you use this example
          pm25: 294,
          pm10: 297,
          so2: 3,
          no: 32,
          nox: 41,
          no2: 18,
          o3: 63,
          co: null,
        },
        {
          datetime: "2020-03-27T15:00:00.000Z", //Taking the 24-hour average concentration  - change when you use this example
          pm25: 213,
          pm10: 275,
          so2: 5,
          no: 33,
          nox: 43,
          no2: 19,
          o3: 59,
          co: null,
        },
      ];

      var AQI = aqiCalculator(DATA);
      document.write(AQI);
    </script>
  </body>
</html>

Client-Side Example - React

import React from "react";
import aqiCalculator from "aqi-calculator";

const DATA = [
  {
    datetime: "2020-03-27T13:00:00.000Z", //Taking the 24-hour average concentration  - change when you use this example
    pm25: null,
    pm10: null,
    so2: null,
    no: null,
    nox: null,
    no2: null,
    o3: null,
    co: null,
  },
  {
    datetime: "2020-03-27T14:00:00.000Z", //Taking the 24-hour average concentration  - change when you use this example
    pm25: 294,
    pm10: 297,
    so2: 3,
    no: 32,
    nox: 41,
    no2: 18,
    o3: 63,
    co: null,
  },
  {
    datetime: "2020-03-27T15:00:00.000Z", //Taking the 24-hour average concentration  - change when you use this example
    pm25: 213,
    pm10: 275,
    so2: 5,
    no: 33,
    nox: 43,
    no2: 19,
    o3: 59,
    co: null,
  },
];

const AQIComponent = () => {
  const AQI = aqiCalculator(DATA);
  return AQI;
};

export default AQIComponent;

Server-Side Example - NodeJs

const aqiCalculator = require("aqi-calculator");

const DATA = [
  {
    datetime: "2020-03-27T13:00:00.000Z", //Taking the 24-hour average concentration  - change when you use this example
    pm25: null,
    pm10: null,
    so2: null,
    no: null,
    nox: null,
    no2: null,
    o3: null,
    co: null,
  },
  {
    datetime: "2020-03-27T14:00:00.000Z", //Taking the 24-hour average concentration  - change when you use this example
    pm25: 294,
    pm10: 297,
    so2: 3,
    no: 32,
    nox: 41,
    no2: 18,
    o3: 63,
    co: null,
  },
  {
    datetime: "2020-03-27T15:00:00.000Z", //Taking the 24-hour average concentration  - change when you use this example
    pm25: 213,
    pm10: 275,
    so2: 5,
    no: 33,
    nox: 43,
    no2: 19,
    o3: 59,
    co: null,
  },
];

const AQI = aqiCalculator(DATA);
console.log(AQI);

aqi-calculator's People

Contributors

srijitcoder avatar kshitijpurwar avatar restyled-commits avatar jashanbhullar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.