AirSense Copenhagen is a real-time air quality monitoring project focused on identifying pollution trends across Copenhagen’s urban landscape. It uses API-driven data collection and scientifically standardized AQI calculations to support smarter, cleaner city planning.
This university project from our Machine Learning course helps advance Copenhagen’s carbon-neutral goals by turning air quality data into actionable insights, especially in relation to traffic patterns. The AQI calculations are based on official EPA methodology, ensuring consistent and comparable pollution scoring across locations.
- Integrates with the Open-Meteo Air Quality API
- Monitors pollution data from multiple urban points in Copenhagen
- Implements EPA-standard AQI computation logic
- Applies correct pollutant-specific averaging rules:
- 24-hour averages for PM2.5 and PM10
- 8-hour averages for O3 and CO
- 1-hour values for NO2 and SO2
- Highlights the dominant pollutant and air quality rating per location
- Categorizes pollution levels based on EPA AQI bands
airsense_copenhagen/
├── config.py # Centralized configuration and constants
├── aqi_breakpoints.py # AQI threshold data
├── aqi_calculator.py # Core AQI logic
├── data_fetcher.py # API querying and data collection
├── data_processor.py # Data cleaning and aggregation
├── main.py # Runs the full pipeline
└── README.md # Documentation
config.py
: Coordinates, API keys, and unit conversion constantsaqi_breakpoints.py
: EPA AQI breakpoint definitionsaqi_calculator.py
: Calculates AQI from pollutant concentrationsdata_fetcher.py
: Downloads air quality data using Open-Meteodata_processor.py
: Applies averages and prepares AQI metricsmain.py
: Ties everything together and produces final output
-
Clone the repository:
git clone https://github.com/YOUR_USERNAME/airsense_copenhagen.git cd airsense_copenhagen
-
(Optional) Create a virtual environment:
python -m venv env source env/bin/activate # Windows: env\Scripts\activate
-
Install required packages:
pip install requests pandas numpy
Use the command below to fetch, process, and evaluate air quality data:
python main.py
This script will:
- Retrieve historical air quality data from three Copenhagen locations
- Apply EPA-standard time-weighted averages
- Compute AQI values per location and time interval
- Output the most recent readings per area
Each location produces a DataFrame with these key columns:
time
: Measurement timestampAQI
: Calculated index scoreAQI_Category
: Qualitative pollution levelDominant_Pollutant
: Pollutant contributing most to the AQI
Example usage in Python:
import pandas as pd
from main import main
# Run pipeline
dfs = main()
# Access one location
boulevard_df = dfs["H.C. Andersens Boulevard"]
# Filter last 30 days
recent_data = boulevard_df[boulevard_df['time'] > pd.Timestamp.now() - pd.Timedelta(days=30)]
# Average AQI
print("Avg AQI (last 30 days):", recent_data['AQI'].mean())
We utilize the Open-Meteo Air Quality API for high-resolution hourly data on:
- PM2.5 / PM10
- NO2
- CO
- SO2
- O3
- H.C. Andersens Boulevard – Dense traffic/commercial area
- Nørrebro – Residential and mixed-use district
- Amager Strandpark – Coastal green space with low emissions
Following the EPA standard, we:
- Compute pollutant-specific rolling averages
- Convert concentrations into AQI using breakpoint tables
- Use the highest AQI value per location as the overall AQI
- Determine the dominant pollutant
- Categorize results into Good, Moderate, Unhealthy, etc.
Future enhancements may include:
- Integration with traffic congestion data
- Machine learning to predict AQI trends
- Web-based dashboard for live updates
- Support for additional monitoring sites
- Seasonal and temporal trend visualizations
- Open-Meteo for providing API access
- U.S. Environmental Protection Agency for AQI framework