Commented here. Digging into it deeper, that function seems to not be returning an "AQI" value, but rather "a weighted concentration value of pm25 pollution" (effectively "how much junk is in the air", not "how healthy is that concentration to humans")
This seems to not follow the current calculations of how "AQI" is calculated? According to the document at https://www.airnow.gov/sites/default/files/2020-05/aqi-technical-assistance-document-sept2018.pdf, when looking at pm2.5 pollution, there's certain μg/m3 ranges that get mapped to the AQI color band ranges, and then the value is interpolated within that band.
@russbiggs who runs OpenAQ wrote this code and explains why he used the NowCast algorithm here even though the EPA uses a different one: https://www.val.town/v/russbiggs/nowcastPMAqi#L5-8
Maybe comment on his val if you have questions?
Commented here. Digging into it deeper, that function seems to not be returning an "AQI" value, but rather "a weighted concentration value of pm25 pollution" (effectively "how much junk is in the air", not "how healthy is that concentration to humans")