import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import style
style.use("bmh")
data = pd.read_csv("smart_room_air_quality_data_final.csv")
Run to view results
#C02 sensor dynamics
plt.figure(figsize=(16, 6))
plt.rcParams.update({"font.size": 15})
plt.plot(data["time_min"], data["co2_ppm"], "k", label="CO2 sensor data")
plt.axhline(1000, color="blue", linestyle="--", label="Warning threshold")
plt.axhline(1500, color="red", linestyle="--", label="Critical threshold")
# Event region
plt.axvspan(20, 45, color="red", alpha=0.12, label="Poor ventilation event")
# First threshold crossing
co2_cross = np.where(data["co2_ppm"] > 1000)[0][0]
plt.plot(data["time_min"][co2_cross], data["co2_ppm"][co2_cross], "ro", label="CO2 threshold exceeded")
# First actuator activation
vent_on = np.where(data["ventilation_state"] == 1)[0][0]
plt.xlabel("Time [min]")
plt.ylabel("CO2 [ppm]")
plt.title("CO2 Dynamics with Detection and Actuation")
plt.legend()
plt.grid(True)
plt.savefig("C02Dynamics.pdf", bbox_inches="tight", pad_inches=0.1, dpi=600)
plt.show()
Run to view results
#PM2.5 sensor dynamics
plt.figure(figsize=(16, 6))
plt.rcParams.update({"font.size": 15})
plt.plot(data["time_min"], data["pm25_ugm3"], "k", label="PM2.5 sensor data")
plt.axhline(15, color="blue", linestyle="--", label="Warning threshold")
plt.axhline(35, color="red", linestyle="--", label="High threshold")
plt.axvspan(50, 70, color="red", alpha=0.12, label="Particle pollution event")
pm_cross = np.where(data["pm25_ugm3"] > 15)[0][0]
plt.plot(data["time_min"][pm_cross], data["pm25_ugm3"][pm_cross], "ro", label="PM2.5 threshold exceeded")
plt.xlabel("Time [min]")
plt.ylabel("PM2.5 [µg/m³]")
plt.title("PM2.5 Dynamics with Pollution Event")
plt.legend()
plt.grid(True)
plt.savefig("PM2.5 Dynamics.pdf", bbox_inches="tight", pad_inches=0.1, dpi=600)
plt.show()
Run to view results
#Dynamics of temperature
plt.figure(figsize=(16, 6))
plt.rcParams.update({"font.size": 15})
plt.plot(data["time_min"], data["temperature_c"], "k", label="Temperature sensor data")
plt.axhline(27, color="red", linestyle="--", label="High threshold")
plt.axhline(18, color="blue", linestyle="--", label="Low threshold")
plt.axvspan(30, 60, color="red", alpha=0.12, label="Overheating event")
temp_cross = np.where(data["temperature_c"] > 27)[0][0]
plt.plot(data["time_min"][temp_cross], data["temperature_c"][temp_cross], "ro", label="Temperature threshold exceeded")
plt.xlabel("Time [min]")
plt.ylabel("Temperature [°C]")
plt.title("Temperature Dynamics with Detection and Actuation")
plt.legend()
plt.grid(True)
plt.savefig("temp_dynamics.pdf", bbox_inches="tight", pad_inches=0.1, dpi=600)
plt.show()
Run to view results
#Humidity sensor
plt.figure(figsize=(16, 6))
plt.rcParams.update({"font.size": 15})
plt.plot(data["time_min"], data["humidity_percent"], "k", label="Humidity sensor data")
plt.axhline(70, color="red", linestyle="--", label="High threshold")
plt.axhline(25, color="blue", linestyle="--", label="Low threshold")
plt.axvspan(65, 90, color="red", alpha=0.12, label="High humidity event")
hum_cross = np.where(data["humidity_percent"] > 70)[0][0]
plt.plot(data["time_min"][hum_cross], data["humidity_percent"][hum_cross], "ro", label="Humidity threshold exceeded")
plt.xlabel("Time [min]")
plt.ylabel("Humidity [%]")
plt.title("Humidity Dynamics with Detection and Actuation")
plt.legend()
plt.grid(True)
plt.savefig("humidity_dynamics.pdf", bbox_inches="tight", pad_inches=0.1, dpi=600)
plt.show()
Run to view results
#Dynamics of action
plt.figure(figsize=(16, 6))
plt.rcParams.update({"font.size": 15})
plt.plot(data["time_min"], data["risk_level"], "k", label="Risk level")
plt.plot(data["time_min"], data["ventilation_state"], "--", label="Ventilation state")
plt.plot(data["time_min"], data["window_state"], "-.", label="Window state")
plt.xlabel("Time [min]")
plt.ylabel("State")
plt.title("Risk Level ")
plt.yticks([0, 1, 2, 3], ["Normal", "Warning", "High", "Critical"])
plt.legend()
plt.grid(True)
plt.savefig("RISKLEVEL.pdf", bbox_inches="tight", pad_inches=0.1, dpi=600)
plt.show()
Run to view results