ECMWFCode4Earth / vAirify

code repository for 2024 Code for Earth project #16
MIT License
2 stars 1 forks source link

Convert PPM measurements from OpenAQ data based on CAMS air density #63

Closed amehta-scottlogic closed 3 months ago

amehta-scottlogic commented 4 months ago

Description

From the last call with the mentors, they are keen to include PPM values from OpenAQ. We want to store the data in µg/m³ so all units are the same. The problem is we need a value for air density from that location to do the conversion.

The approach to take for now will be to query CAMS and use their surface temperature + pressure values (as we do already for forecast data) and when units are PPM we convert. The cams data should be queried with the lat/longs of the measurement stations themselves (rather than the city lat/long) for the best approximation.

While this is not likely to be 100% accurate, it should mean that more data can be used.

Formula: ppb = ppm * 1000 Image Image

Weights no2 = 46.01 g/mol so2 = 64.07 g/mol o3 = 48 g/mol

https://www.apis.ac.uk/unit-conversion https://www.breeze-technologies.de/blog/air-pollution-how-to-convert-between-mgm3-%C2%B5gm3-ppm-ppb/

Acceptance Criteria

EDIT - only ppm measurements for so2, no2 and o3 are converted. We now filter out any instance of pm10 or pm2_5 and do not store in the database

Test Checklist:

mwalker-scottlogic commented 3 months ago

forecast_api_seeded_data_tests.py, forecast_api_validation_tests.py, cams_known_grib_test.py, forecast_calibration_tests.py & open_aq_etl_tests.py tests all passed.

Executed manual test cases, had to make some changes to test assertions, but expected behaviour was observed

mwalker-scottlogic commented 3 months ago

Test Analysis:

Elements to verify:

mnyamunda-scottlogic commented 3 months ago

Looking good, we already have some code snippets that may expedite the process too! 😎

mwalker-scottlogic commented 3 months ago

Finding: pm10 and pm2.5 original_values are not being converted - RESOLVED ✅

Steps to reproduce:

  1. Mock the API response from OpenAQ, with data that has units of ppm, and all pollutants
  2. Observe the data in the database

Expected:

Actual:

Image

I am concerned this data could make it through to the UI.

The document structure is slightly different than described, with fields value, unit, original_value & original_unit

mwalker-scottlogic commented 3 months ago

Test Conclusion

Image