================================================================================
  Experiment 14: Kochi Air Quality Dashboard (PM2.5, PM10, US AQI)
================================================================================

FULL QUESTION:
Analyze the air-quality data of Kochi using the Open-Meteo Air Quality API. Retrieve hourly AQI, PM2.5, and PM10 data for Kochi. Perform statistical and time-series analysis and plot suitable charts to visualize changes in AQI, PM2.5, and PM10 levels over time. Visualize the results using suitable charts and develop a dashboard.

SHORT QUESTION:
Hourly PM2.5, PM10, and US AQI retrieval for Kochi with time-series trend analysis and interactive Streamlit dashboard.

================================================================================
README & SETUP INSTRUCTIONS:
================================================================================
# Experiment 14: Kochi Air Quality Dashboard

## Objective
Retrieve hourly PM2.5, PM10, and US AQI readings for Kochi using the Open-Meteo Air Quality API, perform time-series analysis, and present trends on an interactive dashboard.

## Requirements
```bash
pip install requests pandas matplotlib streamlit
```

## How to Run
```bash
streamlit run app.py
```

================================================================================
SOURCE CODE FILES:
================================================================================

1. app.py
--------------------------------------------------------------------------------
import streamlit as st
import pandas as pd
import requests
import matplotlib.pyplot as plt

st.title("Kochi Air Quality Monitoring")

API_URL = "https://air-quality-api.open-meteo.com/v1/air-quality?latitude=9.93&longitude=76.27&hourly=pm10,pm2_5,us_aqi&timezone=auto"

res = requests.get(API_URL, timeout=10).json()
hourly = res["hourly"]
df = pd.DataFrame({
    "Timestamp": pd.to_datetime(hourly["time"]),
    "PM2.5": hourly["pm2_5"],
    "PM10": hourly["pm10"],
    "US_AQI": hourly["us_aqi"]
}).dropna()

st.subheader("Statistical Analysis")
st.write(df[["US_AQI", "PM2.5", "PM10"]].describe())

st.subheader("Time-Series Trends")
fig, ax = plt.subplots(3, 1, figsize=(10, 8), sharex=True)
ax[0].plot(df["Timestamp"], df["US_AQI"])
ax[0].set_ylabel("AQI")
ax[0].set_title("US AQI Trend")

ax[1].plot(df["Timestamp"], df["PM2.5"])
ax[1].set_ylabel("PM2.5 (ug/m3)")
ax[1].set_title("PM2.5 Concentration")

ax[2].plot(df["Timestamp"], df["PM10"])
ax[2].set_ylabel("PM10 (ug/m3)")
ax[2].set_xlabel("Date / Time")
ax[2].set_title("PM10 Concentration")

plt.tight_layout()
st.pyplot(fig)

st.subheader("Hourly Records")
st.write(df.tail(48))
--------------------------------------------------------------------------------
