import streamlit as st from src.utils import ( format_energy_eq_electric_vehicle, format_energy_eq_electricity_consumption_ireland, format_energy_eq_electricity_production, format_energy_eq_physical_activity, format_gwp_eq_airplane_paris_nyc, format_gwp_eq_streaming, range_plot, PhysicalActivity, EnergyProduction, ) ############################################################################################################ def get_impacts(model, active_params, total_params, mix_ghg, mix_adpe, mix_pe): return 1 ############################################################################################################ def display_impacts(impacts): st.divider() col1, col_energy, col_ghg, col2 = st.columns([1,2,2,1]) with col_energy: st.markdown(f"""

โšก๏ธ

Energy

""", unsafe_allow_html = True) st.markdown(f'

Electricity consumption

', unsafe_allow_html = True) range_plot(impacts.energy.magnitude,impacts.energy_min.magnitude, impacts.energy_max.magnitude, impacts.energy.units) with col_ghg: st.markdown(f"""

๐ŸŒ๏ธ

GHG Emissions

""", unsafe_allow_html = True) st.markdown(f'

Effect on global warming

', unsafe_allow_html = True) range_plot(impacts.gwp.magnitude,impacts.gwp_min.magnitude, impacts.gwp_max.magnitude, impacts.gwp.units) st.markdown(f'
', unsafe_allow_html = True) col_adpe, col_pe, col_water = st.columns(3) with col_adpe: st.markdown(f"""

๐Ÿชจ

""", unsafe_allow_html = True) st.markdown(f"""

Abiotic Resources

""", unsafe_allow_html = True) st.markdown('

Use of metals and minerals

', unsafe_allow_html = True) range_plot(impacts.adpe.magnitude,impacts.adpe_min.magnitude, impacts.adpe_max.magnitude, impacts.adpe.units) with col_pe: st.markdown(f"""

โ›ฝ๏ธ

""", unsafe_allow_html = True) st.markdown(f"""

Primary Energy

""", unsafe_allow_html = True) st.markdown(f'

Use of natural energy resources

', unsafe_allow_html = True) range_plot(impacts.pe.magnitude,impacts.pe_min.magnitude, impacts.pe_max.magnitude, impacts.pe.units) with col_water: st.markdown(f"""

๐Ÿšฐ

""", unsafe_allow_html = True) st.markdown(f"""

Water

""", unsafe_allow_html = True) st.markdown(f'

Evaluates the use of water

', unsafe_allow_html = True) st.markdown(f"""

Upcoming...

""", unsafe_allow_html = True) ############################################################################################################ def display_equivalent(impacts): st.divider() ev_eq = format_energy_eq_electric_vehicle(impacts.energy) streaming_eq = format_gwp_eq_streaming(impacts.gwp) col1, col2, col3 = st.columns(3) with col1: physical_activity, distance = format_energy_eq_physical_activity(impacts.energy) if physical_activity == PhysicalActivity.WALKING: physical_activity = "๐Ÿšถ " + physical_activity.capitalize() if physical_activity == PhysicalActivity.RUNNING: physical_activity = "๐Ÿƒ " + physical_activity.capitalize() st.markdown( f'

{physical_activity}

', unsafe_allow_html=True ) st.latex(f"\Large {distance.magnitude:.3g} \ \large {distance.units}") st.markdown( '

Based on energy consumption

', unsafe_allow_html=True, ) with col2: ev_eq = format_energy_eq_electric_vehicle(impacts.energy) st.markdown( '

๐Ÿ”‹ Electric Vehicle

', unsafe_allow_html=True ) st.latex(f"\Large {ev_eq.magnitude:.3g} \ \large {ev_eq.units}") st.markdown( '

Based on energy consumption

', unsafe_allow_html=True, ) with col3: streaming_eq = format_gwp_eq_streaming(impacts.gwp) st.markdown('

โฏ๏ธ Streaming

', unsafe_allow_html=True) st.latex(f"\Large {streaming_eq.magnitude:.3g} \ \large {streaming_eq.units}") st.markdown( '

Based on GHG emissions

', unsafe_allow_html=True, ) st.divider() st.markdown( '

What if 1% of the planet does this request everyday for 1 year ?

', unsafe_allow_html=True, ) st.markdown( '

If this use case is largely deployed around the world, the equivalent impacts would be the impacts of this request x 1% of 8 billion people x 365 days in a year.

', unsafe_allow_html=True, ) col4, col5, col6 = st.columns(3) with col4: electricity_production, count = format_energy_eq_electricity_production( impacts.energy ) if electricity_production == EnergyProduction.NUCLEAR: emoji = "โ˜ข๏ธ" name = "Nuclear power plants" if electricity_production == EnergyProduction.WIND: emoji = "๐Ÿ’จ๏ธ " name = "Wind turbines" st.markdown( f'

{emoji} {count.magnitude:.0f} {name} (yearly)

', unsafe_allow_html=True, ) st.markdown( '

Based on energy consumption

', unsafe_allow_html=True, ) with col5: ireland_count = format_energy_eq_electricity_consumption_ireland(impacts.energy) st.markdown( f'

๐Ÿ‡ฎ๐Ÿ‡ช {ireland_count.magnitude:.3f} x Ireland (yearly โšก๏ธ cons.)

', unsafe_allow_html=True, ) st.markdown( '

Based on energy consumption

', unsafe_allow_html=True, ) with col6: paris_nyc_airplane = format_gwp_eq_airplane_paris_nyc(impacts.gwp) st.markdown(f'

โœˆ๏ธ {round(paris_nyc_airplane.magnitude):,} Paris โ†” NYC

', unsafe_allow_html = True) st.markdown(f'

Based on GHG emissions

', unsafe_allow_html = True) def display_equivalent_energy(impacts): st.markdown('
', unsafe_allow_html = True) ev_eq = format_energy_eq_electric_vehicle(impacts.energy) col1, col2, col3 = st.columns(3) with col2: physical_activity, distance = format_energy_eq_physical_activity(impacts.energy) if physical_activity == PhysicalActivity.WALKING: physical_activity = "๐Ÿšถ " + physical_activity.capitalize() if physical_activity == PhysicalActivity.RUNNING: physical_activity = "๐Ÿƒ " + physical_activity.capitalize() st.markdown(f'

{physical_activity}

', unsafe_allow_html = True) st.markdown(f"""

โ‰ˆ {distance.magnitude:.3g} {distance.units}

""", unsafe_allow_html = True) with col3: ev_eq = format_energy_eq_electric_vehicle(impacts.energy) st.markdown(f"""

๐Ÿ”‹ Electric Vehicle

""", unsafe_allow_html = True) st.markdown(f"""

โ‰ˆ {ev_eq.magnitude:.3g} {ev_eq.units}

""", unsafe_allow_html = True) with col1: st.markdown(f"""

โšก๏ธEnergy

""", unsafe_allow_html = True) st.markdown(f"""

{impacts.energy.magnitude:.3g} {impacts.energy.units}

""", unsafe_allow_html = True) st.divider() st.markdown('

What if 1% of the planet does the same everyday for 1 year ?

', unsafe_allow_html = True) st.markdown(f"""

{impacts.energy.magnitude:.3g} {impacts.energy.units} x 1% of 8 billion people x 365 days are โ‰ˆ equivalent to


""", unsafe_allow_html = True) col4, col5, col6 = st.columns(3) with col4: electricity_production, count = format_energy_eq_electricity_production(impacts.energy) if electricity_production == EnergyProduction.NUCLEAR: emoji = "โ˜ข๏ธ" name = "Nuclear power plants" if electricity_production == EnergyProduction.WIND: emoji = "๐Ÿ’จ๏ธ " name = "Wind turbines" st.markdown(f'

{emoji} {count.magnitude:.0f} {name}

', unsafe_allow_html = True) st.markdown(f'

Energy produced yearly

', unsafe_allow_html = True) with col5: ireland_count = format_energy_eq_electricity_consumption_ireland(impacts.energy) st.markdown(f'

โšก๏ธ ๐Ÿ‡ฎ๐Ÿ‡ช {ireland_count.magnitude:.3f} x Ireland

', unsafe_allow_html = True) st.markdown(f'

Yearly electricity consumption

', unsafe_allow_html = True) def display_equivalent_ghg(impacts): st.markdown('
', unsafe_allow_html = True) streaming_eq = format_gwp_eq_streaming(impacts.gwp) col1, col2, col3 = st.columns(3) with col1: st.markdown(f"""

๐ŸŒ๏ธGHG Emissions

""", unsafe_allow_html = True) st.markdown(f"""

{impacts.gwp.magnitude:.3g} {impacts.gwp.units}

""", unsafe_allow_html = True) with col2: streaming_eq = format_gwp_eq_streaming(impacts.gwp) st.markdown(f"""

โฏ๏ธ Streaming

""", unsafe_allow_html = True) st.markdown(f"""

โ‰ˆ {streaming_eq.magnitude:.3g} {streaming_eq.units}

""", unsafe_allow_html = True) st.divider() st.markdown('

What if 1% of the planet does the same everyday for 1 year ?

', unsafe_allow_html = True) st.markdown(f"""

{impacts.gwp.magnitude:.3g} {impacts.gwp.units} x 1% of 8 billion people x 365 days are โ‰ˆ equivalent to


""", unsafe_allow_html = True) col4, col5, col6 = st.columns(3) with col5: paris_nyc_airplane = format_gwp_eq_airplane_paris_nyc(impacts.gwp) st.markdown(f'

โœˆ๏ธ {round(paris_nyc_airplane.magnitude):,} Paris โ†” NYC

', unsafe_allow_html = True) st.markdown(f'

Based on GHG emissions

', unsafe_allow_html = True)