skalnik / aqi-wtf

😷 WTF is the AQI near me right now?!
https://aqi.wtf
MIT License
44 stars 12 forks source link

Switch AQI calculations to use the EPA recommended corrections for PA Sensors. #60

Closed obra closed 3 years ago

obra commented 3 years ago

Please check this work CAREFULLY.

As of this PR, we are -not- yet averaging across at least two minutes of readings and throwing a fit if values are off by more than 5% as recommended by them.

Sources:

https://thebolditalic.com/understanding-purpleair-vs-airnow-gov-measurements-of-wood-smoke-pollution-562923a55226 https://cfpub.epa.gov/si/si_public_record_report.cfm?dirEntryId=349513&Lab=CEMM&simplesearch=0&showcriteria=2&sortby=pubDate&timstype=&datebeginpublishedpresented=08/25/2018

vercel[bot] commented 3 years ago

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/skalnik/aqi-wtf/izgia4xy5
✅ Preview: https://aqi-wtf-git-epa-correction.skalnik.vercel.app

obra commented 3 years ago

I would agree pretty strongly with a decision to leave this hanging out for a while until we can see another implementation. I ....sort of want to stick all the alternate AQI calculations on the page in invisible text, just so we can watch them. But I don't feel strongly about it.

skalnik commented 3 years ago

What about a second, unlinked, page with all the values on it?

skalnik commented 3 years ago

I done any comparisons or anything but I just noticed that PurpleAir now includes an EPA adjustment!

daylen commented 3 years ago

As mentioned above, now that PurpleAir has an EPA adjustment, we could verify that this PR matches and then merge it in.

skalnik commented 3 years ago

I adjusted this to use the values posted on the PurpleAir website and fixed the link to send the EPA, and the values seem to align for me (seen them at most 1 off, I figure due to timing). If anyone else wants to try this out and make sure it seems good that'd be great!

skalnik commented 3 years ago

Hm, checked on my bike ride this morning and something seems off!

IMG_5760

skalnik commented 3 years ago

Hm, that URL may have been outdated. I think Vercel made some changes. https://aqi-wtf-izgia4xy5.vercel.app seems to not include the . at the first line, but the URL I was going to did, so maybe this is fine!?

kylebshr commented 3 years ago

👋 Any update on this? Hoping to borrow your implementation but wanted to make sure it all checks out

obra commented 3 years ago

CF1 is “ correction factor 1” and that change is because it is what is specified in the EPA presentation about how to calculate this number

On Oct 19, 2020, at 9:01 PM, Kyle Bashour notifications@github.com wrote:

 @kylebshr commented on this pull request.

In app.js:

announceState("Calculating AQI");

 for (const subsensor of sensor.results) {
   if (!bustedSensor(subsensor)) {
  • pm25s.push(parseFloat(subsensor["PM2_5Value"]));
  • pm25s.push(parseFloat(subsensor["pm2_5_cf_1"])); What does this change? And why? PurpleAir docs are very light 😅

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

kylebshr commented 3 years ago

Awesome, thanks! Copied this over to my app and spot-checking against purple air real-time is looking correct. Going to ship it I think!

skalnik commented 3 years ago

Yeah I've been checking this for the past couple of weeks and I haven't gotten a weird number since and it always lines up with the Purple Air numbers!