Commit
·
a167418
1
Parent(s):
8220917
ui changes
Browse files- app.py +76 -4
- predictions_history.csv +0 -6
- src/helper_functions.py +18 -18
app.py
CHANGED
@@ -86,8 +86,14 @@ with col2:
|
|
86 |
with st.expander("Learn more about O3", expanded=False):
|
87 |
st.markdown(
|
88 |
"""
|
89 |
-
*Ozone (O<sub>3</sub>)
|
90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
""",
|
92 |
unsafe_allow_html=True,
|
93 |
)
|
@@ -103,8 +109,14 @@ with col2:
|
|
103 |
with st.expander("Learn more about NO2", expanded=False):
|
104 |
st.markdown(
|
105 |
"""
|
106 |
-
*Nitrogen Dioxide (NO<sub>2</sub>)
|
107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
""",
|
109 |
unsafe_allow_html=True,
|
110 |
)
|
@@ -169,6 +181,35 @@ with col2:
|
|
169 |
)
|
170 |
)
|
171 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
fig_o3.update_layout(
|
173 |
plot_bgcolor="rgba(0, 0, 0, 0)",
|
174 |
paper_bgcolor="rgba(0, 0, 0, 0)",
|
@@ -185,6 +226,7 @@ with col2:
|
|
185 |
tickcolor="gray",
|
186 |
),
|
187 |
showlegend=False, # Disable legend
|
|
|
188 |
)
|
189 |
|
190 |
st.plotly_chart(fig_o3, key="fig_o3")
|
@@ -235,6 +277,35 @@ with col2:
|
|
235 |
)
|
236 |
)
|
237 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
fig_no2.update_layout(
|
239 |
plot_bgcolor="rgba(0, 0, 0, 0)",
|
240 |
paper_bgcolor="rgba(0, 0, 0, 0)",
|
@@ -251,6 +322,7 @@ with col2:
|
|
251 |
tickcolor="gray",
|
252 |
),
|
253 |
showlegend=False, # Disable legend
|
|
|
254 |
)
|
255 |
|
256 |
st.plotly_chart(fig_no2, key="fig_no2")
|
|
|
86 |
with st.expander("Learn more about O3", expanded=False):
|
87 |
st.markdown(
|
88 |
"""
|
89 |
+
*Ozone (O<sub>3</sub>)* is a gas that occurs both in the Earth's upper atmosphere and at ground level.
|
90 |
+
|
91 |
+
**Levels interpretation:**
|
92 |
+
* <span style='color:#77C124'>**Good**</span> (< 120 µg/m³): Safe for most people. Ideal conditions for outdoor activities.
|
93 |
+
* <span style='color:#E68B0A'>**Medium**</span> (120-240 µg/m³): May cause breathing discomfort for sensitive groups. People with respiratory conditions should limit prolonged outdoor exposure.
|
94 |
+
* <span style='color:#E63946'>**Bad**</span> (> 240 µg/m³): Health alert! Everyone may experience breathing difficulties. Avoid outdoor activities, especially during peak sunlight hours.
|
95 |
+
|
96 |
+
*Health Effects:* High levels can cause throat irritation, coughing, chest pain, and shortness of breath. Long-term exposure may lead to reduced lung function and chronic respiratory illness.
|
97 |
""",
|
98 |
unsafe_allow_html=True,
|
99 |
)
|
|
|
109 |
with st.expander("Learn more about NO2", expanded=False):
|
110 |
st.markdown(
|
111 |
"""
|
112 |
+
*Nitrogen Dioxide (NO<sub>2</sub>)* is primarily produced by vehicles and industrial processes.
|
113 |
+
|
114 |
+
**Levels interpretation:**
|
115 |
+
* <span style='color:#77C124'>**Good**</span> (< 40 µg/m³): Healthy air quality. No restrictions on outdoor activities.
|
116 |
+
* <span style='color:#E68B0A'>**Medium**</span> (40-80 µg/m³): Moderate pollution. Sensitive individuals should consider reducing prolonged outdoor exertion.
|
117 |
+
* <span style='color:#E63946'>**Bad**</span> (> 80 µg/m³): Poor air quality. Everyone should reduce outdoor activities, particularly near high-traffic areas.
|
118 |
+
|
119 |
+
*Health Effects:* Can inflame airways, aggravate asthma, and increase susceptibility to respiratory infections. Long-term exposure may affect lung development in children and contribute to heart disease.
|
120 |
""",
|
121 |
unsafe_allow_html=True,
|
122 |
)
|
|
|
181 |
)
|
182 |
)
|
183 |
|
184 |
+
# Add legend annotations
|
185 |
+
fig_o3.add_annotation(
|
186 |
+
x=1, y=1,
|
187 |
+
xref="paper", yref="paper",
|
188 |
+
text="<span style='color:#77C124'>■</span> Good",
|
189 |
+
showarrow=False,
|
190 |
+
yshift=10,
|
191 |
+
xshift=-10,
|
192 |
+
align="right"
|
193 |
+
)
|
194 |
+
fig_o3.add_annotation(
|
195 |
+
x=1, y=1,
|
196 |
+
xref="paper", yref="paper",
|
197 |
+
text="<span style='color:#E68B0A'>■</span> Medium",
|
198 |
+
showarrow=False,
|
199 |
+
yshift=-10,
|
200 |
+
xshift=-10,
|
201 |
+
align="right"
|
202 |
+
)
|
203 |
+
fig_o3.add_annotation(
|
204 |
+
x=1, y=1,
|
205 |
+
xref="paper", yref="paper",
|
206 |
+
text="<span style='color:#E63946'>■</span> Bad",
|
207 |
+
showarrow=False,
|
208 |
+
yshift=-30,
|
209 |
+
xshift=-10,
|
210 |
+
align="right"
|
211 |
+
)
|
212 |
+
|
213 |
fig_o3.update_layout(
|
214 |
plot_bgcolor="rgba(0, 0, 0, 0)",
|
215 |
paper_bgcolor="rgba(0, 0, 0, 0)",
|
|
|
226 |
tickcolor="gray",
|
227 |
),
|
228 |
showlegend=False, # Disable legend
|
229 |
+
margin=dict(r=100) # Add right margin for legend
|
230 |
)
|
231 |
|
232 |
st.plotly_chart(fig_o3, key="fig_o3")
|
|
|
277 |
)
|
278 |
)
|
279 |
|
280 |
+
# Add legend annotations
|
281 |
+
fig_no2.add_annotation(
|
282 |
+
x=1, y=1,
|
283 |
+
xref="paper", yref="paper",
|
284 |
+
text="<span style='color:#77C124'>■</span> Good",
|
285 |
+
showarrow=False,
|
286 |
+
yshift=10,
|
287 |
+
xshift=-10,
|
288 |
+
align="right"
|
289 |
+
)
|
290 |
+
fig_no2.add_annotation(
|
291 |
+
x=1, y=1,
|
292 |
+
xref="paper", yref="paper",
|
293 |
+
text="<span style='color:#E68B0A'>■</span> Medium",
|
294 |
+
showarrow=False,
|
295 |
+
yshift=-10,
|
296 |
+
xshift=-10,
|
297 |
+
align="right"
|
298 |
+
)
|
299 |
+
fig_no2.add_annotation(
|
300 |
+
x=1, y=1,
|
301 |
+
xref="paper", yref="paper",
|
302 |
+
text="<span style='color:#E63946'>■</span> Bad",
|
303 |
+
showarrow=False,
|
304 |
+
yshift=-30,
|
305 |
+
xshift=-10,
|
306 |
+
align="right"
|
307 |
+
)
|
308 |
+
|
309 |
fig_no2.update_layout(
|
310 |
plot_bgcolor="rgba(0, 0, 0, 0)",
|
311 |
paper_bgcolor="rgba(0, 0, 0, 0)",
|
|
|
322 |
tickcolor="gray",
|
323 |
),
|
324 |
showlegend=False, # Disable legend
|
325 |
+
margin=dict(r=100) # Add right margin for legend
|
326 |
)
|
327 |
|
328 |
st.plotly_chart(fig_no2, key="fig_no2")
|
predictions_history.csv
CHANGED
@@ -1,12 +1,6 @@
|
|
1 |
pollutant,date_predicted,date,prediction_value
|
2 |
-
O3,2025-03-07,2025-03-08,37.82937461928374
|
3 |
-
NO2,2025-03-07,2025-03-08,18.27364918273649
|
4 |
-
O3,2025-03-07,2025-03-09,40.17283746918274
|
5 |
-
NO2,2025-03-07,2025-03-09,15.82736491827365
|
6 |
O3,2025-03-07,2025-03-10,29.12736491827365
|
7 |
NO2,2025-03-07,2025-03-10,32.17283746918274
|
8 |
-
O3,2025-03-08,2025-03-09,35.28374691827365
|
9 |
-
NO2,2025-03-08,2025-03-09,14.72837469182736
|
10 |
O3,2025-03-08,2025-03-10,24.83746918273649
|
11 |
NO2,2025-03-08,2025-03-10,29.18273649182736
|
12 |
O3,2025-03-08,2025-03-11,48.17283746918274
|
|
|
1 |
pollutant,date_predicted,date,prediction_value
|
|
|
|
|
|
|
|
|
2 |
O3,2025-03-07,2025-03-10,29.12736491827365
|
3 |
NO2,2025-03-07,2025-03-10,32.17283746918274
|
|
|
|
|
4 |
O3,2025-03-08,2025-03-10,24.83746918273649
|
5 |
NO2,2025-03-08,2025-03-10,29.18273649182736
|
6 |
O3,2025-03-08,2025-03-11,48.17283746918274
|
src/helper_functions.py
CHANGED
@@ -45,29 +45,29 @@ def pollution_box(label: str, value: str, delta: str, threshold: float) -> None:
|
|
45 |
"""
|
46 |
Create a pollution metric box with a side-by-side layout and fixed width.
|
47 |
|
48 |
-
This function generates a styled markdown box displaying pollution level status, value, and other related information.
|
49 |
-
|
50 |
Parameters:
|
51 |
----------
|
52 |
label : str
|
53 |
The text label representing the type of pollution or metric.
|
54 |
-
|
55 |
value : str
|
56 |
-
The value of the pollution metric
|
57 |
-
|
58 |
delta : str
|
59 |
-
|
60 |
-
|
61 |
threshold : float
|
62 |
-
The threshold value to determine
|
63 |
-
|
64 |
-
Returns:
|
65 |
-
-------
|
66 |
-
None
|
67 |
"""
|
68 |
-
|
69 |
-
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
# Render the pollution box
|
73 |
st.markdown(
|
@@ -82,9 +82,9 @@ def pollution_box(label: str, value: str, delta: str, threshold: float) -> None:
|
|
82 |
padding: 15px;
|
83 |
margin-bottom: 10px;
|
84 |
">
|
85 |
-
<h4 style="font-size: 24px; font-weight: bold; margin: 0;">{label}</h4>
|
86 |
-
<p style="font-size: 36px; font-weight: bold; color: {status_color}; margin: 0;">{status}</p>
|
87 |
-
<p style="font-size: 18px; margin: 0;">{value}</p>
|
88 |
</div>
|
89 |
""",
|
90 |
unsafe_allow_html=True,
|
|
|
45 |
"""
|
46 |
Create a pollution metric box with a side-by-side layout and fixed width.
|
47 |
|
|
|
|
|
48 |
Parameters:
|
49 |
----------
|
50 |
label : str
|
51 |
The text label representing the type of pollution or metric.
|
|
|
52 |
value : str
|
53 |
+
The value of the pollution metric.
|
|
|
54 |
delta : str
|
55 |
+
The change in pollution level.
|
|
|
56 |
threshold : float
|
57 |
+
The threshold value to determine pollution level status.
|
|
|
|
|
|
|
|
|
58 |
"""
|
59 |
+
current_value = float(value.split()[0])
|
60 |
+
|
61 |
+
# Determine status and color based on the same logic as get_simple_color_scale
|
62 |
+
if current_value < threshold:
|
63 |
+
status = "Good"
|
64 |
+
status_color = "#77C124"
|
65 |
+
elif current_value < 2 * threshold:
|
66 |
+
status = "Medium"
|
67 |
+
status_color = "#E68B0A"
|
68 |
+
else:
|
69 |
+
status = "Bad"
|
70 |
+
status_color = "#E63946"
|
71 |
|
72 |
# Render the pollution box
|
73 |
st.markdown(
|
|
|
82 |
padding: 15px;
|
83 |
margin-bottom: 10px;
|
84 |
">
|
85 |
+
<h4 style="font-size: 24px; font-weight: bold; margin: 0;">{label}</h4>
|
86 |
+
<p style="font-size: 36px; font-weight: bold; color: {status_color}; margin: 0;">{status}</p>
|
87 |
+
<p style="font-size: 18px; margin: 0;">{value}</p>
|
88 |
</div>
|
89 |
""",
|
90 |
unsafe_allow_html=True,
|