Open stefanthoss opened 2 years ago
An easier solution that I went with is:
AQI_MAX = 500
def my_function(self):
try:
return aqi.to_aqi(
[(aqi.POLLUTANT_PM25, self.pm25),
(aqi.POLLUTANT_PM10, self.pm10)]
)
except IndexError:
# in some cases, the PM2.5/PM10 values can be 99999, which goes beyond the index.
return AQI_MAX
I'm using version 0.6.1 of this library with the default EPA algorithm. When I provide a PM concentration that is higher than the upper limit defined by the maximum AQI range (i.e. it would result in an AQI above 500), the library fails with an
IndexError
.The error gets thrown by the line https://github.com/hrbonz/python-aqi/blob/56f6e3bd8200205114307558e1d8329b7477d158/aqi/algos/base.py#L91 since the
idx
variable is larger than the AQI boundary array allows.Complete error message: