davidcarslaw / openair

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

CalcFno2 issues with daylight/nighttime #114

Open kailas29 opened 7 years ago

kailas29 commented 7 years ago

Hi David,

I am using the calcFno2 function, however, there is no difference in the plot when I am adding the option type = "daylight". My data is formated in a POSIXct format with tz="Europe/London"

Do you have any suggestions or it is a problem in the function?

Thanks

kailas29 commented 7 years ago

Even when I am changing date/time into GMT it gives me the same warning but still the plot is not changed. Below is the message

Warning: In checkPrep(mydata, unique(vars), type) : Detected data with Daylight Saving Time, converting to UTC/GMT

jack-davison commented 2 weeks ago

Can confirm this is unexpected behaviour. Not a function I've looked at much myself - @davidcarslaw perhaps one for you.

Interestingly, type works with non-hour based options (e.g., weekday is fine), though whether it is presenting the correct values I'm not sure.

The reason the single panel appears is very likely to do with timeAverage(), which is averaging the data to monthly, which is "midnight" and therefore nighttime.

https://github.com/davidcarslaw/openair/blob/94c5c89464ed1a85d35a083e7758a9aab838bc83/R/calcFno2.R#L147

Jack


library(openair)

mydata$back_no2 <- jitter(mydata$no2)
mydata$back_nox <- jitter(mydata$nox)
mydata$back_o3 <- jitter(mydata$o3)

calcFno2(mydata, type = "weekend")

calcFno2(mydata, type = "daylight")

Created on 2024-09-02 with reprex v2.1.1

davidcarslaw commented 1 week ago

Thanks for the comment. Note that this function is undergoing wider modification, so will look at your specific issue. Modification is needed because some refinement is required in partitioning between NO2 from primary emissions and that through chemistry. As roadside NOx concentrations have decreased, it becomes more challenging to differentiate between the two main origins of roadside NO2, as both respond more linearly with NOx concentrations. Once modified, I will update the code on GitHub.

Thanks David