Categorygithub.com/mrflynn/go-aqi
modulepackage
0.0.9
Repository: https://github.com/mrflynn/go-aqi.git
Documentation: pkg.go.dev

# README

go-aqi tests

Calculate the air quality index (AQI) from different particulate concentrations. The method for calculating AQI is based on the Environmental Protection Agency's (United States) table method for calculating AQI. Other countries' AQI calculation methods might come in the future, but this might require some rethinking of how this library is currently written.

Currently this library supports the following measurements:

  • PM2.5
  • PM10
  • Carbon Monoxide
  • Sulfur Dioxide
  • Nitrogen Dioxide

Ozone is another measurement that I would like to add, but calculating AQI from ozone is slightly more complicated compared to the other particulate measures.

Installation

go get -u github.com/mrflynn/go-aqi

Example

Here is an example for calculating AQI from multiple particulate measurements.

package main

import (
	"fmt"

	"github.com/mrflynn/go-aqi"
)

func main() {
	results, err := aqi.Calculate(aqi.PM25{20.2}, aqi.CO{4.1}, aqi.NO2{67.6})
	if err != nil {
		fmt.Prinln(err)
		return
	}

	fmt.Printf(
		"The air quality is %s with an AQI of %.3f\n",
		results.Index.Name,
		results.AQI,
	)
}

A toy CLI application can be found in the examples/ folder.

Contributing

Contributions are welcome. Create a pull request and I'll take a look at it whenever I have some time.

Make sure to include unit tests in your pull requests.

License

MIT

# Packages

No description provided by the author

# Functions

Calculate determines the AQI from the given measurements.

# Variables

Default indices for all EPA AQI levels, each containing their level's respective metadata.
Default indices for all EPA AQI levels, each containing their level's respective metadata.
Default indices for all EPA AQI levels, each containing their level's respective metadata.
Default indices for all EPA AQI levels, each containing their level's respective metadata.
Default indices for all EPA AQI levels, each containing their level's respective metadata.
Default indices for all EPA AQI levels, each containing their level's respective metadata.
Default indices for all EPA AQI levels, each containing their level's respective metadata.

# Structs

CO contains concentration measurements for carbon monoxide in air in parts per million.
Index represents the different levels of AQI (i.e good, moderate, etc.) with associated metadata.
NO2 contains concentration measurements for nitrogen dioxide in air in parts per billion.
PM10 contains concentration measurements for PM10 particulates in air in micrograms per meter cubed.
PM25 contains concentration measurements for PM2.5 particulates in air in micrograms per meter cubed.
Result contains the AQI one of the predefined Index values.
SO2 ontains concentration measurements for sulfur dioxide measurements in air in parts per billion.

# Interfaces

Measurement type are the functions require to calculate the AQI value.