added company mode
Browse files- app.py +11 -3
- src/__pycache__/calculator.cpython-311.pyc +0 -0
- src/__pycache__/company.cpython-311.pyc +0 -0
- src/__pycache__/content.cpython-311.pyc +0 -0
- src/__pycache__/electricity_mix.cpython-311.pyc +0 -0
- src/__pycache__/expert.cpython-311.pyc +0 -0
- src/__pycache__/impacts.cpython-311.pyc +0 -0
- src/__pycache__/models.cpython-311.pyc +0 -0
- src/__pycache__/utils.cpython-311.pyc +0 -0
- src/calculator.py +20 -20
- src/company.py +119 -0
- src/content.py +6 -2
- src/expert.py +33 -15
- src/impacts.py +385 -5
- src/utils.py +67 -4
app.py
CHANGED
|
@@ -4,7 +4,8 @@ from src.content import (
|
|
| 4 |
HERO_TEXT,
|
| 5 |
ABOUT_TEXT,
|
| 6 |
CITATION_LABEL,
|
| 7 |
-
|
|
|
|
| 8 |
LICENCE_TEXT,
|
| 9 |
INTRO_TEXT,
|
| 10 |
METHODOLOGY_TEXT
|
|
@@ -13,6 +14,7 @@ from src.content import (
|
|
| 13 |
from src.expert import expert_mode
|
| 14 |
from src.calculator import calculator_mode
|
| 15 |
from src.token_estimator import token_estimator
|
|
|
|
| 16 |
|
| 17 |
st.set_page_config(
|
| 18 |
layout="wide",
|
|
@@ -27,9 +29,10 @@ st.html(HERO_TEXT)
|
|
| 27 |
|
| 28 |
st.markdown(INTRO_TEXT)
|
| 29 |
|
| 30 |
-
tab_calculator, tab_expert, tab_token, tab_method, tab_about = st.tabs(
|
| 31 |
[
|
| 32 |
'🧮 Calculator',
|
|
|
|
| 33 |
'🤓 Expert Mode',
|
| 34 |
'🪙 Tokens estimator',
|
| 35 |
'📖 Methodology',
|
|
@@ -41,6 +44,10 @@ with tab_calculator:
|
|
| 41 |
|
| 42 |
calculator_mode()
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
with tab_expert:
|
| 45 |
|
| 46 |
expert_mode()
|
|
@@ -59,6 +66,7 @@ with tab_about:
|
|
| 59 |
|
| 60 |
with st.expander('📚 Citation'):
|
| 61 |
st.html(CITATION_LABEL)
|
| 62 |
-
st.html(
|
|
|
|
| 63 |
|
| 64 |
st.html(LICENCE_TEXT)
|
|
|
|
| 4 |
HERO_TEXT,
|
| 5 |
ABOUT_TEXT,
|
| 6 |
CITATION_LABEL,
|
| 7 |
+
CITATION_TEXT_CALCULATOR,
|
| 8 |
+
CITATION_TEXT_SOFTWARE,
|
| 9 |
LICENCE_TEXT,
|
| 10 |
INTRO_TEXT,
|
| 11 |
METHODOLOGY_TEXT
|
|
|
|
| 14 |
from src.expert import expert_mode
|
| 15 |
from src.calculator import calculator_mode
|
| 16 |
from src.token_estimator import token_estimator
|
| 17 |
+
from src.company import company_mode
|
| 18 |
|
| 19 |
st.set_page_config(
|
| 20 |
layout="wide",
|
|
|
|
| 29 |
|
| 30 |
st.markdown(INTRO_TEXT)
|
| 31 |
|
| 32 |
+
tab_calculator, tab_company, tab_expert, tab_token, tab_method, tab_about = st.tabs(
|
| 33 |
[
|
| 34 |
'🧮 Calculator',
|
| 35 |
+
'👩🏻💻 Companies',
|
| 36 |
'🤓 Expert Mode',
|
| 37 |
'🪙 Tokens estimator',
|
| 38 |
'📖 Methodology',
|
|
|
|
| 44 |
|
| 45 |
calculator_mode()
|
| 46 |
|
| 47 |
+
with tab_company:
|
| 48 |
+
|
| 49 |
+
company_mode()
|
| 50 |
+
|
| 51 |
with tab_expert:
|
| 52 |
|
| 53 |
expert_mode()
|
|
|
|
| 66 |
|
| 67 |
with st.expander('📚 Citation'):
|
| 68 |
st.html(CITATION_LABEL)
|
| 69 |
+
st.html(CITATION_TEXT_CALCULATOR)
|
| 70 |
+
st.html(CITATION_TEXT_SOFTWARE)
|
| 71 |
|
| 72 |
st.html(LICENCE_TEXT)
|
src/__pycache__/calculator.cpython-311.pyc
CHANGED
|
Binary files a/src/__pycache__/calculator.cpython-311.pyc and b/src/__pycache__/calculator.cpython-311.pyc differ
|
|
|
src/__pycache__/company.cpython-311.pyc
ADDED
|
Binary file (7.61 kB). View file
|
|
|
src/__pycache__/content.cpython-311.pyc
CHANGED
|
Binary files a/src/__pycache__/content.cpython-311.pyc and b/src/__pycache__/content.cpython-311.pyc differ
|
|
|
src/__pycache__/electricity_mix.cpython-311.pyc
CHANGED
|
Binary files a/src/__pycache__/electricity_mix.cpython-311.pyc and b/src/__pycache__/electricity_mix.cpython-311.pyc differ
|
|
|
src/__pycache__/expert.cpython-311.pyc
CHANGED
|
Binary files a/src/__pycache__/expert.cpython-311.pyc and b/src/__pycache__/expert.cpython-311.pyc differ
|
|
|
src/__pycache__/impacts.cpython-311.pyc
CHANGED
|
Binary files a/src/__pycache__/impacts.cpython-311.pyc and b/src/__pycache__/impacts.cpython-311.pyc differ
|
|
|
src/__pycache__/models.cpython-311.pyc
CHANGED
|
Binary files a/src/__pycache__/models.cpython-311.pyc and b/src/__pycache__/models.cpython-311.pyc differ
|
|
|
src/__pycache__/utils.cpython-311.pyc
CHANGED
|
Binary files a/src/__pycache__/utils.cpython-311.pyc and b/src/__pycache__/utils.cpython-311.pyc differ
|
|
|
src/calculator.py
CHANGED
|
@@ -45,28 +45,28 @@ def calculator_mode():
|
|
| 45 |
if df_filtered['warning_arch'].values[0] and df_filtered['warning_multi_modal'].values[0]:
|
| 46 |
st.warning(WARNING_BOTH)
|
| 47 |
|
| 48 |
-
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
with st.container(border=True):
|
| 66 |
|
| 67 |
-
st.
|
| 68 |
-
st.markdown('<p align = "center">Making this request to the LLM is equivalent to the following actions :</p>', unsafe_allow_html=True)
|
| 69 |
-
display_equivalent(impacts, provider, location="🌎 World")
|
| 70 |
|
| 71 |
-
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
if df_filtered['warning_arch'].values[0] and df_filtered['warning_multi_modal'].values[0]:
|
| 46 |
st.warning(WARNING_BOTH)
|
| 47 |
|
| 48 |
+
try:
|
| 49 |
|
| 50 |
+
impacts = llm_impacts(
|
| 51 |
+
provider=provider_raw,
|
| 52 |
+
model_name=model_raw,
|
| 53 |
+
output_token_count=[x[1] for x in PROMPTS if x[0] == output_tokens][0],
|
| 54 |
+
request_latency=100000
|
| 55 |
+
)
|
| 56 |
|
| 57 |
+
impacts, _, _ = format_impacts(impacts)
|
| 58 |
+
|
| 59 |
+
with st.container(border=True):
|
| 60 |
|
| 61 |
+
st.markdown('<h3 align = "center">Environmental impacts</h3>', unsafe_allow_html=True)
|
| 62 |
+
st.markdown('<p align = "center">To understand how the environmental impacts are computed go to the 📖 Methodology tab.</p>', unsafe_allow_html=True)
|
| 63 |
+
display_impacts(impacts, provider, location="🌎 World")
|
|
|
|
|
|
|
| 64 |
|
| 65 |
+
with st.container(border=True):
|
|
|
|
|
|
|
| 66 |
|
| 67 |
+
st.markdown('<h3 align = "center">That\'s equivalent to ...</h3>', unsafe_allow_html=True)
|
| 68 |
+
st.markdown('<p align = "center">Making this request to the LLM is equivalent to the following actions :</p>', unsafe_allow_html=True)
|
| 69 |
+
display_equivalent(impacts, provider, location="🌎 World")
|
| 70 |
+
|
| 71 |
+
except Exception as e:
|
| 72 |
+
st.error('Could not find the model in the repository. Please try another model.')
|
src/company.py
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
from ecologits.tracers.utils import llm_impacts
|
| 4 |
+
from src.impacts import get_impacts, display_impacts_company, display_equivalent_company
|
| 5 |
+
from src.utils import format_impacts
|
| 6 |
+
from src.content import WARNING_CLOSED_SOURCE, WARNING_MULTI_MODAL, WARNING_BOTH
|
| 7 |
+
from src.models import load_models
|
| 8 |
+
|
| 9 |
+
from src.constants import PROMPTS
|
| 10 |
+
|
| 11 |
+
def company_mode():
|
| 12 |
+
|
| 13 |
+
st.markdown("### 👩🏻💻 Calculator for companies")
|
| 14 |
+
|
| 15 |
+
with st.container(border=True):
|
| 16 |
+
|
| 17 |
+
df = load_models(filter_main=True)
|
| 18 |
+
|
| 19 |
+
col1, col2, col3 = st.columns(3)
|
| 20 |
+
|
| 21 |
+
with col1:
|
| 22 |
+
provider = st.selectbox(
|
| 23 |
+
label = 'Provider',
|
| 24 |
+
options = [x for x in df['provider_clean'].unique()],
|
| 25 |
+
index = 7,
|
| 26 |
+
key = 61
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
with col2:
|
| 30 |
+
model = st.selectbox(
|
| 31 |
+
label = 'Model',
|
| 32 |
+
options = [x for x in df['name_clean'].unique() if x in df[df['provider_clean'] == provider]['name_clean'].unique()],
|
| 33 |
+
key = 62
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
with col3:
|
| 37 |
+
output_tokens = st.selectbox(
|
| 38 |
+
'Example prompt',
|
| 39 |
+
[x[0] for x in PROMPTS],
|
| 40 |
+
key = 63
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
# WARNING DISPLAY
|
| 44 |
+
provider_raw = df[(df['provider_clean'] == provider) & (df['name_clean'] == model)]['provider'].values[0]
|
| 45 |
+
model_raw = df[(df['provider_clean'] == provider) & (df['name_clean'] == model)]['name'].values[0]
|
| 46 |
+
|
| 47 |
+
df_filtered = df[(df['provider_clean'] == provider) & (df['name_clean'] == model)]
|
| 48 |
+
|
| 49 |
+
if df_filtered['warning_arch'].values[0] and not df_filtered['warning_multi_modal'].values[0]:
|
| 50 |
+
st.warning(WARNING_CLOSED_SOURCE)
|
| 51 |
+
if df_filtered['warning_multi_modal'].values[0] and not df_filtered['warning_arch'].values[0]:
|
| 52 |
+
st.warning(WARNING_MULTI_MODAL)
|
| 53 |
+
if df_filtered['warning_arch'].values[0] and df_filtered['warning_multi_modal'].values[0]:
|
| 54 |
+
st.warning(WARNING_BOTH)
|
| 55 |
+
|
| 56 |
+
col4, col5, col6 = st.columns(3)
|
| 57 |
+
|
| 58 |
+
with col4:
|
| 59 |
+
company_size = st.number_input(
|
| 60 |
+
label="Company size (in number of employees)",
|
| 61 |
+
min_value=1,
|
| 62 |
+
value=10, # valeur par défaut
|
| 63 |
+
step=1,
|
| 64 |
+
key = 64
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
+
#TODO : lire la literature pour comprendre des chiffres en moyen pour remplisser comme defaut
|
| 68 |
+
#par example, entre 400 - 800 > entreprise taille moyenne, frequence correspondant : ...
|
| 69 |
+
with col5:
|
| 70 |
+
use_percentage = st.number_input(
|
| 71 |
+
label = 'What percentage of employees use LLM daily (in %)?',
|
| 72 |
+
min_value=0,
|
| 73 |
+
max_value=100,
|
| 74 |
+
value=75, # valeur par défaut
|
| 75 |
+
step=5,
|
| 76 |
+
key = 65
|
| 77 |
+
)
|
| 78 |
+
|
| 79 |
+
#TODO : lire la literature pour comprendre des chiffres en moyen pour remplisser comme defaut
|
| 80 |
+
#par example, entre 400 - 800 > entreprise taille moyenne, frequence correspondant : ...
|
| 81 |
+
with col6:
|
| 82 |
+
request_frequency = st.number_input(
|
| 83 |
+
label = 'How frequently do the employees use LLM (times per day)?',
|
| 84 |
+
min_value=1,
|
| 85 |
+
value=20, # valeur par défaut
|
| 86 |
+
step=5,
|
| 87 |
+
key = 66
|
| 88 |
+
)
|
| 89 |
+
|
| 90 |
+
company_multiplier = company_size * use_percentage/100 * request_frequency
|
| 91 |
+
|
| 92 |
+
#try:
|
| 93 |
+
|
| 94 |
+
impacts = llm_impacts(
|
| 95 |
+
provider=provider_raw,
|
| 96 |
+
model_name=model_raw,
|
| 97 |
+
output_token_count=[x[1] for x in PROMPTS if x[0] == output_tokens][0],
|
| 98 |
+
request_latency=100000
|
| 99 |
+
)
|
| 100 |
+
|
| 101 |
+
impacts, _, _ = format_impacts(impacts)
|
| 102 |
+
|
| 103 |
+
#down here
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
with st.container(border=True):
|
| 107 |
+
|
| 108 |
+
st.markdown('<h3 align = "center">Environmental impacts</h3>', unsafe_allow_html=True)
|
| 109 |
+
st.markdown('<p align = "center">To understand how the environmental impacts are computed go to the 📖 Methodology tab.</p>', unsafe_allow_html=True)
|
| 110 |
+
display_impacts_company(impacts, provider, company_multiplier, location="🌎 World")
|
| 111 |
+
|
| 112 |
+
with st.container(border=True):
|
| 113 |
+
#TODO : corriger ça
|
| 114 |
+
st.markdown('<h3 align = "center">That\'s equivalent to ...</h3>', unsafe_allow_html=True)
|
| 115 |
+
st.markdown('<p align = "center">On the scale of the company, making this request to the LLM over a day is equivalent to the following actions :</p>', unsafe_allow_html=True)
|
| 116 |
+
display_equivalent_company(impacts, provider, company_multiplier, location="🌎 World")
|
| 117 |
+
|
| 118 |
+
#except Exception as e:
|
| 119 |
+
# st.error('Could not find the model in the repository. Please try another model.')
|
src/content.py
CHANGED
|
@@ -258,17 +258,21 @@ an Olympic-sized swimming pool holds about 2.5 million liters of water.
|
|
| 258 |
"""
|
| 259 |
|
| 260 |
CITATION_LABEL = "BibTeX citation for EcoLogits Calculator and the EcoLogits library:"
|
| 261 |
-
|
| 262 |
author={Samuel Rincé, Adrien Banse, Valentin Defour, and Chieh Hsu},
|
| 263 |
title={EcoLogits Calculator},
|
| 264 |
year={2025},
|
| 265 |
howpublished= {\url{https://huggingface.co/spaces/genai-impact/ecologits-calculator}},
|
| 266 |
}
|
|
|
|
|
|
|
|
|
|
| 267 |
@software{ecologits,
|
| 268 |
author = {Samuel Rincé, Adrien Banse, Vinh Nguyen, Luc Berton, and Chieh Hsu},
|
| 269 |
publisher = {GenAI Impact},
|
| 270 |
title = {EcoLogits: track the energy consumption and environmental footprint of using generative AI models through APIs.},
|
| 271 |
-
}
|
|
|
|
| 272 |
|
| 273 |
LICENCE_TEXT = """<p xmlns:cc="http://creativecommons.org/ns#" >
|
| 274 |
This work is licensed under
|
|
|
|
| 258 |
"""
|
| 259 |
|
| 260 |
CITATION_LABEL = "BibTeX citation for EcoLogits Calculator and the EcoLogits library:"
|
| 261 |
+
CITATION_TEXT_CALCULATOR = r"""@misc{ecologits-calculator,
|
| 262 |
author={Samuel Rincé, Adrien Banse, Valentin Defour, and Chieh Hsu},
|
| 263 |
title={EcoLogits Calculator},
|
| 264 |
year={2025},
|
| 265 |
howpublished= {\url{https://huggingface.co/spaces/genai-impact/ecologits-calculator}},
|
| 266 |
}
|
| 267 |
+
"""
|
| 268 |
+
|
| 269 |
+
CITATION_TEXT_SOFTWARE = r"""
|
| 270 |
@software{ecologits,
|
| 271 |
author = {Samuel Rincé, Adrien Banse, Vinh Nguyen, Luc Berton, and Chieh Hsu},
|
| 272 |
publisher = {GenAI Impact},
|
| 273 |
title = {EcoLogits: track the energy consumption and environmental footprint of using generative AI models through APIs.},
|
| 274 |
+
}
|
| 275 |
+
"""
|
| 276 |
|
| 277 |
LICENCE_TEXT = """<p xmlns:cc="http://creativecommons.org/ns#" >
|
| 278 |
This work is licensed under
|
src/expert.py
CHANGED
|
@@ -141,20 +141,19 @@ def expert_mode():
|
|
| 141 |
|
| 142 |
st.markdown('The usage impacts account for the electricity consumption of the model while the embodied impacts account for resource extraction (e.g., minerals and metals), manufacturing, and transportation of the hardware.')
|
| 143 |
|
| 144 |
-
col_ghg_comparison, col_adpe_comparison, col_pe_comparison = st.columns(
|
| 145 |
|
| 146 |
with col_ghg_comparison:
|
| 147 |
-
|
| 148 |
fig_gwp = px.pie(
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
)
|
| 155 |
fig_gwp.update_layout(
|
| 156 |
showlegend=False,
|
| 157 |
-
title_x=0.
|
| 158 |
|
| 159 |
st.plotly_chart(fig_gwp)
|
| 160 |
|
|
@@ -163,13 +162,18 @@ def expert_mode():
|
|
| 163 |
values = [average_range_impacts(usage.adpe.value), average_range_impacts(embodied.adpe.value)],
|
| 164 |
names = ['usage', 'embodied'],
|
| 165 |
title = 'Abiotic depletion',
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
fig_adpe.update_layout(
|
| 170 |
showlegend=False,
|
| 171 |
-
title_x=0.
|
| 172 |
-
|
|
|
|
| 173 |
st.plotly_chart(fig_adpe)
|
| 174 |
|
| 175 |
with col_pe_comparison:
|
|
@@ -178,14 +182,28 @@ def expert_mode():
|
|
| 178 |
names = ['usage', 'embodied'],
|
| 179 |
title = 'Primary energy',
|
| 180 |
color_discrete_sequence=["#00BF63", "#0B3B36"],
|
| 181 |
-
width =
|
| 182 |
)
|
| 183 |
fig_pe.update_layout(
|
| 184 |
showlegend=False,
|
| 185 |
-
title_x=0.
|
| 186 |
|
| 187 |
st.plotly_chart(fig_pe)
|
| 188 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
with st.expander('🌍️ Location impact'):
|
| 190 |
|
| 191 |
st.markdown('<h4 align="center">How can location impact the footprint ?</h4>', unsafe_allow_html = True)
|
|
|
|
| 141 |
|
| 142 |
st.markdown('The usage impacts account for the electricity consumption of the model while the embodied impacts account for resource extraction (e.g., minerals and metals), manufacturing, and transportation of the hardware.')
|
| 143 |
|
| 144 |
+
col_ghg_comparison, col_adpe_comparison, col_pe_comparison, col_water_comparison = st.columns(4)
|
| 145 |
|
| 146 |
with col_ghg_comparison:
|
|
|
|
| 147 |
fig_gwp = px.pie(
|
| 148 |
+
values = [average_range_impacts(usage.gwp.value), average_range_impacts(embodied.gwp.value)],
|
| 149 |
+
names = ['usage', 'embodied'],
|
| 150 |
+
title = 'GHG emissions',
|
| 151 |
+
color_discrete_sequence=["#00BF63", "#0B3B36"],
|
| 152 |
+
width = 300
|
| 153 |
)
|
| 154 |
fig_gwp.update_layout(
|
| 155 |
showlegend=False,
|
| 156 |
+
title_x=0.1)
|
| 157 |
|
| 158 |
st.plotly_chart(fig_gwp)
|
| 159 |
|
|
|
|
| 162 |
values = [average_range_impacts(usage.adpe.value), average_range_impacts(embodied.adpe.value)],
|
| 163 |
names = ['usage', 'embodied'],
|
| 164 |
title = 'Abiotic depletion',
|
| 165 |
+
color = ['usage', 'embodied'], # Associe chaque valeur à un label pour la couleur
|
| 166 |
+
color_discrete_map={
|
| 167 |
+
'usage': '#00BF63',
|
| 168 |
+
'embodied': '#0B3B36'
|
| 169 |
+
},
|
| 170 |
+
width = 300
|
| 171 |
+
)
|
| 172 |
fig_adpe.update_layout(
|
| 173 |
showlegend=False,
|
| 174 |
+
title_x=0.05
|
| 175 |
+
)
|
| 176 |
+
|
| 177 |
st.plotly_chart(fig_adpe)
|
| 178 |
|
| 179 |
with col_pe_comparison:
|
|
|
|
| 182 |
names = ['usage', 'embodied'],
|
| 183 |
title = 'Primary energy',
|
| 184 |
color_discrete_sequence=["#00BF63", "#0B3B36"],
|
| 185 |
+
width = 300
|
| 186 |
)
|
| 187 |
fig_pe.update_layout(
|
| 188 |
showlegend=False,
|
| 189 |
+
title_x=0.1)
|
| 190 |
|
| 191 |
st.plotly_chart(fig_pe)
|
| 192 |
|
| 193 |
+
with col_water_comparison:
|
| 194 |
+
fig_water = px.pie(
|
| 195 |
+
values = [average_range_impacts(usage.water.value), average_range_impacts(embodied.water.value)],
|
| 196 |
+
names = ['usage', 'embodied'],
|
| 197 |
+
title = 'Water',
|
| 198 |
+
color_discrete_sequence=["#00BF63", "#0B3B36"],
|
| 199 |
+
width = 300
|
| 200 |
+
)
|
| 201 |
+
fig_water.update_layout(
|
| 202 |
+
showlegend=False,
|
| 203 |
+
title_x=0.3)
|
| 204 |
+
|
| 205 |
+
st.plotly_chart(fig_water)
|
| 206 |
+
|
| 207 |
with st.expander('🌍️ Location impact'):
|
| 208 |
|
| 209 |
st.markdown('<h4 align="center">How can location impact the footprint ?</h4>', unsafe_allow_html = True)
|
src/impacts.py
CHANGED
|
@@ -9,6 +9,14 @@ from src.utils import (
|
|
| 9 |
format_gwp_eq_streaming,
|
| 10 |
format_water_eq_bottled_waters,
|
| 11 |
format_water_eq_olympic_sized_swimming_pool,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
PhysicalActivity,
|
| 13 |
EnergyProduction,
|
| 14 |
AI_COMPANY_TO_DATA_CENTER_PROVIDER,
|
|
@@ -67,7 +75,23 @@ def display_impacts(impacts, provider, location):
|
|
| 67 |
<div style="font-size: 16px;">Abiotic Resources</div>
|
| 68 |
</div>
|
| 69 |
""", unsafe_allow_html = True)
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
st.markdown("""
|
| 72 |
<div style="text-align: center;"><i>Evaluates the use of metals and minerals<i>
|
| 73 |
</div>
|
|
@@ -101,6 +125,154 @@ def display_impacts(impacts, provider, location):
|
|
| 101 |
""", unsafe_allow_html = True)
|
| 102 |
|
| 103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
############################################################################################################
|
| 105 |
|
| 106 |
def display_equivalent(impacts, provider, location):
|
|
@@ -182,21 +354,229 @@ def display_equivalent(impacts, provider, location):
|
|
| 182 |
if electricity_production == EnergyProduction.WIND:
|
| 183 |
emoji = "💨️ "
|
| 184 |
name = "Wind turbines"
|
| 185 |
-
st.markdown(f
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
st.markdown(f'<p align="center"><i>Based on energy consumption<i></p>', unsafe_allow_html = True)
|
| 187 |
|
| 188 |
with col6:
|
| 189 |
ireland_count = format_energy_eq_electricity_consumption_ireland(impacts.energy)
|
| 190 |
-
st.markdown(f
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
st.markdown(f'<p align="center"><i>Based on energy consumption<i></p>', unsafe_allow_html = True)
|
| 192 |
|
| 193 |
with col7:
|
| 194 |
paris_nyc_airplane = format_gwp_eq_airplane_paris_nyc(impacts.gwp)
|
| 195 |
-
st.markdown(f
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
st.markdown(f'<p align="center"><i>Based on GHG emissions<i></p>', unsafe_allow_html = True)
|
| 197 |
|
| 198 |
with col8:
|
| 199 |
olympic_swimming_pool = format_water_eq_olympic_sized_swimming_pool(impacts.water)
|
| 200 |
-
st.markdown(f
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
st.markdown(f'<p align="center"><i>Based on water consumption<i></p>', unsafe_allow_html = True)
|
| 202 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
format_gwp_eq_streaming,
|
| 10 |
format_water_eq_bottled_waters,
|
| 11 |
format_water_eq_olympic_sized_swimming_pool,
|
| 12 |
+
format_energy_eq_electricity_production_company,
|
| 13 |
+
format_energy_eq_electricity_consumption_ireland_company,
|
| 14 |
+
format_gwp_eq_airplane_paris_nyc_company,
|
| 15 |
+
format_water_eq_olympic_sized_swimming_pool_company,
|
| 16 |
+
format_energy_eq_physical_activity_company,
|
| 17 |
+
format_gwp_eq_streaming_company,
|
| 18 |
+
format_energy_eq_electric_vehicle_company,
|
| 19 |
+
format_water_eq_bottled_waters_company,
|
| 20 |
PhysicalActivity,
|
| 21 |
EnergyProduction,
|
| 22 |
AI_COMPANY_TO_DATA_CENTER_PROVIDER,
|
|
|
|
| 75 |
<div style="font-size: 16px;">Abiotic Resources</div>
|
| 76 |
</div>
|
| 77 |
""", unsafe_allow_html = True)
|
| 78 |
+
company_impact = impacts.adpe.magnitude
|
| 79 |
+
impacts_adpe_units = impacts.adpe.units
|
| 80 |
+
#errornique
|
| 81 |
+
if company_impact <= 1 and impacts_adpe_units == "kgSbeq":
|
| 82 |
+
company_impact *= 1000
|
| 83 |
+
impacts_adpe_units = "gSbeq"
|
| 84 |
+
if company_impact <= 1 and impacts_adpe_units == "gSbeq":
|
| 85 |
+
company_impact *= 1000
|
| 86 |
+
impacts_adpe_units = "mgSbeq"
|
| 87 |
+
if company_impact <= 1 and impacts_adpe_units == "mgSbeq":
|
| 88 |
+
company_impact *= 1000
|
| 89 |
+
impacts_adpe_units = "μSbeq"
|
| 90 |
+
################################################
|
| 91 |
+
if company_impact >= 1000 and impacts_adpe_units == "kgSbeq":
|
| 92 |
+
company_impact /= 1000
|
| 93 |
+
impacts_adpe_units = "tSbeq"
|
| 94 |
+
st.latex(f'\Large {company_impact:.3g} \ \large {impacts_adpe_units}')
|
| 95 |
st.markdown("""
|
| 96 |
<div style="text-align: center;"><i>Evaluates the use of metals and minerals<i>
|
| 97 |
</div>
|
|
|
|
| 125 |
""", unsafe_allow_html = True)
|
| 126 |
|
| 127 |
|
| 128 |
+
#################################################################################################
|
| 129 |
+
def display_impacts_company(impacts, provider, company_multiplier, location):
|
| 130 |
+
|
| 131 |
+
st.divider()
|
| 132 |
+
|
| 133 |
+
col_energy, col_ghg, col_adpe, col_pe, col_water = st.columns(5)
|
| 134 |
+
|
| 135 |
+
with col_energy:
|
| 136 |
+
st.markdown("""
|
| 137 |
+
<div style="text-align: center;">
|
| 138 |
+
<div style="font-size: 30px;">⚡️</div>
|
| 139 |
+
<div style="font-size: 25px;">Energy</div>
|
| 140 |
+
</div>
|
| 141 |
+
""", unsafe_allow_html = True)
|
| 142 |
+
company_impact = impacts.energy.magnitude * company_multiplier
|
| 143 |
+
impacts_energy_units = impacts.energy.units
|
| 144 |
+
if company_impact >= 1000 and impacts_energy_units == "Wh":
|
| 145 |
+
company_impact /= 1000
|
| 146 |
+
impacts_energy_units = "kWh"
|
| 147 |
+
if company_impact >= 1000 and impacts_energy_units == "kWh":
|
| 148 |
+
company_impact /= 1000
|
| 149 |
+
impacts_energy_units = "MWh"
|
| 150 |
+
if company_impact >= 1000 and impacts_energy_units == "MWh":
|
| 151 |
+
company_impact /= 1000
|
| 152 |
+
impacts_energy_units = "GWh"
|
| 153 |
+
if company_impact >= 1000 and impacts_energy_units == "GWh":
|
| 154 |
+
company_impact /= 1000
|
| 155 |
+
impacts_energy_units = "TWh"
|
| 156 |
+
if company_impact >= 1000 and impacts_energy_units == "TWh":
|
| 157 |
+
company_impact /= 1000
|
| 158 |
+
impacts_energy_units = "PWh"
|
| 159 |
+
st.latex(f'\Large {company_impact:.3g} \ \large {impacts_energy_units}')
|
| 160 |
+
st.markdown("""
|
| 161 |
+
<div style="height: 10px;"></div>
|
| 162 |
+
<div style="text-align: center;"><i>Evaluates the electricity consumption<i>
|
| 163 |
+
</div>
|
| 164 |
+
""", unsafe_allow_html = True)
|
| 165 |
+
|
| 166 |
+
with col_ghg:
|
| 167 |
+
st.markdown("""
|
| 168 |
+
<div style="text-align: center;">
|
| 169 |
+
<div style="font-size: 30px;">🌍️</div>
|
| 170 |
+
<div style="font-size: 18px;">GHG Emissions</div>
|
| 171 |
+
</div>
|
| 172 |
+
""", unsafe_allow_html = True)
|
| 173 |
+
impacts_ghg_units = impacts.gwp.units
|
| 174 |
+
company_impact = impacts.gwp.magnitude * company_multiplier
|
| 175 |
+
if company_impact >= 1000 and impacts_ghg_units == "gCO2eq":
|
| 176 |
+
company_impact /= 1000
|
| 177 |
+
impacts_ghg_units = "kgCO2eq"
|
| 178 |
+
if company_impact >= 1000 and impacts_ghg_units == "kgCO2eq":
|
| 179 |
+
company_impact /= 1000
|
| 180 |
+
impacts_ghg_units = "tCO2eq"
|
| 181 |
+
st.latex(f'\Large {company_impact:.3g} \ \large {impacts_ghg_units}')
|
| 182 |
+
st.markdown("""
|
| 183 |
+
<div style="text-align: center;"><i>Evaluates the effect on climate change<i>
|
| 184 |
+
</div>
|
| 185 |
+
""", unsafe_allow_html = True)
|
| 186 |
+
|
| 187 |
+
with col_adpe:
|
| 188 |
+
st.markdown("""
|
| 189 |
+
<div style="text-align: center;">
|
| 190 |
+
<div style="font-size: 30px;">🪨</div>
|
| 191 |
+
<div style="font-size: 16px;">Abiotic Resources</div>
|
| 192 |
+
</div>
|
| 193 |
+
""", unsafe_allow_html = True)
|
| 194 |
+
company_impact = impacts.adpe.magnitude * company_multiplier
|
| 195 |
+
impacts_adpe_units = impacts.adpe.units
|
| 196 |
+
if company_impact <= 1 and impacts_adpe_units == "kgSbeq":
|
| 197 |
+
company_impact *= 1000
|
| 198 |
+
impacts_adpe_units = "gSbeq"
|
| 199 |
+
if company_impact <= 1 and impacts_adpe_units == "gSbeq":
|
| 200 |
+
company_impact *= 1000
|
| 201 |
+
impacts_adpe_units = "mgSbeq"
|
| 202 |
+
|
| 203 |
+
##############
|
| 204 |
+
if company_impact <= 1 and impacts_adpe_units == "mgSbeq":
|
| 205 |
+
company_impact *= 1000
|
| 206 |
+
impacts_adpe_units = "μSbeq"
|
| 207 |
+
if company_impact >= 1000 and impacts_adpe_units == "kgSbeq":
|
| 208 |
+
company_impact /= 1000
|
| 209 |
+
impacts_adpe_units = "tSbeq"
|
| 210 |
+
st.latex(f'\Large {company_impact:.3g} \ \large {impacts_adpe_units}')
|
| 211 |
+
st.markdown("""
|
| 212 |
+
<div style="text-align: center;"><i>Evaluates the use of metals and minerals<i>
|
| 213 |
+
</div>
|
| 214 |
+
""", unsafe_allow_html = True)
|
| 215 |
+
|
| 216 |
+
with col_pe:
|
| 217 |
+
st.markdown("""
|
| 218 |
+
<div style="text-align: center;">
|
| 219 |
+
<div style="font-size: 30px;">⛽️</div>
|
| 220 |
+
<div style="font-size: 18px;">Primary Energy</div>
|
| 221 |
+
</div>
|
| 222 |
+
""", unsafe_allow_html = True)
|
| 223 |
+
company_impact = impacts.pe.magnitude * company_multiplier
|
| 224 |
+
impacts_pe_units = impacts.pe.units
|
| 225 |
+
if company_impact >= 1000 and impacts_pe_units == "kJ":
|
| 226 |
+
company_impact /= 1000
|
| 227 |
+
impacts_pe_units = "MJ"
|
| 228 |
+
if company_impact >= 1000 and impacts_pe_units == "MJ":
|
| 229 |
+
company_impact /= 1000
|
| 230 |
+
impacts_pe_units = "GJ"
|
| 231 |
+
if company_impact >= 1000 and impacts_pe_units == "GJ":
|
| 232 |
+
company_impact /= 1000
|
| 233 |
+
impacts_pe_units = "TJ"
|
| 234 |
+
if company_impact >= 1000 and impacts_pe_units == "TJ":
|
| 235 |
+
company_impact /= 1000
|
| 236 |
+
impacts_pe_units = "PJ"
|
| 237 |
+
st.latex(f'\Large {company_impact:.3g} \ \large {impacts_pe_units}')
|
| 238 |
+
st.markdown("""
|
| 239 |
+
<div style="height: 10px;"></div>
|
| 240 |
+
<div style="text-align: center;"><i>Evaluates the use of energy resources<i>
|
| 241 |
+
</div>
|
| 242 |
+
""", unsafe_allow_html = True)
|
| 243 |
+
|
| 244 |
+
with col_water:
|
| 245 |
+
st.markdown("""
|
| 246 |
+
<div style="text-align: center;">
|
| 247 |
+
<div style="font-size: 30px;">🚰</div>
|
| 248 |
+
<div style="font-size: 25px;">Water</div>
|
| 249 |
+
</div>
|
| 250 |
+
""", unsafe_allow_html = True)
|
| 251 |
+
company_impact = impacts.water.magnitude * company_multiplier
|
| 252 |
+
impacts_water_units = impacts.water.units
|
| 253 |
+
if company_impact >= 1000 and impacts_water_units == "mL":
|
| 254 |
+
company_impact /= 1000
|
| 255 |
+
impacts_water_units = "L"
|
| 256 |
+
if company_impact >= 1000 and impacts_water_units == "L":
|
| 257 |
+
company_impact /= 1000
|
| 258 |
+
impacts_water_units = "kL"
|
| 259 |
+
if company_impact >= 1000 and impacts_water_units == "kL":
|
| 260 |
+
company_impact /= 1000
|
| 261 |
+
impacts_water_units = "ML"
|
| 262 |
+
if company_impact >= 1000 and impacts_water_units == "ML":
|
| 263 |
+
company_impact /= 1000
|
| 264 |
+
impacts_water_units = "GL"
|
| 265 |
+
if company_impact >= 1000 and impacts_water_units == "GL":
|
| 266 |
+
company_impact /= 1000
|
| 267 |
+
impacts_water_units = "TL"
|
| 268 |
+
st.latex(f'\Large {company_impact:.3g} \ \large {impacts_water_units}')
|
| 269 |
+
st.markdown("""
|
| 270 |
+
<div style="text-align: center;"><i>Evaluates the use of water<i>
|
| 271 |
+
</div>
|
| 272 |
+
""", unsafe_allow_html = True)
|
| 273 |
+
|
| 274 |
+
|
| 275 |
+
|
| 276 |
############################################################################################################
|
| 277 |
|
| 278 |
def display_equivalent(impacts, provider, location):
|
|
|
|
| 354 |
if electricity_production == EnergyProduction.WIND:
|
| 355 |
emoji = "💨️ "
|
| 356 |
name = "Wind turbines"
|
| 357 |
+
st.markdown(f"""
|
| 358 |
+
<div style="text-align: center;">
|
| 359 |
+
<div style="font-size: 30px;">
|
| 360 |
+
{emoji}
|
| 361 |
+
</div>
|
| 362 |
+
<div style="font-size: 30px;">
|
| 363 |
+
{count.magnitude:.3g}
|
| 364 |
+
</div>
|
| 365 |
+
<div style="font-size: 25px;">
|
| 366 |
+
{name}
|
| 367 |
+
</div>
|
| 368 |
+
<div style="font-size: 12px;">
|
| 369 |
+
(yearly ⚡️ production)
|
| 370 |
+
</div>
|
| 371 |
+
</div>
|
| 372 |
+
""", unsafe_allow_html=True)
|
| 373 |
st.markdown(f'<p align="center"><i>Based on energy consumption<i></p>', unsafe_allow_html = True)
|
| 374 |
|
| 375 |
with col6:
|
| 376 |
ireland_count = format_energy_eq_electricity_consumption_ireland(impacts.energy)
|
| 377 |
+
st.markdown(f"""
|
| 378 |
+
<div style="text-align: center;">
|
| 379 |
+
<div style="font-size: 30px;">
|
| 380 |
+
☘️🇮🇪
|
| 381 |
+
</div>
|
| 382 |
+
<div style="font-size: 30px;">
|
| 383 |
+
{ireland_count.magnitude:.3g}
|
| 384 |
+
</div>
|
| 385 |
+
<div style="font-size: 25px;">
|
| 386 |
+
Irelands
|
| 387 |
+
</div>
|
| 388 |
+
<div style="font-size: 12px;">
|
| 389 |
+
(yearly ⚡️ consumption)
|
| 390 |
+
</div>
|
| 391 |
+
</div>
|
| 392 |
+
""", unsafe_allow_html=True)
|
| 393 |
st.markdown(f'<p align="center"><i>Based on energy consumption<i></p>', unsafe_allow_html = True)
|
| 394 |
|
| 395 |
with col7:
|
| 396 |
paris_nyc_airplane = format_gwp_eq_airplane_paris_nyc(impacts.gwp)
|
| 397 |
+
st.markdown(f"""
|
| 398 |
+
<div style="text-align: center;">
|
| 399 |
+
<div style="font-size: 30px;">
|
| 400 |
+
✈️
|
| 401 |
+
</div>
|
| 402 |
+
<div style="font-size: 30px;">
|
| 403 |
+
{paris_nyc_airplane.magnitude:.3g}
|
| 404 |
+
</div>
|
| 405 |
+
<div style="font-size: 25px;">
|
| 406 |
+
Paris ↔ NYC
|
| 407 |
+
</div>
|
| 408 |
+
</div>
|
| 409 |
+
""", unsafe_allow_html=True)
|
| 410 |
st.markdown(f'<p align="center"><i>Based on GHG emissions<i></p>', unsafe_allow_html = True)
|
| 411 |
|
| 412 |
with col8:
|
| 413 |
olympic_swimming_pool = format_water_eq_olympic_sized_swimming_pool(impacts.water)
|
| 414 |
+
st.markdown(f"""
|
| 415 |
+
<div style="text-align: center;">
|
| 416 |
+
<div style="font-size: 30px;">
|
| 417 |
+
🏊🏼
|
| 418 |
+
</div>
|
| 419 |
+
<div style="font-size: 30px;">
|
| 420 |
+
{olympic_swimming_pool.magnitude:.3g}
|
| 421 |
+
</div>
|
| 422 |
+
<div style="font-size: 22px;">
|
| 423 |
+
Olympic-sized swimming pools
|
| 424 |
+
</div>
|
| 425 |
+
</div>
|
| 426 |
+
""", unsafe_allow_html=True)
|
| 427 |
st.markdown(f'<p align="center"><i>Based on water consumption<i></p>', unsafe_allow_html = True)
|
| 428 |
|
| 429 |
+
#####################################################################################
|
| 430 |
+
|
| 431 |
+
def display_equivalent_company(impacts, provider, company_multiplier, location):
|
| 432 |
+
|
| 433 |
+
st.divider()
|
| 434 |
+
|
| 435 |
+
ev_eq = format_energy_eq_electric_vehicle(impacts.energy)
|
| 436 |
+
|
| 437 |
+
streaming_eq = format_gwp_eq_streaming(impacts.gwp)
|
| 438 |
+
|
| 439 |
+
col1, col2, col3, col4 = st.columns(4)
|
| 440 |
+
|
| 441 |
+
with col1:
|
| 442 |
+
physical_activity, distance = format_energy_eq_physical_activity_company(impacts.energy, company_multiplier)
|
| 443 |
+
if physical_activity == PhysicalActivity.WALKING:
|
| 444 |
+
physical_activity_emoji = "🚶 "
|
| 445 |
+
physical_activity = physical_activity.capitalize()
|
| 446 |
+
if physical_activity == PhysicalActivity.RUNNING:
|
| 447 |
+
physical_activity_emoji = "🏃 "
|
| 448 |
+
physical_activity = physical_activity.capitalize()
|
| 449 |
+
|
| 450 |
+
st.markdown(f"""
|
| 451 |
+
<div style="text-align: center;">
|
| 452 |
+
<div style="font-size: 30px;">{physical_activity_emoji}</div>
|
| 453 |
+
<div style="font-size: 25px;">{physical_activity}</div>
|
| 454 |
+
</div>
|
| 455 |
+
""", unsafe_allow_html = True)
|
| 456 |
+
value = round(distance.magnitude, 3)
|
| 457 |
+
st.latex(rf'\Large {value:.0g} \ \large {distance.units}')
|
| 458 |
+
st.markdown(f'<p align="center"><i>Based on energy consumption<i></p>', unsafe_allow_html = True)
|
| 459 |
+
|
| 460 |
+
with col2:
|
| 461 |
+
ev_eq = format_energy_eq_electric_vehicle_company(impacts.energy, company_multiplier)
|
| 462 |
+
st.markdown(f"""
|
| 463 |
+
<div style="text-align: center;">
|
| 464 |
+
<div style="font-size: 30px;">🔋</div>
|
| 465 |
+
<div style="font-size: 22px;">Electric Vehicle</div>
|
| 466 |
+
</div>
|
| 467 |
+
""", unsafe_allow_html = True)
|
| 468 |
+
value = round(ev_eq.magnitude, 3)
|
| 469 |
+
st.latex(rf'\Large {value:.0f} \ \large {ev_eq.units}')
|
| 470 |
+
st.markdown(f'<p align="center"><i>Based on energy consumption<i></p>', unsafe_allow_html = True)
|
| 471 |
+
|
| 472 |
+
with col3:
|
| 473 |
+
streaming_eq = format_gwp_eq_streaming_company(impacts.gwp, company_multiplier)
|
| 474 |
+
st.markdown(f"""
|
| 475 |
+
<div style="text-align: center;">
|
| 476 |
+
<div style="font-size: 30px;">⏯️</div>
|
| 477 |
+
<div style="font-size: 25px;">Streaming</div>
|
| 478 |
+
</div>
|
| 479 |
+
""", unsafe_allow_html = True)
|
| 480 |
+
value = round(streaming_eq.magnitude, 3)
|
| 481 |
+
st.latex(rf'\Large {value:.0f} \ \large {streaming_eq.units}')
|
| 482 |
+
st.markdown(f'<p align="center"><i>Based on GHG emissions<i></p>', unsafe_allow_html = True)
|
| 483 |
+
|
| 484 |
+
with col4:
|
| 485 |
+
#water = water_impact(impacts, provider, location)
|
| 486 |
+
water_eq = format_water_eq_bottled_waters_company(impacts.water, company_multiplier)
|
| 487 |
+
st.markdown(f"""
|
| 488 |
+
<div style="text-align: center;">
|
| 489 |
+
<div style="font-size: 30px;">🚰</div>
|
| 490 |
+
<div style="font-size: 25px;">Bottled Waters</div>
|
| 491 |
+
</div>
|
| 492 |
+
""", unsafe_allow_html = True)
|
| 493 |
+
value = round(water_eq.magnitude, 3)
|
| 494 |
+
st.latex(rf'\Large {value:.0f} \ \large {"bottles"}')
|
| 495 |
+
st.markdown(f'<p align="center"><i>Based on water consumption, measured in 0.75 L bottles.<i></p>', unsafe_allow_html = True)
|
| 496 |
+
|
| 497 |
+
st.divider()
|
| 498 |
+
|
| 499 |
+
st.markdown('<h3 align="center">What if the company does this request everyday for 251 days (number of work days per year in France in 2025) ?</h3>', unsafe_allow_html = True)
|
| 500 |
+
|
| 501 |
+
col5, col6, col7, col8 = st.columns(4)
|
| 502 |
+
|
| 503 |
+
with col5:
|
| 504 |
+
|
| 505 |
+
electricity_production, count = format_energy_eq_electricity_production_company(impacts.energy, company_multiplier)
|
| 506 |
+
if electricity_production == EnergyProduction.NUCLEAR:
|
| 507 |
+
emoji = "☢️"
|
| 508 |
+
name = "Nuclear power plants"
|
| 509 |
+
if electricity_production == EnergyProduction.WIND:
|
| 510 |
+
emoji = "💨️ "
|
| 511 |
+
name = "Wind turbines"
|
| 512 |
+
st.markdown(f"""
|
| 513 |
+
<div style="text-align: center;">
|
| 514 |
+
<div style="font-size: 30px;">
|
| 515 |
+
{emoji}
|
| 516 |
+
</div>
|
| 517 |
+
<div style="font-size: 30px;">
|
| 518 |
+
{count.magnitude:.3g}
|
| 519 |
+
</div>
|
| 520 |
+
<div style="font-size: 25px;">
|
| 521 |
+
{name}
|
| 522 |
+
</div>
|
| 523 |
+
<div style="font-size: 12px;">
|
| 524 |
+
(yearly ⚡️ production)
|
| 525 |
+
</div>
|
| 526 |
+
</div>
|
| 527 |
+
""", unsafe_allow_html=True)
|
| 528 |
+
st.markdown(f'<p align="center"><i>Based on energy consumption<i></p>', unsafe_allow_html = True)
|
| 529 |
+
|
| 530 |
+
with col6:
|
| 531 |
+
ireland_count = format_energy_eq_electricity_consumption_ireland_company(impacts.energy, company_multiplier)
|
| 532 |
+
st.markdown(f"""
|
| 533 |
+
<div style="text-align: center;">
|
| 534 |
+
<div style="font-size: 30px;">
|
| 535 |
+
☘️🇮🇪
|
| 536 |
+
</div>
|
| 537 |
+
<div style="font-size: 30px;">
|
| 538 |
+
{ireland_count.magnitude:.3g}
|
| 539 |
+
</div>
|
| 540 |
+
<div style="font-size: 25px;">
|
| 541 |
+
Irelands
|
| 542 |
+
</div>
|
| 543 |
+
<div style="font-size: 12px;">
|
| 544 |
+
(yearly ⚡️ consumption)
|
| 545 |
+
</div>
|
| 546 |
+
</div>
|
| 547 |
+
""", unsafe_allow_html=True)
|
| 548 |
+
st.markdown(f'<p align="center"><i>Based on energy consumption<i></p>', unsafe_allow_html = True)
|
| 549 |
+
|
| 550 |
+
with col7:
|
| 551 |
+
paris_nyc_airplane = format_gwp_eq_airplane_paris_nyc_company(impacts.gwp, company_multiplier)
|
| 552 |
+
st.markdown(f"""
|
| 553 |
+
<div style="text-align: center;">
|
| 554 |
+
<div style="font-size: 30px;">
|
| 555 |
+
✈️
|
| 556 |
+
</div>
|
| 557 |
+
<div style="font-size: 30px;">
|
| 558 |
+
{paris_nyc_airplane.magnitude:.3g}
|
| 559 |
+
</div>
|
| 560 |
+
<div style="font-size: 25px;">
|
| 561 |
+
Paris ↔ NYC
|
| 562 |
+
</div>
|
| 563 |
+
</div>
|
| 564 |
+
""", unsafe_allow_html=True)
|
| 565 |
+
st.markdown(f'<p align="center"><i>Based on GHG emissions<i></p>', unsafe_allow_html = True)
|
| 566 |
+
|
| 567 |
+
with col8:
|
| 568 |
+
olympic_swimming_pool = format_water_eq_olympic_sized_swimming_pool_company(impacts.water, company_multiplier)
|
| 569 |
+
st.markdown(f"""
|
| 570 |
+
<div style="text-align: center;">
|
| 571 |
+
<div style="font-size: 30px;">
|
| 572 |
+
🏊🏼
|
| 573 |
+
</div>
|
| 574 |
+
<div style="font-size: 30px;">
|
| 575 |
+
{olympic_swimming_pool.magnitude:.3g}
|
| 576 |
+
</div>
|
| 577 |
+
<div style="font-size: 22px;">
|
| 578 |
+
Olympic-sized swimming pools
|
| 579 |
+
</div>
|
| 580 |
+
</div>
|
| 581 |
+
""", unsafe_allow_html=True)
|
| 582 |
+
st.markdown(f'<p align="center"><i>Based on water consumption<i></p>', unsafe_allow_html = True)
|
src/utils.py
CHANGED
|
@@ -78,7 +78,9 @@ BOTTLED_WATERS_EQ = q("0.75 L")
|
|
| 78 |
# From https://ourworldindata.org/population-growth
|
| 79 |
ONE_PERCENT_WORLD_POPULATION = 80_000_000
|
| 80 |
|
| 81 |
-
DAYS_IN_YEAR = 365
|
|
|
|
|
|
|
| 82 |
|
| 83 |
# For a 900 MW nuclear plant -> 500 000 MWh / month
|
| 84 |
# From https://www.edf.fr/groupe-edf/espaces-dedies/jeunes-enseignants/pour-les-jeunes/lenergie-de-a-a-z/produire-de-lelectricite/le-nucleaire-en-chiffres
|
|
@@ -235,6 +237,10 @@ def format_impacts_expert(impacts: Impacts, display_range: bool) -> QImpacts:
|
|
| 235 |
pe=format_pe(pe),
|
| 236 |
water=format_water(impacts.water)
|
| 237 |
), impacts.usage, impacts.embodied
|
|
|
|
|
|
|
|
|
|
|
|
|
| 238 |
|
| 239 |
#####################################################################################
|
| 240 |
### EQUIVALENT FORMATING
|
|
@@ -286,6 +292,7 @@ def format_energy_eq_electricity_consumption_ireland(energy: Quantity) -> Quanti
|
|
| 286 |
electricity_eq = electricity_eq.to("TWh")
|
| 287 |
return electricity_eq / YEARLY_IRELAND_ELECTRICITY_CONSUMPTION
|
| 288 |
|
|
|
|
| 289 |
def format_gwp_eq_airplane_paris_nyc(gwp: Quantity) -> Quantity:
|
| 290 |
gwp_eq = gwp * ONE_PERCENT_WORLD_POPULATION * DAYS_IN_YEAR
|
| 291 |
gwp_eq = gwp_eq.to("kgCO2eq")
|
|
@@ -296,8 +303,64 @@ def format_water_eq_olympic_sized_swimming_pool(water: Quantity) -> Quantity:
|
|
| 296 |
water_eq = water_eq.to("L")
|
| 297 |
return water_eq / OLYMPIC_SWIMMING_POOL
|
| 298 |
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 302 |
|
| 303 |
####################################################################################### MODELS PARAMETER####################################################################################
|
|
|
|
| 78 |
# From https://ourworldindata.org/population-growth
|
| 79 |
ONE_PERCENT_WORLD_POPULATION = 80_000_000
|
| 80 |
|
| 81 |
+
DAYS_IN_YEAR = 365.15
|
| 82 |
+
|
| 83 |
+
WORKDAYS_IN_YEAR_FRANCE = 251
|
| 84 |
|
| 85 |
# For a 900 MW nuclear plant -> 500 000 MWh / month
|
| 86 |
# From https://www.edf.fr/groupe-edf/espaces-dedies/jeunes-enseignants/pour-les-jeunes/lenergie-de-a-a-z/produire-de-lelectricite/le-nucleaire-en-chiffres
|
|
|
|
| 237 |
pe=format_pe(pe),
|
| 238 |
water=format_water(impacts.water)
|
| 239 |
), impacts.usage, impacts.embodied
|
| 240 |
+
|
| 241 |
+
|
| 242 |
+
|
| 243 |
+
######################################################################3
|
| 244 |
|
| 245 |
#####################################################################################
|
| 246 |
### EQUIVALENT FORMATING
|
|
|
|
| 292 |
electricity_eq = electricity_eq.to("TWh")
|
| 293 |
return electricity_eq / YEARLY_IRELAND_ELECTRICITY_CONSUMPTION
|
| 294 |
|
| 295 |
+
|
| 296 |
def format_gwp_eq_airplane_paris_nyc(gwp: Quantity) -> Quantity:
|
| 297 |
gwp_eq = gwp * ONE_PERCENT_WORLD_POPULATION * DAYS_IN_YEAR
|
| 298 |
gwp_eq = gwp_eq.to("kgCO2eq")
|
|
|
|
| 303 |
water_eq = water_eq.to("L")
|
| 304 |
return water_eq / OLYMPIC_SWIMMING_POOL
|
| 305 |
|
| 306 |
+
########################################################################
|
| 307 |
+
|
| 308 |
+
def format_energy_eq_physical_activity_company(energy: Quantity, company_multiplier) -> tuple[PhysicalActivity, Quantity]:
|
| 309 |
+
energy = energy.to("kJ")
|
| 310 |
+
running_eq = energy / RUNNING_ENERGY_EQ * company_multiplier
|
| 311 |
+
if running_eq > q("1 km"):
|
| 312 |
+
return PhysicalActivity.RUNNING, running_eq
|
| 313 |
+
|
| 314 |
+
walking_eq = energy / WALKING_ENERGY_EQ
|
| 315 |
+
if walking_eq < q("1 km"):
|
| 316 |
+
walking_eq = walking_eq.to("meter")
|
| 317 |
+
return PhysicalActivity.WALKING, walking_eq
|
| 318 |
+
|
| 319 |
+
def format_energy_eq_electric_vehicle_company(energy: Quantity, company_multiplier) -> Quantity:
|
| 320 |
+
energy = energy.to("kWh")
|
| 321 |
+
ev_eq = energy / EV_ENERGY_EQ * company_multiplier
|
| 322 |
+
if ev_eq < q("1 km"):
|
| 323 |
+
ev_eq = ev_eq.to("meter")
|
| 324 |
+
return ev_eq
|
| 325 |
+
|
| 326 |
+
def format_gwp_eq_streaming_company(gwp: Quantity, company_multiplier) -> Quantity:
|
| 327 |
+
gwp = gwp.to("kgCO2eq")
|
| 328 |
+
streaming_eq = gwp * STREAMING_GWP_EQ * company_multiplier
|
| 329 |
+
if streaming_eq < q("1 h"):
|
| 330 |
+
streaming_eq = streaming_eq.to("min")
|
| 331 |
+
if streaming_eq < q("1 min"):
|
| 332 |
+
streaming_eq = streaming_eq.to("s")
|
| 333 |
+
return streaming_eq
|
| 334 |
+
|
| 335 |
+
def format_water_eq_bottled_waters_company(water: Quantity, company_multiplier) -> Quantity:
|
| 336 |
+
water = water.to("L")
|
| 337 |
+
bottled_water_eq = water / BOTTLED_WATERS_EQ * company_multiplier
|
| 338 |
+
return bottled_water_eq
|
| 339 |
+
|
| 340 |
+
def format_energy_eq_electricity_production_company(energy: Quantity, company_multiplier) -> tuple[EnergyProduction, Quantity]:
|
| 341 |
+
electricity_eq = energy * company_multiplier * WORKDAYS_IN_YEAR_FRANCE
|
| 342 |
+
electricity_eq = electricity_eq.to("TWh")
|
| 343 |
+
if electricity_eq > YEARLY_NUCLEAR_ENERGY_EQ:
|
| 344 |
+
return EnergyProduction.NUCLEAR, electricity_eq / YEARLY_NUCLEAR_ENERGY_EQ
|
| 345 |
+
electricity_eq = electricity_eq.to("GWh")
|
| 346 |
+
return EnergyProduction.WIND, electricity_eq / YEARLY_WIND_ENERGY_EQ
|
| 347 |
+
|
| 348 |
+
|
| 349 |
+
def format_energy_eq_electricity_consumption_ireland_company(energy: Quantity, company_multiplier) -> Quantity:
|
| 350 |
+
electricity_eq = energy * company_multiplier * WORKDAYS_IN_YEAR_FRANCE
|
| 351 |
+
electricity_eq = electricity_eq.to("TWh")
|
| 352 |
+
return electricity_eq / YEARLY_IRELAND_ELECTRICITY_CONSUMPTION
|
| 353 |
+
|
| 354 |
+
|
| 355 |
+
def format_gwp_eq_airplane_paris_nyc_company(gwp: Quantity, company_multiplier) -> Quantity:
|
| 356 |
+
gwp_eq = gwp * company_multiplier * WORKDAYS_IN_YEAR_FRANCE
|
| 357 |
+
gwp_eq = gwp_eq.to("kgCO2eq")
|
| 358 |
+
return gwp_eq / AIRPLANE_PARIS_NYC_GWP_EQ
|
| 359 |
+
|
| 360 |
+
def format_water_eq_olympic_sized_swimming_pool_company(water: Quantity, company_multiplier) -> Quantity:
|
| 361 |
+
water_eq = water * company_multiplier * WORKDAYS_IN_YEAR_FRANCE
|
| 362 |
+
water_eq = water_eq.to("L")
|
| 363 |
+
return water_eq / OLYMPIC_SWIMMING_POOL
|
| 364 |
+
|
| 365 |
|
| 366 |
####################################################################################### MODELS PARAMETER####################################################################################
|