Data mismatch between API fetch and Real Time Map CSV

Hi Tiago, and welcome!

This response was written mainly by @Josh_PurpleAir, but he couldn’t finish it today, so I put on some finishing touches. Please let me know if I can clarify anything in the response below.


There are a few things causing the difference.

Sensor Index

The sensor index you’re using (223683) actually refers to a sensor named UFPA-ICB. However, the sensor in your CSV data and graph is UFPA Breves, with an index of 223673.

Averaging Period

You queried 10-minute averages from the API. However, the graph shown in your screenshot has a 1-day average. You can change the graph’s averaging period in your map settings, or supply a value of 1440 to the API for daily averages.

Time Zone

The time zone on the map defaults to your local one as determined by your browser. In your screenshot, the time zone you’re in has a UTC offset of -03:00.

When querying the API, it looks like you parsed the result into an ISO timestamp with no UTC offset. You can instead supply an ISO timestamp for the parameters start_timestamp and/or end_timestamp. When you do this, the API will also respond with ISO timestamps, meaning you won’t need to perform any conversion in your code.

Please note: When using ISO timestamps to query the API, data is always returned using the same UTC offset, and does not account for daylight saving changes.

Which field matches Raw PM2.5 µg/m³ on the map?

It looks like you queried pm2.5_alt and pm2.5_cf_1. There is also another set of particulate matter fields, pm2.5_atm. The differences between these are described in our What is the Difference Between CF=1, ATM, and ALT? article. You’ll want to read this for some more in-depth details.

Since both sensors in question, UFPA-ICB and UFPA Breves, are registered as outdoor, the Raw PM2.5 µg/m³ data layer reflects pm2.5_atm data.

Conversion

This actually didn’t cause any difference for you, but I’m including it for any others who read this. The only conversion currently supported by the API is ALT cf=3.4. To ensure data from the API matches the map, you’ll generally need to ensure that no is selected for the Apply conversion map setting.

Since both the map and API directly support Alt-CF3.4, you could also compare the data converted this way. You would enable the “Alt-CF3.4” conversion on the map, and from the API, you would need to retrieve the pm2.5_alt_a|3.4 and pm2.5_alt_b|3.4 data from the API to compare with the map graph data. You can learn more about why the “|3.4” is needed here: What is the Difference Between CF=1, ATM, and ALT?

1 Like