Replies: 2 comments 1 reply
-
My original implementation, for posterity:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
One other thing... the Nowcast values will provide the best AQI, because that is a recency-weighted average, and better takes into account current conditions. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I wanted to share some experience I have doing AQI calculations, since it sounds from @siku2 like there's some interest in adding this as a feature. It looks like there's been some discussion (#36) on how to do this with templates, but this would be a new approach as part of the sensor itself.
For US EPA, it's a basic step function. You're essentially mapping values from one predefined range (PM values) to another predefined range (index). I used the values published here: US EPA AQI Breakpoints
Note that the breakpoints are not the same for PM2.5 and PM10. Overall AQI is found by taking the maximum of PM2.5 and PM10 AQI values.
A brief glance makes it seem like other health agencies use the same basic function, but with different breakpoints, but I could be wrong about this.
One gotcha in the implementation is that there's technically a discontinuity between the high breakpoint in one step and the low breakpoint in the next. eg. looking at the first two PM2.5 breakpoints, what happens if your PM2.5 value is 12.05? A silly thing, but it bit me on the first try... Solution is to round first.
Beta Was this translation helpful? Give feedback.
All reactions