Author Topic: Which Airlink data is relevant for a simple air quality report?  (Read 353 times)

0 Members and 1 Guest are viewing this topic.

Offline wrybread

  • Senior Member
  • **
  • Posts: 70
Which Airlink data is relevant for a simple air quality report?
« on: September 26, 2020, 04:59:04 PM »
I'm working on a Python script to grab the air quality index from my new Airlink.

Using Davis' AirLink Local API (v1), here's the data I just retrieved:

Code: [Select]
{
"data": {
"did": "[my station serial num]",
"name": "[my station name]",
"ts": 1601153631,
"conditions": [{
"lsid": 349391,
"data_structure_type": 6,
"temp": 64.9,
"hum": 77.7,
"dew_point": 57.7,
"wet_bulb": 60.0,
"heat_index": 65.1,
"pm_1_last": 2,
"pm_2p5_last": 3,
"pm_10_last": 5,
"pm_1": 3.74,
"pm_2p5": 7.01,
"pm_2p5_last_1_hour": 4.45,
"pm_2p5_last_3_hours": 3.82,
"pm_2p5_last_24_hours": 3.82,
"pm_2p5_nowcast": 4.02,
"pm_10": 17.38,
"pm_10_last_1_hour": 11.84,
"pm_10_last_3_hours": 11.08,
"pm_10_last_24_hours": 11.08,
"pm_10_nowcast": 11.32,
"last_report_time": 1601153631,
"pct_pm_data_last_1_hour": 100,
"pct_pm_data_last_3_hours": 91,
"pct_pm_data_nowcast": 22,
"pct_pm_data_last_24_hours": 11
}]
},
"error": null
}

I'm new to measuring air quality and don't know which of the above is relevant. If I was just posting a number for the air quality, does anyone happen to know which of those I'd post?

And what sort of key/legend I'd use to let people know what that means?

And I'd also like to graph it longterm, showing how the air quality has changed. Any tips on which values are relevant for that, if different?

Thanks for any help.
« Last Edit: September 29, 2020, 03:39:46 AM by wrybread »

Offline ConligWX

  • Forecaster
  • *****
  • Posts: 687
  • #conligwx
    • conligwx.org
Re: Which Airlink data is relevant for a simple air quality report?
« Reply #1 on: September 26, 2020, 06:20:38 PM »
All of the lines are explained in the API documentation.

https://weatherlink.github.io/airlink-local-api/
Regards Simon
Davis Vantage Pro2 Plus Daytime FARS WeatherLink Live CumulusMX Saratoga Templates


Offline the beteljuice

  • the beteljuice
  • Senior Contributor
  • ****
  • Posts: 252
    • test site
Re: Which Airlink data is relevant for a simple air quality report?
« Reply #2 on: September 26, 2020, 06:23:55 PM »
It is said that the various classification tables apply to rolling 24 hour pm2.5 (pm_2p5_last_24_hours) - However I suggest if any of the pm sizes suddenly rise and you live near a chemical factory you may want to take some sort of action !

This is a beteljuice experiment - data is 'old' and static. I have no kit to play with  provided by Mapantz (UK)
« Last Edit: October 15, 2020, 12:31:32 AM by the beteljuice »
Imagine what you will KNOW tomorrow !

Offline Mapantz

  • Forecaster
  • *****
  • Posts: 440
    • Wareham Weather
Re: Which Airlink data is relevant for a simple air quality report?
« Reply #3 on: September 26, 2020, 06:26:28 PM »
If you go to the weatherlink app or webpage, there's an AQI setting for your relevant country/continent.

I would then go to the website of that provider to look at their legends/keys.

I've got PM 2.5 and PM 10 showing on my site and I matched the coloured icon to the info displayed by UK COMEAP Daily at the UK's DEFRA website.

It is said that the various classification tables apply to rolling 24 hour pm2.5 (pm_2p5_last_24_hours) - However I suggest if any of the pm sizes suddenly rise and you live near a chemical factory you may want to take some sort of action !

This is a beteljuice experiment - data is 'old' and static. I have no kit to play with !

You can test with my data if you like beteljuice?


Offline wrybread

  • Senior Member
  • **
  • Posts: 70
Re: Which Airlink data is relevant for a simple air quality report?
« Reply #4 on: September 27, 2020, 08:15:07 PM »
Quote
I've got PM 2.5 and PM 10 showing on my site

Are you converting those numbers to an AQI, or are you just displaying the PM2.5 and PM10 numbers?

For an AQI, the WeatherLink app shows my "NowCast AQI" is 110, and a nearby PurpleAir sensor reports "10 Minute Average US EPA PM2.5 AQI is 123". Here are the Purple Airs in my area:

http://purpleair.com/map?opt=1/mAQI/a10/cC0#10.73/38.173/-122.8435

Is WeatherLink's "NowCast AQI" the same index as PurpleAir's "10 Minute Average US EPA PM2.5 AQI"?

Looking at my data closer, currently the WeatherLink app reports for my sensor:

Code: [Select]
NowCast EPA AQI = 110
PM 1 = 22
PM 2.5 = 33
PM 10 = 42

That's the "pm_1", "pm_2p5" and "pm_10" data in the local API, and here's the rest of the data from the local API:

Code: [Select]
"pm_1_last": 26,
"pm_2p5_last": 38,
"pm_10_last": 50,
[b]"pm_1": 22.43[/b],
[b]"pm_2p5": 32.66[/b],
"pm_2p5_last_1_hour": 41.09,
"pm_2p5_last_3_hours": 40.78,
"pm_2p5_last_24_hours": 23.92,
"pm_2p5_nowcast": 39.32,
[b]"pm_10": 41.51,[/b]
"pm_10_last_1_hour": 54.23,
"pm_10_last_3_hours": 53.45,
"pm_10_last_24_hours": 34.04,
"pm_10_nowcast": 52.01,
"last_report_time": 1601246426,
"pct_pm_data_last_1_hour": 100,
"pct_pm_data_last_3_hours": 100,
"pct_pm_data_nowcast": 100,
"pct_pm_data_last_24_hours": 100

Using this Concentration to AQI calculator:

https://www.airnow.gov/aqi/aqi-calculator-concentration/

If I enter my PM2.5 of 33 I get an AQI of 95, which I think is too low.

This is an interesting Python project:

https://github.com/hrbonz/python-aqi

When I enter just my PM2.5 I get an AQI of 93, and when I enter both my PM2.5 and PM10 I get an AQI of 95:

Code: [Select]
import aqi

# using just PM2.5
myaqi = aqi.to_iaqi(aqi.POLLUTANT_PM25, '32', algo=aqi.ALGO_EPA)
print myaqi # prints 93

# using PM2.5 and PM10
myaqi = aqi.to_aqi([
    (aqi.POLLUTANT_PM25, '33'),
    (aqi.POLLUTANT_PM10, '42')
])
print myaqi # prints 95

That's lower than the AQI in both WeatherLink and PurpleAir. Thoughts?

Edited to add: Aha, using the "pm_2p5_last_1_hour" puts me in the ballpark, with an AQI of 115. Does that sound right?

Code: [Select]
import aqi

# using pm_2p5_last_1_hour
v=41.09
myaqi = aqi.to_iaqi(aqi.POLLUTANT_PM25, v, algo=aqi.ALGO_EPA)
print myaqi # prints 115
« Last Edit: September 27, 2020, 08:26:52 PM by wrybread »

Offline wrybread

  • Senior Member
  • **
  • Posts: 70
Re: Which Airlink data is relevant for a simple air quality report?
« Reply #5 on: September 27, 2020, 09:09:51 PM »
Update: I'm now able to generate the 3 AQI's shown on WeatherLink's web interface: the "current AQI", the "1 hour AQI" and the "NowCast" with this Python script, which also retrieves the data from my airlink:

Code: [Select]
import aqi # pip install python-aqi
import requests

# IP of the AirLink
ip = "10.10.10.51"


response = requests.get("http://%s/v1/current_conditions" % ip)
data = response.json()
conditions = data["data"]["conditions"][0]

myaqi = aqi.to_aqi([
    (aqi.POLLUTANT_PM25, conditions["pm_2p5"]),
    #(aqi.POLLUTANT_PM10, conditions["pm_10_last_1_hour"])
])
print ("Current AQI is %s" % myaqi)

myaqi = aqi.to_aqi([
    (aqi.POLLUTANT_PM25, conditions["pm_2p5_last_1_hour"]),
])
print ("1 Hour AQI is %s" % myaqi)

myaqi = aqi.to_aqi([
    (aqi.POLLUTANT_PM25, conditions["pm_2p5_nowcast"]),
])
print ("Nowcast AQI is %s" % myaqi)

That exactly duplicates the numbers shown in the attached screenshot of the weatherlink.com interface.

So that just leaves building PurpleAir's AQI, which is a bit trickier since I don't actually have a PurpleAir to confirm my calculation method. All the PurpleAirs near me (https://www.purpleair.com/map?opt=1/mAQI/a10/cC0#10.73/38.173/-122.8435) show a "10 Minute Average US EPA PM2.5 AQI" ranging from 100 to 130, which is about like my "Nowcast" value of 93.

I don't think the AirLink lists a 10 minute average of the PM2.5, so I could just average out the last 10 mins of readings, or maybe it's not necessary. Thoughts about whether I'm on the right track to duplicate purpleair's main aqi?
« Last Edit: September 28, 2020, 03:00:04 AM by wrybread »

Offline wrybread

  • Senior Member
  • **
  • Posts: 70
Re: Which Airlink data is relevant for a simple air quality report?
« Reply #6 on: September 28, 2020, 08:56:57 PM »
Here's a Python script that retrieves the data from my AirLink via its local api, converts the pm_2p5, pm_2p5_last_1_hour and pm_2p5_nowcast to EPA AQI, exactly matching the numbers shown on weatherlink.com. It also averages the pm_2p5 over 10 minutes, which I *think* is what PurpleAir does. Comments and feedback invited! Since I'm still not sure about the Purple Air method.

Tested with Python 2.7 but it should work with 3 as well.

Code: [Select]
import aqi    # pip install python-aqi
import requests
import time

# IP of the AirLink
ip = "10.10.10.51"




readings = []
while True:
   
    try:
        response = requests.get("http://%s/v1/current_conditions" % ip)
        data = response.json()
        conditions = data["data"]["conditions"][0]

    except Exception as e:
        print ("Error connecting to Airlink! %s" % e)
        continue
   
    myaqi = aqi.to_aqi([
        (aqi.POLLUTANT_PM25, conditions["pm_2p5"]),
        #(aqi.POLLUTANT_PM10, conditions["pm_10_last_1_hour"])
    ])
    print ("Current AQI: %s" % myaqi)
    readings.append(myaqi)

    myaqi = aqi.to_aqi([
        (aqi.POLLUTANT_PM25, conditions["pm_2p5_last_1_hour"]),
    ])
    print ("1 Hour AQI: %s" % myaqi)

    myaqi = aqi.to_aqi([
        (aqi.POLLUTANT_PM25, conditions["pm_2p5_nowcast"]),
    ])
    print ("Nowcast AQI: %s" % myaqi)

    # if change the delay at end of loop, change the number of readings so we get 10 minutes of readings.
    # for example with a delay in the loop of 30 seconds, we need 20 readings to add up to 10 minutes of readings.
    num_readings = 20
    if len(readings)>=num_readings:
        subset = readings[-num_readings:] # the last X readings
        avg = sum(subset) / len(subset)
        avg = round(avg, 1)
        print ("10 minute average of pm_2p5: %s" % (avg))

    print("")
    time.sleep(30)
« Last Edit: September 29, 2020, 03:43:36 AM by wrybread »

 

anything