Spaces:
Running
Running
Commit
·
0d3291a
1
Parent(s):
4aff08b
Add functions to display equivalents with page navigation button
Browse files- src/impacts.py +85 -0
src/impacts.py
CHANGED
|
@@ -128,3 +128,88 @@ def display_equivalent(impacts):
|
|
| 128 |
st.markdown(f'<h4 align="center">✈️ {round(paris_nyc_airplane.magnitude):,} Paris ↔ NYC</h4>', unsafe_allow_html = True)
|
| 129 |
st.markdown(f'<p align="center"><i>Based on GHG emissions<i></p>', unsafe_allow_html = True)
|
| 130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
st.markdown(f'<h4 align="center">✈️ {round(paris_nyc_airplane.magnitude):,} Paris ↔ NYC</h4>', unsafe_allow_html = True)
|
| 129 |
st.markdown(f'<p align="center"><i>Based on GHG emissions<i></p>', unsafe_allow_html = True)
|
| 130 |
|
| 131 |
+
def display_equivalent_energy(impacts):
|
| 132 |
+
st.markdown('<br>', unsafe_allow_html = True)
|
| 133 |
+
|
| 134 |
+
ev_eq = format_energy_eq_electric_vehicle(impacts.energy)
|
| 135 |
+
|
| 136 |
+
col1, col2, col3 = st.columns(3)
|
| 137 |
+
|
| 138 |
+
with col2:
|
| 139 |
+
physical_activity, distance = format_energy_eq_physical_activity(impacts.energy)
|
| 140 |
+
if physical_activity == PhysicalActivity.WALKING:
|
| 141 |
+
physical_activity = "🚶 " + physical_activity.capitalize()
|
| 142 |
+
if physical_activity == PhysicalActivity.RUNNING:
|
| 143 |
+
physical_activity = "🏃 " + physical_activity.capitalize()
|
| 144 |
+
|
| 145 |
+
st.markdown(f'<h4 align="center">{physical_activity}</h4>', unsafe_allow_html = True)
|
| 146 |
+
st.markdown(f"""<p style='font-size:35px;text-align: center'>≈ {distance.magnitude:.3g} <i>{distance.units} </p>""", unsafe_allow_html = True)
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
with col3:
|
| 150 |
+
ev_eq = format_energy_eq_electric_vehicle(impacts.energy)
|
| 151 |
+
st.markdown(f"""<p style='font-size:30px;text-align: center;margin-bottom :2px'><strong>🔋 Electric Vehicle</p>""", unsafe_allow_html = True)
|
| 152 |
+
st.markdown(f"""<p style='font-size:35px;text-align: center'>≈ {ev_eq.magnitude:.3g} <i>{ev_eq.units} </p>""", unsafe_allow_html = True)
|
| 153 |
+
|
| 154 |
+
with col1:
|
| 155 |
+
st.markdown(f"""<p style='font-size:30px;text-align: center;margin-bottom :2px'><strong>⚡️Energy</p>""", unsafe_allow_html = True)
|
| 156 |
+
st.markdown(f"""<p style='font-size:35px;text-align: center'> {impacts.energy.magnitude:.3g} {impacts.energy.units} </p>""", unsafe_allow_html = True)
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
st.divider()
|
| 160 |
+
|
| 161 |
+
st.markdown('<h3 align="center">What if 1% of the planet does the same everyday for 1 year ?</h3>', unsafe_allow_html = True)
|
| 162 |
+
st.markdown(f"""<p align="center"> {impacts.energy.magnitude:.3g} {impacts.energy.units} x 1% of 8 billion people x 365 days are ≈ equivalent to</p><br>""", unsafe_allow_html = True)
|
| 163 |
+
|
| 164 |
+
col4, col5, col6 = st.columns(3)
|
| 165 |
+
|
| 166 |
+
with col4:
|
| 167 |
+
|
| 168 |
+
electricity_production, count = format_energy_eq_electricity_production(impacts.energy)
|
| 169 |
+
if electricity_production == EnergyProduction.NUCLEAR:
|
| 170 |
+
emoji = "☢️"
|
| 171 |
+
name = "Nuclear power plants"
|
| 172 |
+
if electricity_production == EnergyProduction.WIND:
|
| 173 |
+
emoji = "💨️ "
|
| 174 |
+
name = "Wind turbines"
|
| 175 |
+
st.markdown(f'<h4 align="center">{emoji} {count.magnitude:.0f} {name} </h4>', unsafe_allow_html = True)
|
| 176 |
+
st.markdown(f'<p align="center">Energy produced yearly </p>', unsafe_allow_html = True)
|
| 177 |
+
|
| 178 |
+
with col5:
|
| 179 |
+
ireland_count = format_energy_eq_electricity_consumption_ireland(impacts.energy)
|
| 180 |
+
st.markdown(f'<h4 align="center">⚡️ 🇮🇪 {ireland_count.magnitude:.3f} x Ireland </h4>', unsafe_allow_html = True)
|
| 181 |
+
st.markdown(f'<p align="center">Yearly electricity consumption</p>', unsafe_allow_html = True)
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
def display_equivalent_ghg(impacts):
|
| 185 |
+
st.markdown('<br>', unsafe_allow_html = True)
|
| 186 |
+
|
| 187 |
+
streaming_eq = format_gwp_eq_streaming(impacts.gwp)
|
| 188 |
+
|
| 189 |
+
col1, col2, col3 = st.columns(3)
|
| 190 |
+
|
| 191 |
+
|
| 192 |
+
with col1:
|
| 193 |
+
|
| 194 |
+
st.markdown(f"""<p style='font-size:30px;text-align: center;margin-bottom :2px'><strong>🌍️GHG Emissions</p>""", unsafe_allow_html = True)
|
| 195 |
+
st.markdown(f"""<p style='font-size:35px;text-align: center'> {impacts.gwp.magnitude:.3g} {impacts.gwp.units} </p>""", unsafe_allow_html = True)
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
with col2:
|
| 199 |
+
streaming_eq = format_gwp_eq_streaming(impacts.gwp)
|
| 200 |
+
st.markdown(f"""<p style='font-size:30px;text-align: center;margin-bottom :2px'><strong>⏯️ Streaming</p>""", unsafe_allow_html = True)
|
| 201 |
+
st.markdown(f"""<p style='font-size:35px;text-align: center'>≈ {streaming_eq.magnitude:.3g} <i>{streaming_eq.units} </p>""", unsafe_allow_html = True)
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
st.divider()
|
| 205 |
+
|
| 206 |
+
st.markdown('<h3 align="center">What if 1% of the planet does the same everyday for 1 year ?</h3>', unsafe_allow_html = True)
|
| 207 |
+
st.markdown(f"""<p align="center"> {impacts.gwp.magnitude:.3g} {impacts.gwp.units} x 1% of 8 billion people x 365 days are ≈ equivalent to</p><br>""", unsafe_allow_html = True)
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
col4, col5, col6 = st.columns(3)
|
| 211 |
+
|
| 212 |
+
with col5:
|
| 213 |
+
paris_nyc_airplane = format_gwp_eq_airplane_paris_nyc(impacts.gwp)
|
| 214 |
+
st.markdown(f'<h4 align="center">✈️ {round(paris_nyc_airplane.magnitude):,} Paris ↔ NYC</h4>', unsafe_allow_html = True)
|
| 215 |
+
st.markdown(f'<p align="center"><i>Based on GHG emissions<i></p>', unsafe_allow_html = True)
|