48°F

Aaron Parecki

  • Articles
  • Notes
  • Photos
  • pm25-to-aqi.php

    August 14, 2021
    1. <?php
    2.  
    3. // https://forum.airnowtech.org/t/the-aqi-equation/169
    4.  
    5. function aqiFromPM($pm) {
    6. if($pm >= 350.5)
    7. return scale($pm, 500, 401, 500, 350.5);
    8. if($pm >= 250.5)
    9. return scale($pm, 400, 301, 350.4, 250.5);
    10. if($pm >= 150.5)
    11. return scale($pm, 300, 201, 250.4, 150.5);
    12. if($pm >= 55.5)
    13. return scale($pm, 200, 151, 150.4, 55.5);
    14. if($pm >= 35.5)
    15. return scale($pm, 150, 101, 55.4, 35.5);
    16. if($pm >= 12.1)
    17. return scale($pm, 100, 51, 35.4, 12.1);
    18. if($pm >= 0)
    19. return scale($pm, 50, 0, 12, 0);
    20. return '';
    21. }
    22.  
    23. function scale($pm, $aqiHigh, $aqiLow, $pmHigh, $pmLow) {
    24. $a = $aqiHigh - $aqiLow;
    25. $b = $pmHigh - $pmLow;
    26. $c = $pm - $pmLow;
    27. return round(($a/$b) * $c + $aqiLow);
    28. }
    Portland, Oregon • 92°F
    Sat, Aug 14, 2021 6:01pm -07:00
Posted in /code using quill.p3k.io

Hi, I'm Aaron Parecki, Director of Identity Standards at Okta, and co-founder of IndieWebCamp. I maintain oauth.net, write and consult about OAuth, and participate in the OAuth Working Group at the IETF. I also help people learn about video production and livestreaming. (detailed bio)

I've been tracking my location since 2008 and I wrote 100 songs in 100 days. I've spoken at conferences around the world about owning your data, OAuth, quantified self, and explained why R is a vowel. Read more.

  • Director of Identity Standards at Okta
  • IndieWebCamp Founder
  • OAuth WG Editor
  • OpenID Board Member

  • 🎥 YouTube Tutorials and Reviews
  • 🏠 We're building a triplex!
  • ⭐️ Life Stack
  • ⚙️ Home Automation
  • All
  • Articles
  • Bookmarks
  • Notes
  • Photos
  • Replies
  • Reviews
  • Trips
  • Videos
  • Contact
© 1999-2025 by Aaron Parecki. Powered by p3k. This site supports Webmention.
Except where otherwise noted, text content on this site is licensed under a Creative Commons Attribution 3.0 License.
IndieWebCamp Microformats Webmention W3C HTML5 Creative Commons
WeChat ID
aaronpk_tv