This project analyzes Beijing's air quality using multi-source time-series data, following the methodology of Zhang et al. (2017). The main goal is to disentangle the effects of meteorology from emission trends, providing a "weather-adjusted" view of PM2.5 pollution.
- Combined hourly air quality and meteorological data from multiple monitoring stations (2013–2017).
- Created a unified DataFrame with a datetime index and station labels.
- Handled missing values and engineered features (e.g., cyclical time, wind direction encoding).
- Explored spatial, temporal, and meteorological patterns in PM2.5.
- Visualized trends by station, hour, month, and wind direction.
- Trained three models to classify PM2.5 air quality categories based on meteorological features:
- Random Forest
- XGBoost
- LSTM (PyTorch)
- Evaluated models using accuracy, F1-score, and confusion matrices.
- For each year, replaced actual weather with long-term average ("baseline") weather conditions.
- Used trained models to predict what PM2.5 categories would have been under average weather.
- Compared observed and weather-adjusted trends to reveal the true impact of emission controls, independent of meteorological variability.
- Weather adjustment reveals greater air quality improvement than raw data suggests.
- In years with unfavorable weather (e.g., 2017), observed PM2.5 can appear worse than it truly is.
- Meteorological factors, especially wind speed and direction, are major drivers of short-term PM2.5 variation.
-
Install dependencies:
pip install -r requirements.txt
-
Train models:
python -m src.train_rf python -m src.train_xgb python -m src.train_lstm
-
Run weather-adjusted analysis:
python -m src.weather_adjusted_pm25 python -m src.weather_adjusted_pm25_xgb python -m src.weather_adjusted_pm25_lstm
-
Check the
output/directory for visualizations and results.
- Zhang, Q., et al. (2017). "Cautionary tales on air-quality improvement in Beijing." PNAS.
This project demonstrates the importance of meteorological adjustment in air quality trend analysis and provides a reproducible workflow for similar studies.