Git Product home page Git Product logo

sg-hazometer's Introduction

The Singapore Hazometer is a simple npm module allowing for easy retrieval of pollutant data from data.gov.sg, which is in turn sourced from NEA.

`node demo.js`

Demo

const hazometer = require("sg-hazometer")
const apiKey = "xxx" // get one here https://developers.data.gov.sg
	
hazometer.getInfo({apiKey}, function(err, data){
	console.log(data)
})

You'll get something like the following:

{
	summary: 'healthy',
	last_update: 2017 - 02 - 09 T14: 00: 00.000 Z,
	east: {
		dailyPM10: 32,
		dailyPM25: 20,
		'8hCO': 0.27,
		'2hNO2': 15,
		dailySO2: 3,
		'8hO3': 56,
		'3hPSI': 53,
		dailyPSI: 60,
		location: {
			latitude: 1.35735,
			longitude: 103.94
		}
	},
	central: {
		dailyPM10: 29,
		dailyPM25: 19,
		'8hCO': 0.58,
		'2hNO2': 60,
		dailySO2: 5,
		'8hO3': 58,
		'3hPSI': 59,
		dailyPSI: 59,
		location: {
			latitude: 1.35735,
			longitude: 103.82
		}
	},
	south: {
		dailyPM10: 28,
		dailyPM25: 18,
		'8hCO': 0.52,
		'2hNO2': 60,
		dailySO2: 137,
		'8hO3': 57,
		'3hPSI': 59,
		dailyPSI: 61,
		location: {
			latitude: 1.29587,
			longitude: 103.82
		}
	},
	north: {
		dailyPM10: 33,
		dailyPM25: 21,
		'8hCO': 0.4,
		'2hNO2': 20,
		dailySO2: 11,
		'8hO3': 63,
		'3hPSI': 56,
		dailyPSI: 61,
		location: {
			latitude: 1.41803,
			longitude: 103.82
		}
	},
	west: {
		dailyPM10: 30,
		dailyPM25: 17,
		'8hCO': 0.78,
		'2hNO2': 39,
		dailySO2: 4,
		'8hO3': 77,
		'3hPSI': 40,
		dailyPSI: 56,
		location: {
			latitude: 1.35735,
			longitude: 103.7
		}
	},
	national: {
		dailyPM10: 33,
		dailyPM25: 21,
		'8hCO': 0.78,
		'2hNO2': 60,
		dailySO2: 137,
		'8hO3': 77,
		'3hPSI': 55,
		dailyPSI: 61,
		location: {
			latitude: 0,
			longitude: 0
		}
	}
}

FAQ

What do all these terms mean?

summary: human-readable assessment of current air quality (see this)

dailyPM10: 24h readings for particulate matter 10 micrometers or less in diameter

dailyPM25: ditto, but for particulate matter 2.5 micrometers or less in diameter

8hCO: 8h readings for Carbon Monoxide levels

2hNO2: 2h readings for Nitrogen Dioxide levels

dailySO2: 24h readings for Sulfur Dioxide levels

8hO3: 8h readings for Ozone levels

3hPSI: 3h readings for the NEA-released Particulate Matter Index (PSI)

dailyPSI: ditto but every 24h

location: coordinates of the points at which the readings are taken at

Why don't the dateTime or date parameters seem to do anything?

The data.gov.sg API seems to be faulty.

Why is data on pollution sub-indexes not included?

The Pollutant Standards Index (PSI) is calculated from sub-indexes using a formula detailed here. This module retrieves the raw data that is used to calculate the index, that is then used to calculate the overall PSI. Unless you plan to check NEA's mathematics, it's unlikely the sub-index itself will be of any interest.

sg-hazometer's People

Contributors

hueyy avatar

Watchers

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