Update app.py
Browse files
app.py
CHANGED
@@ -18,7 +18,7 @@ body {
|
|
18 |
"""
|
19 |
st.markdown(custom_css, unsafe_allow_html=True)
|
20 |
|
21 |
-
# Prescribed limits for AQI
|
22 |
PRESCRIBED_LIMITS = {
|
23 |
'AQI': {
|
24 |
'good': (0, 50),
|
@@ -35,10 +35,24 @@ PRESCRIBED_LIMITS = {
|
|
35 |
'unhealthy': (55.6, 150.4),
|
36 |
'very_unhealthy': (150.5, 250.4),
|
37 |
'hazardous': (250.5, float('inf'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
}
|
39 |
}
|
40 |
|
41 |
-
# Color codes for different AQI
|
42 |
COLOR_CODES = {
|
43 |
'good': 'green',
|
44 |
'moderate': 'yellow',
|
@@ -77,7 +91,12 @@ def get_aqi_data():
|
|
77 |
pm10_end = line.find(" µg/m³)", pm10_start)
|
78 |
pm10 = float(line[pm10_start:pm10_end].strip())
|
79 |
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
def main():
|
83 |
# Logo
|
@@ -87,7 +106,7 @@ def main():
|
|
87 |
st.title('Real Time SXR AQI Dashboard')
|
88 |
st.subheader('Real-time Air Quality Monitoring')
|
89 |
|
90 |
-
aqi, aqi_level, pm25, pm10 = get_aqi_data()
|
91 |
|
92 |
# Display AQI with safety level
|
93 |
st.markdown('### Current Data:')
|
@@ -108,6 +127,19 @@ def main():
|
|
108 |
|
109 |
# Display PM10 with safety level
|
110 |
st.write(f"- **PM10:** {pm10} µg/m³")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
|
112 |
# Developer section
|
113 |
st.markdown('### Developer:')
|
|
|
18 |
"""
|
19 |
st.markdown(custom_css, unsafe_allow_html=True)
|
20 |
|
21 |
+
# Prescribed limits for AQI, PM2.5, PM10, and temperature
|
22 |
PRESCRIBED_LIMITS = {
|
23 |
'AQI': {
|
24 |
'good': (0, 50),
|
|
|
35 |
'unhealthy': (55.6, 150.4),
|
36 |
'very_unhealthy': (150.5, 250.4),
|
37 |
'hazardous': (250.5, float('inf'))
|
38 |
+
},
|
39 |
+
'PM10': {
|
40 |
+
'good': (0, 50),
|
41 |
+
'moderate': (51, 100),
|
42 |
+
'unhealthy_sensitive': (101, 250),
|
43 |
+
'unhealthy': (251, 350),
|
44 |
+
'very_unhealthy': (351, 430),
|
45 |
+
'hazardous': (431, float('inf'))
|
46 |
+
},
|
47 |
+
'Temperature': {
|
48 |
+
'comfortable': (0, 25),
|
49 |
+
'moderate': (26, 30),
|
50 |
+
'warm': (31, 35),
|
51 |
+
'hot': (36, float('inf'))
|
52 |
}
|
53 |
}
|
54 |
|
55 |
+
# Color codes for different AQI, PM2.5, PM10, and temperature levels
|
56 |
COLOR_CODES = {
|
57 |
'good': 'green',
|
58 |
'moderate': 'yellow',
|
|
|
91 |
pm10_end = line.find(" µg/m³)", pm10_start)
|
92 |
pm10 = float(line[pm10_start:pm10_end].strip())
|
93 |
|
94 |
+
# Extract temperature value
|
95 |
+
temp_start = line.find("temperature (") + len("temperature (")
|
96 |
+
temp_end = line.find("˚C)", temp_start)
|
97 |
+
temp = float(line[temp_start:temp_end].strip())
|
98 |
+
|
99 |
+
return aqi, aqi_level, pm25, pm10, temp
|
100 |
|
101 |
def main():
|
102 |
# Logo
|
|
|
106 |
st.title('Real Time SXR AQI Dashboard')
|
107 |
st.subheader('Real-time Air Quality Monitoring')
|
108 |
|
109 |
+
aqi, aqi_level, pm25, pm10, temp = get_aqi_data()
|
110 |
|
111 |
# Display AQI with safety level
|
112 |
st.markdown('### Current Data:')
|
|
|
127 |
|
128 |
# Display PM10 with safety level
|
129 |
st.write(f"- **PM10:** {pm10} µg/m³")
|
130 |
+
pm10_safety = check_safety_level(pm10, 'PM10')
|
131 |
+
if pm10_safety:
|
132 |
+
st.write(f"Safety Level: {pm10_safety}")
|
133 |
+
color_code = COLOR_CODES[pm10_safety]
|
134 |
+
st.markdown(f'<p style="color:{color_code};">The PM10 level is {pm10_safety}.</p>', unsafe_allow_html=True)
|
135 |
+
|
136 |
+
# Display temperature with safety level
|
137 |
+
st.write(f"- **Temperature:** {temp}˚C")
|
138 |
+
temp_safety = check_safety_level(temp, 'Temperature')
|
139 |
+
if temp_safety:
|
140 |
+
st.write(f"Safety Level: {temp_safety}")
|
141 |
+
color_code = COLOR_CODES[temp_safety]
|
142 |
+
st.markdown(f'<p style="color:{color_code};">The temperature level is {temp_safety}.</p>', unsafe_allow_html=True)
|
143 |
|
144 |
# Developer section
|
145 |
st.markdown('### Developer:')
|