Openair R

Openair is a package created for the analysis of air pollution by David Carlslaw (University College London). Please find how it works from the official website and from the tutorial or manual package.

You will find many instructions available to create powerful graphs as for example timePlot(x), calendarPlot(x),summaryPlot(x)

You can also create an interactive graph by making use of C3.js library. In this example you can interact with air pollutant data found in Martorell from 2005 to 2016.

Data preparation

  • Name of Dates column must be dates
  • Convert dates into dates

>martorell$date<-as.Date(martorell$date, format=”%d/%m/%Y”, tz=”Europe/Madrid”)

class (martorell$date) “Date”

  • Convert factor to numeric values:

martorell$H2S<-as.numeric(levels(martorell$H2S))[martorell$H2S]

cutData()

selectByDate instruction:

We can conclude that there is less pollution during weekends according to available hour data from H2S levels in the period 01/12/2016 to 30/11/2017.

You can find some data from january 2018 to December18th, but you need to analyse the full year 2018

WORKING LOCALLY in a pendrive with R and RStudio:

  • install.packages (“openair”, lib=”F:/SOFTWARE/RStudio/libraries”)
  • library(“openair”, lib.loc=”F:/SOFTWARE/RStudio/libraries”)
  • setwd(“F://SOFTWARE/RStudio/Projects”)
  • getwd()
  • Review setwd and getwd to know the working directory

SET LANGUAGE TO ENGLISH

Sys.setlocale(“LC_ALL”, “English”)

CHECK CLASSES and use as.Date or as.POSIXct to work with dates (lubridate package can also help)

AIR POLLUTION IN MARTORELL 2017 EXAMPLE

  1. SummaryPlot example

summaryPlot(martorell)
date NO NO2 H2S
“Date” “integer” “integer” “numeric”

2. Calendar plot example

Sys.setenv(LANGUAGE=”en”)

>martorell<read.csv(file=”/Users/franciscoperezgarcia/Desktop/martorelld17.csv”)
> View(martorelld17)
> class(martorell$date)
[1] “factor”
> martorell$date<-as.Date(martorell$date, format=”%d/%m/%Y”)
> class(martorell$date)
[1] “Date”
> library(openair)
> calendarPlot(martorell,pollutant=”H2S”, year=”2017″)

 

 

2. timePlot example

timePlot(martorell, pollutant=c(“NO”, “NO2″,”H2S”))

> timePlot(martorell,pollutant=”NO”, year=”2017″)

timePlot(martorell, pollutant = c(“NO”, “NO2”, “H2S”),
+ avg.time = “month”, normalise = “01/08/2017”, lwd = 4, lty = 1,
+ group = TRUE, ylim = c(0, 700))

3. monthPlot example

monthplot(martorell$NO2, main=expression(paste(“2017 Month plot of Martorell NO”[2])), ylab=”Conc (ug/m3)”)

4. Episodes of air pollution in Martorell

Remember to convert ppb to microgram/m3

Pollution limits in other countries

Concerning H2S: 8h over 1.5 microgram/m3 (1ppm), 15 min over 7.5 microgram/m3 (5 ppm) according to ACGIH, 2010

ALERT: Values of H2S are in microgram/m3 and limits in Catalonia are 40 (24-hour mean) and 100 (30-min mean). Review the previous code accordingly.

Concerning NO2, criteria from EU Air Quality Standards and Air Quality Guidelines WHO 2011 limits

Remember to calculate 8-hour mean of ozone and other means (1h,8h,24h, annual,etc) of other air pollutants to find air pollution episodes in your city.

5. trendLevel

trendLevel(martorellh, pollutant=”H2S”)

6. smoothTrend

First, we choose to deseasonalise the data, then we choose to plot percentiles (the 5th, 50th, 75th and 95th)

7. Times series ts

8. timeVariation

Data from 2018 below

timeVariation(palau, pollutant=c(“NO”, “NO2″,”SO2″,”CO”, “PM10”, “O3”), main = expression(paste(“Air pollutants, “, mu, “g/m3″ at Barcelona-Palau Reial (2018)”)

timeVariation(palau, pollutant=c(“NO”, “NO2″,”SO2″,”CO”, “PM10”, “O3”), normalise = TRUE)

Next graphs are Air pollutant from Martorell in 2018:


Air pollution in Martorell: levels in NO (ug/m3)

Air pollution in Martorell: levels in H2S (ug/m3)


Air pollution in Martorell: levels in NO2 (ug/m3)