davidcarslaw / openair

Tools for air quality data analysis
https://davidcarslaw.github.io/openair/
GNU General Public License v2.0
304 stars 113 forks source link

Calculating Number of Exceedances #23

Closed AlanMcDonaldSEPA closed 9 years ago

AlanMcDonaldSEPA commented 9 years ago

I would like to calculate the number of exceedances at several monitoring stations, and I wondered if there was a function in OpenAir that would do that for multiple years and sites for the appropriate averaging period (similar to the CalculatePercentile function)? I was able to do this using a subset of data for each year for each monitoring site, but this was taking a while.

For example number of hours that the hourly NO2 concentration was greater than 200 ug/m3 or number of days the PM10 concentration was greater than 50 ug/m3.

Many Thanks

davidcarslaw commented 9 years ago

Yes, there is a function in openair called aqStats - which is not mentioned in the manual at the moment. However, the help file is up to date. I just noticed a bug when there are multiple sites, which should now be fixed. Have a look at the installation instructions here https://github.com/davidcarslaw/openair where I have also put links to pre-compiled packages.

Here is an example:

dat <- importAURN(site = c("kc1", "my1"), year = 2014)
aqStats(dat, pollutant = "no2")
                    site pollutant year       date  dat.cap     mean minimum  maximum   median daily.max
1   London N. Kensington       NO2 2014 2014-01-01 97.47717 34.38203 0.98972 173.7325 29.79484  97.93662
2 London Marylebone Road       NO2 2014 2014-01-01 98.72146 93.61623 8.26678 245.9528 87.82678 155.67198
  max.roll.8 max.roll.24 percentile.95 percentile.99 hours
1   114.2191    104.5261      73.75843      91.62118     0
2   215.9092    161.0016     165.89121     195.51105    64
Warning message:
In rbind_all(out[[1]]) : Unequal factor levels: coercing to character

(the warning message is harmless and I need to deal with that - due to updates in another package)

AlanMcDonaldSEPA commented 9 years ago

Great, this is what I was looking for and the updated version works a treat.

Many Thanks