Commit
Β·
03065c3
1
Parent(s):
a48c2e3
updated
Browse files- README.md +4 -9
- app-versions/v1.py +119 -0
- app-versions/v2.py +0 -0
- app-versions/v3.py +228 -0
- app-versions/v4.py +268 -0
- app-versions/v5.py +278 -0
- calculator-app/app.py +281 -0
- calculator-app/data.csv +18 -0
- calculator-app/instructions.md +61 -0
- docs/additional-notes.md +13 -0
- docs/app-notes.md +9 -0
- {reference-material β docs}/data-dictionary.md +0 -0
- {reference-material β docs}/glossary.md +0 -0
- {reference-material β docs}/units-glossary.md +0 -0
- requirements.txt +0 -0
README.md
CHANGED
@@ -10,20 +10,15 @@ This is a second version of an earlier calculator I put together. The reason tha
|
|
10 |
|
11 |
I was drawn to this work as a result of my employment. Nevertheless, at least in its first iterations, my work with data in the realm of environmental and sustainability topics should not be perceived as anything other than my own first entry notes and attempts at exploring various questions. High among them is the question of whether and how companies' far-reaching environmental impacts could be monetized and integrated into financial accounting - an idea, at least in some implementations, called impact accounting. I open source technical projects as a matter of course and I haven't thought it is important to distinguish between my initial work in this and other areas.
|
12 |
|
13 |
-
##
|
14 |
|
|
|
15 |
|
16 |
-
|
17 |
|
18 |
-
|
19 |
|
20 |
-
Although obvious, it's important to highlight the following, too:
|
21 |
|
22 |
-
Greenhouse gas emissions are often used for this purpose for a plurality of reasons, but chief among them is probably the fact that they are relatively widely available as a datapoint. To calculate what monetized environmental emissions would look like in practice, two things are necessary: Firstly the quantitative data about those emissions and secondly the multiplication factors to convert those to monetary units. To call the latter merely multipliers is also to greatly oversimplify what these are. In reality, to the extent that a simple number is ultimately proposed, the number is the result of a extensive modeling process underpinned by detailed scientific information.
|
23 |
-
|
24 |
-
The broad idea behind proposing a social cost of carbon at all is to fix a number on the extent to which companies emissions have effects that could be monetized. However, there are two large deficiencies in even this approach. The first is that while it might be the most prominent gas in companies emissions profiles, carbon dioxide is but one of several gasses they may be emitting in their overall GHG emissions basket that have been demonstrated scientifically to have damaging effects on the environment (express, numerically, through their GWP values). One approach arround this is to consider for calculation a social cost of greenhouse gasses or SC-GHG.
|
25 |
-
|
26 |
-
The second is the point made previously, that while companies greenhouse gas emissions, even if considered collectively, are relatively easy to document, monitor and report upon, together, they only consider one part of a company's environmental impacts. The Global Value Factors Database released by the International Foundation for Valuing Impacts l(IFVI) in 2024 considers a wide variety of environmental impacts, including in areas such as air pollution, waste management and land use displacement.
|
27 |
|
28 |
## Proposals Included In Dataset
|
29 |
|
|
|
10 |
|
11 |
I was drawn to this work as a result of my employment. Nevertheless, at least in its first iterations, my work with data in the realm of environmental and sustainability topics should not be perceived as anything other than my own first entry notes and attempts at exploring various questions. High among them is the question of whether and how companies' far-reaching environmental impacts could be monetized and integrated into financial accounting - an idea, at least in some implementations, called impact accounting. I open source technical projects as a matter of course and I haven't thought it is important to distinguish between my initial work in this and other areas.
|
12 |
|
13 |
+
## Limitations of Calculations (Summary)
|
14 |
|
15 |
+
Simulating the monetization of greenhouse gas emissions is limited by the difficulties of working with two different yardsticks: the social cost of carbon, which only considers carbon dioxide emissions, and the quantitative reporting data from companies for greenhouse gas emissions (GHG), which almost always includes gases beyond carbon dioxide.
|
16 |
|
17 |
+
It' has been suggested that organisations should propose a social cost of greenhouse gas emissions encompassing both carbon dioxide and other greenhouse gases with higher global warming potential (GWP) values But doing so would be challenging given the relative paucity of such estimates.
|
18 |
|
19 |
+
The practical effect of monetizing greenhouse gas emissions at proposed rates, which only consider carbon dioxide in some cases, **is that the monetizations will actually be understatements of the true estimated monetary cost of the emissions**. Therefore, the calculations will actually be conservative and understatements of the true cost of these emissions. .
|
20 |
|
|
|
21 |
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
## Proposals Included In Dataset
|
24 |
|
app-versions/v1.py
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
|
4 |
+
# Path to the data file relative to the app.py file
|
5 |
+
DATA_PATH = "data.csv"
|
6 |
+
INSTRUCTIONS_PATH = "instructions.md"
|
7 |
+
|
8 |
+
|
9 |
+
def load_data():
|
10 |
+
try:
|
11 |
+
df = pd.read_csv(DATA_PATH)
|
12 |
+
return df
|
13 |
+
except FileNotFoundError:
|
14 |
+
st.error(
|
15 |
+
f"Error: Could not find the data file at {DATA_PATH}. Please ensure the file exists."
|
16 |
+
)
|
17 |
+
return None
|
18 |
+
|
19 |
+
|
20 |
+
def load_instructions():
|
21 |
+
try:
|
22 |
+
with open(INSTRUCTIONS_PATH, "r") as f:
|
23 |
+
return f.read()
|
24 |
+
except FileNotFoundError:
|
25 |
+
return "Error: Instructions file not found."
|
26 |
+
|
27 |
+
|
28 |
+
def format_currency(value, display_unit):
|
29 |
+
if display_unit == "Millions":
|
30 |
+
formatted_value = f"${value / 1_000_000:.2f} MN"
|
31 |
+
elif display_unit == "Billions":
|
32 |
+
formatted_value = f"${value / 1_000_000_000:.2f} BN"
|
33 |
+
return formatted_value
|
34 |
+
|
35 |
+
|
36 |
+
def main():
|
37 |
+
st.title("GHG Emissions Monetization Calculator")
|
38 |
+
st.markdown(
|
39 |
+
"The purpose of this tool and demonstration is to allow users to explore How monetizing companies proposed greenhouse gas emissions might work in practice."
|
40 |
+
)
|
41 |
+
st.markdown(
|
42 |
+
"This calculator accompanies a repository shared on Github and Hugging Face which aggregates proposals for the social cost of carbon, which have been advanced at various points in time by various world bodies."
|
43 |
+
)
|
44 |
+
st.markdown(
|
45 |
+
"Detailed notes and instructions about the use of this calculator can be found in the Instructions tab."
|
46 |
+
)
|
47 |
+
st.markdown(
|
48 |
+
"This calculator was developed by Daniel Rosehill in December 2024 (danielrosehill.com)."
|
49 |
+
)
|
50 |
+
|
51 |
+
# Load the data and instructions
|
52 |
+
df = load_data()
|
53 |
+
instructions = load_instructions()
|
54 |
+
if df is None:
|
55 |
+
return # Don't proceed if data can't be loaded
|
56 |
+
|
57 |
+
# Tabs for calculator and instructions
|
58 |
+
tabs = st.tabs(["Calculator", "Instructions"])
|
59 |
+
|
60 |
+
with tabs[0]: # Calculator tab
|
61 |
+
with st.container():
|
62 |
+
left, right = st.columns(2)
|
63 |
+
|
64 |
+
with left:
|
65 |
+
st.subheader("Input Values")
|
66 |
+
scope1_emissions = st.number_input("Scope 1 Emissions", value=0.0)
|
67 |
+
scope2_emissions = st.number_input("Scope 2 Emissions", value=0.0)
|
68 |
+
scope3_emissions = st.number_input("Scope 3 Emissions", value=0.0)
|
69 |
+
unit_of_reporting = st.selectbox("Unit of Reporting", ["TCO2E", "MTCO2E"])
|
70 |
+
|
71 |
+
proposal_names = df['proposal_with_date'].tolist()
|
72 |
+
selected_proposal = st.selectbox("Social cost of carbon", proposal_names)
|
73 |
+
|
74 |
+
with right:
|
75 |
+
st.subheader("Calculated Values")
|
76 |
+
# Calculated emissions
|
77 |
+
scope1_2_emissions = scope1_emissions + scope2_emissions
|
78 |
+
all_scopes_emissions = (
|
79 |
+
scope1_emissions + scope2_emissions + scope3_emissions
|
80 |
+
)
|
81 |
+
st.markdown(
|
82 |
+
f"Scope 1 and 2 Emissions: {scope1_2_emissions:.2f} {unit_of_reporting}"
|
83 |
+
)
|
84 |
+
st.markdown(
|
85 |
+
f"All Scopes Emissions: {all_scopes_emissions:.2f} {unit_of_reporting}"
|
86 |
+
)
|
87 |
+
|
88 |
+
# Find the value in USD per ton
|
89 |
+
selected_row = df[df['proposal_with_date'] == selected_proposal].iloc[0]
|
90 |
+
multiplier = selected_row['usd_proposed_value']
|
91 |
+
|
92 |
+
st.subheader("Monetized Emissions")
|
93 |
+
display_unit = st.radio("Display units", ["Millions", "Billions"])
|
94 |
+
|
95 |
+
if unit_of_reporting == "MTCO2E":
|
96 |
+
scope1_emissions = scope1_emissions * 1_000_000
|
97 |
+
scope2_emissions = scope2_emissions * 1_000_000
|
98 |
+
scope3_emissions = scope3_emissions * 1_000_000
|
99 |
+
all_scopes_emissions = all_scopes_emissions * 1_000_000
|
100 |
+
|
101 |
+
# Monetization calculations
|
102 |
+
monetized_scope1 = scope1_emissions * multiplier
|
103 |
+
monetized_scope2 = scope2_emissions * multiplier
|
104 |
+
monetized_scope3 = scope3_emissions * multiplier
|
105 |
+
monetized_all_scopes = all_scopes_emissions * multiplier
|
106 |
+
|
107 |
+
st.markdown(f"Scope 1: {format_currency(monetized_scope1, display_unit)}")
|
108 |
+
st.markdown(f"Scope 2: {format_currency(monetized_scope2, display_unit)}")
|
109 |
+
st.markdown(f"Scope 3: {format_currency(monetized_scope3, display_unit)}")
|
110 |
+
st.markdown(
|
111 |
+
f"All Scopes: {format_currency(monetized_all_scopes, display_unit)}"
|
112 |
+
)
|
113 |
+
|
114 |
+
with tabs[1]: # Instructions tab
|
115 |
+
st.markdown(instructions)
|
116 |
+
|
117 |
+
|
118 |
+
if __name__ == "__main__":
|
119 |
+
main()
|
app-versions/v2.py
ADDED
File without changes
|
app-versions/v3.py
ADDED
@@ -0,0 +1,228 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import plotly.express as px
|
4 |
+
|
5 |
+
# Path to the data file relative to the app.py file
|
6 |
+
DATA_PATH = "data.csv"
|
7 |
+
INSTRUCTIONS_PATH = "instructions.md"
|
8 |
+
|
9 |
+
GITHUB_LINK = "https://github.com/danielrosehill/Emissions-Monetisation-Calculator"
|
10 |
+
|
11 |
+
|
12 |
+
def load_data():
|
13 |
+
try:
|
14 |
+
df = pd.read_csv(DATA_PATH)
|
15 |
+
return df
|
16 |
+
except FileNotFoundError:
|
17 |
+
st.error(
|
18 |
+
f"Error: Could not find the data file at {DATA_PATH}. Please ensure the file exists."
|
19 |
+
)
|
20 |
+
return None
|
21 |
+
|
22 |
+
|
23 |
+
def load_instructions():
|
24 |
+
try:
|
25 |
+
with open(INSTRUCTIONS_PATH, "r") as f:
|
26 |
+
return f.read()
|
27 |
+
except FileNotFoundError:
|
28 |
+
return "Error: Instructions file not found."
|
29 |
+
|
30 |
+
|
31 |
+
def format_currency(value, display_unit):
|
32 |
+
if display_unit == "Millions":
|
33 |
+
formatted_value = f"${value / 1_000_000:.2f} MN"
|
34 |
+
elif display_unit == "Billions":
|
35 |
+
formatted_value = f"${value / 1_000_000_000:.2f} BN"
|
36 |
+
return formatted_value
|
37 |
+
|
38 |
+
|
39 |
+
def main():
|
40 |
+
st.title("GHG Emissions Monetization Calculator")
|
41 |
+
st.markdown(
|
42 |
+
"The purpose of this tool and demonstration is to allow users to explore How monetizing companies proposed greenhouse gas emissions might work in practice."
|
43 |
+
)
|
44 |
+
st.markdown(
|
45 |
+
"This calculator accompanies a repository shared on Github and Hugging Face which aggregates proposals for the social cost of carbon, which have been advanced at various points in time by various world bodies."
|
46 |
+
)
|
47 |
+
st.markdown(
|
48 |
+
"Detailed notes and instructions about the use of this calculator can be found in the Instructions tab."
|
49 |
+
)
|
50 |
+
st.markdown(
|
51 |
+
"This calculator was developed by Daniel Rosehill in December 2024 (danielrosehill.com)."
|
52 |
+
)
|
53 |
+
|
54 |
+
# Load the data and instructions
|
55 |
+
df = load_data()
|
56 |
+
instructions = load_instructions()
|
57 |
+
if df is None:
|
58 |
+
return # Don't proceed if data can't be loaded
|
59 |
+
|
60 |
+
# Tabs for calculator, instructions and SCC proposals
|
61 |
+
tabs = st.tabs(["Calculator", "Instructions", "SCC Chart", "SCC Details"])
|
62 |
+
|
63 |
+
with tabs[0]: # Calculator tab
|
64 |
+
with st.container():
|
65 |
+
left, right = st.columns(2)
|
66 |
+
|
67 |
+
with left:
|
68 |
+
st.subheader("Input Values")
|
69 |
+
scope1_emissions = st.number_input("Scope 1 Emissions", value=0.0)
|
70 |
+
scope2_emissions = st.number_input("Scope 2 Emissions", value=0.0)
|
71 |
+
scope3_emissions = st.number_input("Scope 3 Emissions", value=0.0)
|
72 |
+
unit_of_reporting = st.selectbox("Unit of Reporting", ["TCO2E", "MTCO2E"])
|
73 |
+
|
74 |
+
proposal_names = df['proposal_with_date'].tolist()
|
75 |
+
selected_proposal = st.selectbox("Social cost of carbon", proposal_names)
|
76 |
+
|
77 |
+
with right:
|
78 |
+
st.subheader("Calculated Values")
|
79 |
+
# Calculated emissions
|
80 |
+
scope1_2_emissions = scope1_emissions + scope2_emissions
|
81 |
+
all_scopes_emissions = (
|
82 |
+
scope1_emissions + scope2_emissions + scope3_emissions
|
83 |
+
)
|
84 |
+
st.markdown(
|
85 |
+
f"Scope 1 and 2 Emissions: {scope1_2_emissions:.2f} {unit_of_reporting}"
|
86 |
+
)
|
87 |
+
st.markdown(
|
88 |
+
f"All Scopes Emissions: {all_scopes_emissions:.2f} {unit_of_reporting}"
|
89 |
+
)
|
90 |
+
|
91 |
+
# Find the value in USD per ton
|
92 |
+
selected_row = df[df['proposal_with_date'] == selected_proposal].iloc[0]
|
93 |
+
multiplier = selected_row['usd_proposed_value']
|
94 |
+
|
95 |
+
st.subheader("Monetized Emissions")
|
96 |
+
display_unit = st.radio("Display units", ["Millions", "Billions"])
|
97 |
+
|
98 |
+
if unit_of_reporting == "MTCO2E":
|
99 |
+
scope1_emissions = scope1_emissions * 1_000_000
|
100 |
+
scope2_emissions = scope2_emissions * 1_000_000
|
101 |
+
scope3_emissions = scope3_emissions * 1_000_000
|
102 |
+
all_scopes_emissions = all_scopes_emissions * 1_000_000
|
103 |
+
|
104 |
+
# Monetization calculations
|
105 |
+
monetized_scope1 = scope1_emissions * multiplier
|
106 |
+
monetized_scope2 = scope2_emissions * multiplier
|
107 |
+
monetized_scope3 = scope3_emissions * multiplier
|
108 |
+
monetized_all_scopes = all_scopes_emissions * multiplier
|
109 |
+
|
110 |
+
st.markdown(f"Scope 1: {format_currency(monetized_scope1, display_unit)}")
|
111 |
+
st.markdown(f"Scope 2: {format_currency(monetized_scope2, display_unit)}")
|
112 |
+
st.markdown(f"Scope 3: {format_currency(monetized_scope3, display_unit)}")
|
113 |
+
st.markdown(
|
114 |
+
f"All Scopes: {format_currency(monetized_all_scopes, display_unit)}"
|
115 |
+
)
|
116 |
+
|
117 |
+
with tabs[1]: # Instructions tab
|
118 |
+
st.markdown(instructions)
|
119 |
+
|
120 |
+
with tabs[2]: # SCC Chart tab
|
121 |
+
st.subheader("Social Cost of Carbon Proposals")
|
122 |
+
|
123 |
+
# Convert the 'date' column to datetime objects for proper sorting
|
124 |
+
df['date'] = pd.to_datetime(df['date'])
|
125 |
+
|
126 |
+
# Sort by date
|
127 |
+
df = df.sort_values(by='date')
|
128 |
+
|
129 |
+
# Create horizontal bar chart
|
130 |
+
bar_fig = px.bar(
|
131 |
+
df,
|
132 |
+
x="usd_proposed_value",
|
133 |
+
y="proposal_with_date",
|
134 |
+
title="Social Cost of Carbon Proposals",
|
135 |
+
labels={
|
136 |
+
"usd_proposed_value": "USD Proposed Value",
|
137 |
+
"proposal_with_date": "Proposal",
|
138 |
+
},
|
139 |
+
orientation='h' # Set orientation to horizontal
|
140 |
+
)
|
141 |
+
|
142 |
+
st.plotly_chart(bar_fig)
|
143 |
+
|
144 |
+
# Create line chart with data points and custom hover text
|
145 |
+
line_fig = px.line(
|
146 |
+
df,
|
147 |
+
x="date",
|
148 |
+
y="usd_proposed_value",
|
149 |
+
title="Trend of Social Cost of Carbon Proposals Over Time",
|
150 |
+
labels={
|
151 |
+
"usd_proposed_value": "USD Proposed Value",
|
152 |
+
"date": "Date",
|
153 |
+
},
|
154 |
+
hover_data={
|
155 |
+
"usd_proposed_value": False,
|
156 |
+
"proposal_with_date": True,
|
157 |
+
},
|
158 |
+
|
159 |
+
)
|
160 |
+
|
161 |
+
line_fig.update_traces(
|
162 |
+
mode="lines+markers",
|
163 |
+
hovertemplate="<b>%{hovertext}</b>", # Customize hover text
|
164 |
+
text=df["proposal_with_date"], # Add the text data
|
165 |
+
|
166 |
+
)
|
167 |
+
|
168 |
+
st.plotly_chart(line_fig)
|
169 |
+
|
170 |
+
with tabs[3]: # SCC Details tab
|
171 |
+
st.subheader("Social Cost of Carbon Proposal Details")
|
172 |
+
proposal_names = df["proposal_with_date"].tolist()
|
173 |
+
selected_proposal = st.selectbox("Select a proposal", proposal_names)
|
174 |
+
|
175 |
+
if selected_proposal:
|
176 |
+
selected_row = df[df["proposal_with_date"] == selected_proposal].iloc[0]
|
177 |
+
|
178 |
+
# Prepare data for the table
|
179 |
+
table_data = {
|
180 |
+
"Field": [
|
181 |
+
"Organization Name",
|
182 |
+
"Organization Description",
|
183 |
+
"Date",
|
184 |
+
"Country",
|
185 |
+
"ISO3",
|
186 |
+
"ISO2",
|
187 |
+
"HDI Value",
|
188 |
+
"HDI Category",
|
189 |
+
"Details",
|
190 |
+
"Original Proposed Value",
|
191 |
+
"Average Value",
|
192 |
+
"USD Proposed Value",
|
193 |
+
"USD Proposed Value (Empty CO2e)",
|
194 |
+
"USD Conversion Date",
|
195 |
+
"Value Units",
|
196 |
+
"Environmental Units",
|
197 |
+
"Methodologies Used",
|
198 |
+
"Calculation Scope",
|
199 |
+
"Is Range",
|
200 |
+
],
|
201 |
+
"Value": [
|
202 |
+
selected_row["organization_name"],
|
203 |
+
selected_row["organization_description"],
|
204 |
+
selected_row["date"].strftime('%Y-%m-%d'),
|
205 |
+
selected_row["country"],
|
206 |
+
selected_row["iso3"],
|
207 |
+
selected_row["iso2"],
|
208 |
+
selected_row["hdi_value"],
|
209 |
+
selected_row["hdi_category"],
|
210 |
+
selected_row["details"],
|
211 |
+
f"{selected_row['original_proposed_value']} {selected_row['original_currency_name']}",
|
212 |
+
selected_row["average_value"],
|
213 |
+
selected_row["usd_proposed_value"],
|
214 |
+
selected_row['use_proposed_value_mtco2e'],
|
215 |
+
selected_row["usd_conversion_date"],
|
216 |
+
selected_row["value_units"],
|
217 |
+
selected_row["environmental_units"],
|
218 |
+
selected_row["methodologies_used"],
|
219 |
+
selected_row["calculation_scope"],
|
220 |
+
selected_row["is_range"],
|
221 |
+
],
|
222 |
+
}
|
223 |
+
st.table(table_data)
|
224 |
+
|
225 |
+
st.markdown(f'<a href="{GITHUB_LINK}"><img src="https://img.shields.io/badge/View%20on%20GitHub-blue?logo=github"></a>', unsafe_allow_html=True)
|
226 |
+
|
227 |
+
if __name__ == "__main__":
|
228 |
+
main()
|
app-versions/v4.py
ADDED
@@ -0,0 +1,268 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import plotly.express as px
|
4 |
+
|
5 |
+
# Path to the data file relative to the app.py file
|
6 |
+
DATA_PATH = "data.csv"
|
7 |
+
INSTRUCTIONS_PATH = "instructions.md"
|
8 |
+
|
9 |
+
GITHUB_LINK = "https://github.com/danielrosehill/Emissions-Monetisation-Calculator"
|
10 |
+
|
11 |
+
|
12 |
+
def load_data():
|
13 |
+
try:
|
14 |
+
df = pd.read_csv(DATA_PATH)
|
15 |
+
return df
|
16 |
+
except FileNotFoundError:
|
17 |
+
st.error(
|
18 |
+
f"Error: Could not find the data file at {DATA_PATH}. Please ensure the file exists."
|
19 |
+
)
|
20 |
+
return None
|
21 |
+
|
22 |
+
|
23 |
+
def load_instructions():
|
24 |
+
try:
|
25 |
+
with open(INSTRUCTIONS_PATH, "r") as f:
|
26 |
+
return f.read()
|
27 |
+
except FileNotFoundError:
|
28 |
+
return "Error: Instructions file not found."
|
29 |
+
|
30 |
+
|
31 |
+
def format_currency(value, display_unit):
|
32 |
+
if display_unit == "Millions":
|
33 |
+
formatted_value = f"${value / 1_000_000:.2f} MN"
|
34 |
+
elif display_unit == "Billions":
|
35 |
+
formatted_value = f"${value / 1_000_000_000:.2f} BN"
|
36 |
+
return formatted_value
|
37 |
+
|
38 |
+
|
39 |
+
def main():
|
40 |
+
st.set_page_config(layout="wide")
|
41 |
+
st.markdown("""
|
42 |
+
<style>
|
43 |
+
[data-testid="stHorizontalBlock"] {
|
44 |
+
border: 1px solid #e6e6e6;
|
45 |
+
border-radius: 5px;
|
46 |
+
padding: 1em;
|
47 |
+
margin-bottom: 1em;
|
48 |
+
}
|
49 |
+
</style>
|
50 |
+
""", unsafe_allow_html=True)
|
51 |
+
|
52 |
+
st.title("GHG Emissions Monetization Calculator")
|
53 |
+
st.markdown(
|
54 |
+
"This tool explores the potential financial implications of proposed greenhouse gas emissions costs. It accompanies a repository on Github and Hugging Face that aggregates proposals for the social cost of carbon."
|
55 |
+
)
|
56 |
+
st.markdown(
|
57 |
+
"The social cost of carbon represents the economic damages associated with emitting one additional ton of carbon dioxide into the atmosphere."
|
58 |
+
)
|
59 |
+
st.markdown(
|
60 |
+
"Detailed notes and instructions about the use of this calculator can be found in the Instructions tab."
|
61 |
+
)
|
62 |
+
st.markdown(
|
63 |
+
"This calculator was developed by Daniel Rosehill in December 2024 (danielrosehill.com)."
|
64 |
+
)
|
65 |
+
|
66 |
+
|
67 |
+
# Load the data and instructions
|
68 |
+
df = load_data()
|
69 |
+
instructions = load_instructions()
|
70 |
+
if df is None:
|
71 |
+
return # Don't proceed if data can't be loaded
|
72 |
+
|
73 |
+
# Tabs for calculator, instructions and SCC proposals
|
74 |
+
tabs = st.tabs(["Calculator", "Instructions", "SCC Chart", "SCC Details", "Data"])
|
75 |
+
|
76 |
+
with tabs[0]: # Calculator tab
|
77 |
+
with st.container():
|
78 |
+
st.markdown("### Input your emissions and proposal of interest")
|
79 |
+
left, right = st.columns(2)
|
80 |
+
|
81 |
+
with left:
|
82 |
+
st.subheader("Input Values")
|
83 |
+
st.markdown("Enter your company's greenhouse gas emissions:")
|
84 |
+
scope1_emissions = st.number_input("Scope 1 Emissions", value=0.0)
|
85 |
+
st.markdown("*(Direct emissions from owned or controlled sources)*")
|
86 |
+
scope2_emissions = st.number_input("Scope 2 Emissions", value=0.0)
|
87 |
+
st.markdown("*(Indirect emissions from the generation of purchased energy)*")
|
88 |
+
scope3_emissions = st.number_input("Scope 3 Emissions", value=0.0)
|
89 |
+
st.markdown("*(All other indirect emissions that occur in a company's value chain)*")
|
90 |
+
unit_of_reporting = st.selectbox("Unit of Reporting", ["TCO2E", "MTCO2E"])
|
91 |
+
proposal_names = df['proposal_with_date'].tolist()
|
92 |
+
selected_proposal = st.selectbox("Social cost of carbon proposal", proposal_names)
|
93 |
+
calculate_button = st.button("Calculate Monetized Emissions")
|
94 |
+
|
95 |
+
with right:
|
96 |
+
st.subheader("Calculated Values")
|
97 |
+
if calculate_button:
|
98 |
+
# Calculated emissions
|
99 |
+
scope1_2_emissions = scope1_emissions + scope2_emissions
|
100 |
+
all_scopes_emissions = (
|
101 |
+
scope1_emissions + scope2_emissions + scope3_emissions
|
102 |
+
)
|
103 |
+
st.markdown(
|
104 |
+
f"Scope 1 and 2 Emissions: {scope1_2_emissions:.2f} {unit_of_reporting}"
|
105 |
+
)
|
106 |
+
st.markdown(
|
107 |
+
f"All Scopes Emissions: {all_scopes_emissions:.2f} {unit_of_reporting}"
|
108 |
+
)
|
109 |
+
|
110 |
+
# Find the value in USD per ton
|
111 |
+
selected_row = df[df['proposal_with_date'] == selected_proposal].iloc[0]
|
112 |
+
multiplier = selected_row['usd_proposed_value']
|
113 |
+
|
114 |
+
st.subheader("Monetized Emissions")
|
115 |
+
display_unit = st.radio("Display units", ["Millions", "Billions"])
|
116 |
+
|
117 |
+
if unit_of_reporting == "MTCO2E":
|
118 |
+
scope1_emissions = scope1_emissions * 1_000_000
|
119 |
+
scope2_emissions = scope2_emissions * 1_000_000
|
120 |
+
scope3_emissions = scope3_emissions * 1_000_000
|
121 |
+
all_scopes_emissions = all_scopes_emissions * 1_000_000
|
122 |
+
|
123 |
+
# Monetization calculations
|
124 |
+
monetized_scope1 = scope1_emissions * multiplier
|
125 |
+
monetized_scope2 = scope2_emissions * multiplier
|
126 |
+
monetized_scope3 = scope3_emissions * multiplier
|
127 |
+
monetized_all_scopes = all_scopes_emissions * multiplier
|
128 |
+
|
129 |
+
st.markdown(f"Scope 1: {format_currency(monetized_scope1, display_unit)}")
|
130 |
+
st.markdown(f"Scope 2: {format_currency(monetized_scope2, display_unit)}")
|
131 |
+
st.markdown(f"Scope 3: {format_currency(monetized_scope3, display_unit)}")
|
132 |
+
st.markdown(
|
133 |
+
f"All Scopes: {format_currency(monetized_all_scopes, display_unit)}"
|
134 |
+
)
|
135 |
+
|
136 |
+
with tabs[1]: # Instructions tab
|
137 |
+
st.markdown(instructions)
|
138 |
+
|
139 |
+
with tabs[2]: # SCC Chart tab
|
140 |
+
st.subheader("Social Cost of Carbon Proposals")
|
141 |
+
|
142 |
+
# Convert the 'date' column to datetime objects for proper sorting
|
143 |
+
df['date'] = pd.to_datetime(df['date'])
|
144 |
+
# Sort by date
|
145 |
+
df = df.sort_values(by='date')
|
146 |
+
|
147 |
+
# Create horizontal bar chart
|
148 |
+
bar_fig = px.bar(
|
149 |
+
df,
|
150 |
+
x="usd_proposed_value",
|
151 |
+
y="proposal_with_date",
|
152 |
+
title="Social Cost of Carbon Proposals",
|
153 |
+
labels={
|
154 |
+
"usd_proposed_value": "USD Proposed Value",
|
155 |
+
"proposal_with_date": "Proposal",
|
156 |
+
},
|
157 |
+
orientation='h', # Set orientation to horizontal
|
158 |
+
hover_data={
|
159 |
+
"usd_proposed_value": True,
|
160 |
+
}
|
161 |
+
)
|
162 |
+
bar_fig.update_traces(texttemplate='%{x:.2f}', textposition='outside')
|
163 |
+
st.plotly_chart(bar_fig)
|
164 |
+
|
165 |
+
# Create line chart with data points and custom hover text
|
166 |
+
show_points = st.checkbox("Display Data Points", value = True)
|
167 |
+
line_fig = px.line(
|
168 |
+
df,
|
169 |
+
x="date",
|
170 |
+
y="usd_proposed_value",
|
171 |
+
title="Trend of Social Cost of Carbon Proposals Over Time",
|
172 |
+
labels={
|
173 |
+
"usd_proposed_value": "USD Proposed Value",
|
174 |
+
"date": "Date",
|
175 |
+
},
|
176 |
+
hover_data={
|
177 |
+
"usd_proposed_value": False,
|
178 |
+
"proposal_with_date": True,
|
179 |
+
},
|
180 |
+
|
181 |
+
)
|
182 |
+
|
183 |
+
line_fig.update_traces(
|
184 |
+
mode="lines+markers" if show_points else "lines",
|
185 |
+
hovertemplate="<b>%{hovertext}</b>", # Customize hover text
|
186 |
+
text=df["proposal_with_date"], # Add the text data
|
187 |
+
marker=dict(size=6) # Make the markers smaller
|
188 |
+
|
189 |
+
)
|
190 |
+
|
191 |
+
st.plotly_chart(line_fig)
|
192 |
+
|
193 |
+
|
194 |
+
with tabs[3]: # SCC Details tab
|
195 |
+
st.subheader("Social Cost of Carbon Proposal Details")
|
196 |
+
proposal_names = df["proposal_with_date"].tolist()
|
197 |
+
selected_proposal = st.selectbox("Select a proposal", proposal_names)
|
198 |
+
|
199 |
+
if selected_proposal:
|
200 |
+
selected_row = df[df["proposal_with_date"] == selected_proposal].iloc[0]
|
201 |
+
|
202 |
+
# Prepare data for the table
|
203 |
+
col1, col2 = st.columns(2)
|
204 |
+
with col1:
|
205 |
+
st.markdown(" **Organization Name:**")
|
206 |
+
st.markdown(" **Organization Description:**")
|
207 |
+
st.markdown(" **Date:**")
|
208 |
+
st.markdown(" **Country:**")
|
209 |
+
st.markdown(" **ISO3:**")
|
210 |
+
st.markdown(" **ISO2:**")
|
211 |
+
st.markdown(" **HDI Value:**")
|
212 |
+
st.markdown(" **HDI Category:**")
|
213 |
+
st.markdown(" **Details:**")
|
214 |
+
with col2:
|
215 |
+
st.markdown(selected_row["organization_name"])
|
216 |
+
st.markdown(selected_row["organization_description"])
|
217 |
+
st.markdown(selected_row["date"].strftime('%Y-%m-%d'))
|
218 |
+
st.markdown(selected_row["country"])
|
219 |
+
st.markdown(selected_row["iso3"])
|
220 |
+
st.markdown(selected_row["iso2"])
|
221 |
+
st.markdown(str(selected_row["hdi_value"]))
|
222 |
+
st.markdown(selected_row["hdi_category"])
|
223 |
+
st.markdown(selected_row["details"])
|
224 |
+
|
225 |
+
col3, col4 = st.columns(2)
|
226 |
+
with col3:
|
227 |
+
st.markdown(" **Original Proposed Value:**")
|
228 |
+
st.markdown(" **Average Value:**")
|
229 |
+
st.markdown(" **USD Proposed Value:**")
|
230 |
+
st.markdown(" **USD Proposed Value (Empty CO2e):**")
|
231 |
+
st.markdown(" **USD Conversion Date:**")
|
232 |
+
st.markdown(" **Value Units:**")
|
233 |
+
st.markdown(" **Environmental Units:**")
|
234 |
+
st.markdown(" **Methodologies Used:**")
|
235 |
+
st.markdown(" **Calculation Scope:**")
|
236 |
+
st.markdown(" **Is Range:**")
|
237 |
+
with col4:
|
238 |
+
st.markdown(f"{selected_row['original_proposed_value']} {selected_row['original_currency_name']}")
|
239 |
+
st.markdown(str(selected_row["average_value"]))
|
240 |
+
st.markdown(str(selected_row["usd_proposed_value"]))
|
241 |
+
st.markdown(str(selected_row['use_proposed_value_mtco2e']))
|
242 |
+
st.markdown(str(selected_row["usd_conversion_date"]))
|
243 |
+
st.markdown(selected_row["value_units"])
|
244 |
+
st.markdown(selected_row["environmental_units"])
|
245 |
+
st.markdown(selected_row["methodologies_used"])
|
246 |
+
st.markdown(selected_row["calculation_scope"])
|
247 |
+
st.markdown(str(selected_row["is_range"]))
|
248 |
+
|
249 |
+
with tabs[4]: # Data Tab
|
250 |
+
st.subheader("Data")
|
251 |
+
st.dataframe(df)
|
252 |
+
st.markdown("#### Download Data")
|
253 |
+
|
254 |
+
def convert_df(df):
|
255 |
+
return df.to_csv().encode('utf-8')
|
256 |
+
|
257 |
+
csv = convert_df(df)
|
258 |
+
st.download_button(
|
259 |
+
label="Download data as CSV",
|
260 |
+
data=csv,
|
261 |
+
file_name='scc_data.csv',
|
262 |
+
mime='text/csv',
|
263 |
+
)
|
264 |
+
|
265 |
+
st.markdown(f'<a href="{GITHUB_LINK}"><img src="https://img.shields.io/badge/View%20on%20GitHub-blue?logo=github"></a>', unsafe_allow_html=True)
|
266 |
+
|
267 |
+
if __name__ == "__main__":
|
268 |
+
main()
|
app-versions/v5.py
ADDED
@@ -0,0 +1,278 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import plotly.express as px
|
4 |
+
|
5 |
+
# Path to the data file relative to the app.py file
|
6 |
+
DATA_PATH = "data.csv"
|
7 |
+
INSTRUCTIONS_PATH = "instructions.md"
|
8 |
+
|
9 |
+
GITHUB_LINK = "https://github.com/danielrosehill/Emissions-Monetisation-Calculator"
|
10 |
+
|
11 |
+
|
12 |
+
def load_data():
|
13 |
+
try:
|
14 |
+
df = pd.read_csv(DATA_PATH)
|
15 |
+
return df
|
16 |
+
except FileNotFoundError:
|
17 |
+
st.error(
|
18 |
+
f"Error: Could not find the data file at {DATA_PATH}. Please ensure the file exists."
|
19 |
+
)
|
20 |
+
return None
|
21 |
+
|
22 |
+
|
23 |
+
def load_instructions():
|
24 |
+
try:
|
25 |
+
with open(INSTRUCTIONS_PATH, "r") as f:
|
26 |
+
return f.read()
|
27 |
+
except FileNotFoundError:
|
28 |
+
return "Error: Instructions file not found."
|
29 |
+
|
30 |
+
|
31 |
+
def format_currency(value, display_unit):
|
32 |
+
if display_unit == "Millions":
|
33 |
+
formatted_value = f"${value / 1_000_000:.2f} MN"
|
34 |
+
elif display_unit == "Billions":
|
35 |
+
formatted_value = f"${value / 1_000_000_000:.2f} BN"
|
36 |
+
return formatted_value
|
37 |
+
|
38 |
+
|
39 |
+
def main():
|
40 |
+
st.set_page_config(layout="wide")
|
41 |
+
st.markdown("""
|
42 |
+
<style>
|
43 |
+
[data-testid="stHorizontalBlock"] {
|
44 |
+
border: 1px solid #e6e6e6;
|
45 |
+
border-radius: 5px;
|
46 |
+
padding: 1em;
|
47 |
+
margin-bottom: 1em;
|
48 |
+
}
|
49 |
+
</style>
|
50 |
+
""", unsafe_allow_html=True)
|
51 |
+
|
52 |
+
st.title("GHG Emissions Monetization Calculator")
|
53 |
+
st.markdown(
|
54 |
+
"This tool explores the potential financial implications of proposed greenhouse gas emissions costs. It accompanies a repository on Github and Hugging Face that aggregates proposals for the social cost of carbon."
|
55 |
+
)
|
56 |
+
st.markdown(
|
57 |
+
"The social cost of carbon represents the economic damages associated with emitting one additional ton of carbon dioxide into the atmosphere."
|
58 |
+
)
|
59 |
+
st.markdown(
|
60 |
+
"Detailed notes and instructions about the use of this calculator can be found in the Instructions tab."
|
61 |
+
)
|
62 |
+
st.markdown(
|
63 |
+
"This calculator was developed by Daniel Rosehill in December 2024 (danielrosehill.com)."
|
64 |
+
)
|
65 |
+
|
66 |
+
|
67 |
+
# Load the data and instructions
|
68 |
+
df = load_data()
|
69 |
+
instructions = load_instructions()
|
70 |
+
if df is None:
|
71 |
+
return # Don't proceed if data can't be loaded
|
72 |
+
|
73 |
+
# Tabs for calculator, instructions and SCC proposals
|
74 |
+
tabs = st.tabs(["Calculator", "Instructions", "SCC Chart", "SCC Details", "Data"])
|
75 |
+
|
76 |
+
with tabs[0]: # Calculator tab
|
77 |
+
with st.container():
|
78 |
+
st.markdown("### Input your emissions and proposal of interest")
|
79 |
+
left, right = st.columns(2)
|
80 |
+
|
81 |
+
with left:
|
82 |
+
st.subheader("Input Values")
|
83 |
+
st.markdown("Enter your company's greenhouse gas emissions:")
|
84 |
+
scope1_emissions = st.number_input("Scope 1 Emissions", value=0.0)
|
85 |
+
st.markdown("*(Direct emissions from owned or controlled sources)*")
|
86 |
+
scope2_emissions = st.number_input("Scope 2 Emissions", value=0.0)
|
87 |
+
st.markdown("*(Indirect emissions from the generation of purchased energy)*")
|
88 |
+
scope3_emissions = st.number_input("Scope 3 Emissions", value=0.0)
|
89 |
+
st.markdown("*(All other indirect emissions that occur in a company's value chain)*")
|
90 |
+
unit_of_reporting = st.selectbox("Unit of Reporting", ["TCO2E", "MTCO2E"])
|
91 |
+
proposal_names = df['proposal_with_date'].tolist()
|
92 |
+
selected_proposal = st.selectbox("Social cost of carbon proposal", proposal_names)
|
93 |
+
calculate_button = st.button("Calculate Monetized Emissions")
|
94 |
+
|
95 |
+
with right:
|
96 |
+
st.subheader("Calculated Values")
|
97 |
+
if calculate_button:
|
98 |
+
# Calculated emissions
|
99 |
+
scope1_2_emissions = scope1_emissions + scope2_emissions
|
100 |
+
all_scopes_emissions = (
|
101 |
+
scope1_emissions + scope2_emissions + scope3_emissions
|
102 |
+
)
|
103 |
+
st.markdown(
|
104 |
+
f"Scope 1 and 2 Emissions: {scope1_2_emissions:.2f} {unit_of_reporting}"
|
105 |
+
)
|
106 |
+
st.markdown(
|
107 |
+
f"All Scopes Emissions: {all_scopes_emissions:.2f} {unit_of_reporting}"
|
108 |
+
)
|
109 |
+
|
110 |
+
# Find the value in USD per ton
|
111 |
+
selected_row = df[df['proposal_with_date'] == selected_proposal].iloc[0]
|
112 |
+
multiplier = selected_row['usd_proposed_value']
|
113 |
+
|
114 |
+
st.subheader("Monetized Emissions")
|
115 |
+
display_unit = st.radio("Display units", ["Millions", "Billions"])
|
116 |
+
|
117 |
+
if unit_of_reporting == "MTCO2E":
|
118 |
+
scope1_emissions = scope1_emissions * 1_000_000
|
119 |
+
scope2_emissions = scope2_emissions * 1_000_000
|
120 |
+
scope3_emissions = scope3_emissions * 1_000_000
|
121 |
+
all_scopes_emissions = all_scopes_emissions * 1_000_000
|
122 |
+
|
123 |
+
# Monetization calculations
|
124 |
+
monetized_scope1 = scope1_emissions * multiplier
|
125 |
+
monetized_scope2 = scope2_emissions * multiplier
|
126 |
+
monetized_scope3 = scope3_emissions * multiplier
|
127 |
+
monetized_all_scopes = all_scopes_emissions * multiplier
|
128 |
+
|
129 |
+
st.markdown(f"Scope 1: {format_currency(monetized_scope1, display_unit)}")
|
130 |
+
st.markdown(f"Scope 2: {format_currency(monetized_scope2, display_unit)}")
|
131 |
+
st.markdown(f"Scope 3: {format_currency(monetized_scope3, display_unit)}")
|
132 |
+
st.markdown(
|
133 |
+
f"All Scopes: {format_currency(monetized_all_scopes, display_unit)}"
|
134 |
+
)
|
135 |
+
|
136 |
+
with tabs[1]: # Instructions tab
|
137 |
+
st.markdown(instructions)
|
138 |
+
|
139 |
+
with tabs[2]: # SCC Chart tab
|
140 |
+
st.subheader("Social Cost of Carbon Proposals")
|
141 |
+
|
142 |
+
# Convert the 'date' column to datetime objects for proper sorting
|
143 |
+
df['date'] = pd.to_datetime(df['date'])
|
144 |
+
# Sort by value
|
145 |
+
df_sorted = df.sort_values(by='usd_proposed_value', ascending=True)
|
146 |
+
|
147 |
+
# Create horizontal bar chart
|
148 |
+
bar_fig = px.bar(
|
149 |
+
df_sorted,
|
150 |
+
x="usd_proposed_value",
|
151 |
+
y="proposal_with_date",
|
152 |
+
title="Social Cost of Carbon Proposals",
|
153 |
+
labels={
|
154 |
+
"usd_proposed_value": "USD Proposed Value",
|
155 |
+
"proposal_with_date": "Proposal",
|
156 |
+
},
|
157 |
+
orientation='h', # Set orientation to horizontal
|
158 |
+
hover_data={
|
159 |
+
"usd_proposed_value": True,
|
160 |
+
}
|
161 |
+
)
|
162 |
+
bar_fig.update_traces(texttemplate='%{x:.2f}', textposition='outside')
|
163 |
+
st.plotly_chart(bar_fig)
|
164 |
+
|
165 |
+
# Organization filter
|
166 |
+
organizations = df['organization_name'].unique().tolist()
|
167 |
+
selected_org = st.selectbox("Filter by organization", ["All"] + organizations)
|
168 |
+
|
169 |
+
# Filter data
|
170 |
+
if selected_org != "All":
|
171 |
+
filtered_df = df[df['organization_name'] == selected_org]
|
172 |
+
else:
|
173 |
+
filtered_df = df
|
174 |
+
|
175 |
+
# Create line chart with data points and custom hover text
|
176 |
+
show_points = st.checkbox("Display Data Points", value=True)
|
177 |
+
line_fig = px.line(
|
178 |
+
filtered_df,
|
179 |
+
x="date",
|
180 |
+
y="usd_proposed_value",
|
181 |
+
title="Trend of Social Cost of Carbon Proposals Over Time",
|
182 |
+
labels={
|
183 |
+
"usd_proposed_value": "USD Proposed Value",
|
184 |
+
"date": "Date",
|
185 |
+
},
|
186 |
+
hover_data={
|
187 |
+
"usd_proposed_value": True,
|
188 |
+
"proposal_with_date": True,
|
189 |
+
"organization_name": True,
|
190 |
+
},
|
191 |
+
)
|
192 |
+
|
193 |
+
line_fig.update_traces(
|
194 |
+
mode="lines+markers" if show_points else "lines",
|
195 |
+
hovertemplate="<b>%{hovertext}</b><br>USD Value: %{y:.2f}<br>Proposal: %{customdata[0]}<br>Organization: %{customdata[1]}",
|
196 |
+
text=filtered_df["proposal_with_date"],
|
197 |
+
marker=dict(size=6),
|
198 |
+
customdata=filtered_df[["proposal_with_date","organization_name"]]
|
199 |
+
)
|
200 |
+
|
201 |
+
st.plotly_chart(line_fig)
|
202 |
+
|
203 |
+
|
204 |
+
with tabs[3]: # SCC Details tab
|
205 |
+
st.subheader("Social Cost of Carbon Proposal Details")
|
206 |
+
proposal_names = df["proposal_with_date"].tolist()
|
207 |
+
selected_proposal = st.selectbox("Select a proposal", proposal_names)
|
208 |
+
|
209 |
+
if selected_proposal:
|
210 |
+
selected_row = df[df["proposal_with_date"] == selected_proposal].iloc[0]
|
211 |
+
|
212 |
+
# Prepare data for the table
|
213 |
+
col1, col2 = st.columns(2)
|
214 |
+
with col1:
|
215 |
+
st.markdown(" **Organization Name:**")
|
216 |
+
st.markdown(" **Organization Description:**")
|
217 |
+
st.markdown(" **Date:**")
|
218 |
+
st.markdown(" **Country:**")
|
219 |
+
st.markdown(" **ISO3:**")
|
220 |
+
st.markdown(" **ISO2:**")
|
221 |
+
st.markdown(" **HDI Value:**")
|
222 |
+
st.markdown(" **HDI Category:**")
|
223 |
+
st.markdown(" **Details:**")
|
224 |
+
with col2:
|
225 |
+
st.markdown(selected_row["organization_name"])
|
226 |
+
st.markdown(selected_row["organization_description"])
|
227 |
+
st.markdown(selected_row["date"].strftime('%Y-%m-%d'))
|
228 |
+
st.markdown(selected_row["country"])
|
229 |
+
st.markdown(selected_row["iso3"])
|
230 |
+
st.markdown(selected_row["iso2"])
|
231 |
+
st.markdown(str(selected_row["hdi_value"]))
|
232 |
+
st.markdown(selected_row["hdi_category"])
|
233 |
+
st.markdown(selected_row["details"])
|
234 |
+
|
235 |
+
col3, col4 = st.columns(2)
|
236 |
+
with col3:
|
237 |
+
st.markdown(" **Original Proposed Value:**")
|
238 |
+
st.markdown(" **Average Value:**")
|
239 |
+
st.markdown(" **USD Proposed Value:**")
|
240 |
+
st.markdown(" **USD Proposed Value (Empty CO2e):**")
|
241 |
+
st.markdown(" **USD Conversion Date:**")
|
242 |
+
st.markdown(" **Value Units:**")
|
243 |
+
st.markdown(" **Environmental Units:**")
|
244 |
+
st.markdown(" **Methodologies Used:**")
|
245 |
+
st.markdown(" **Calculation Scope:**")
|
246 |
+
st.markdown(" **Is Range:**")
|
247 |
+
with col4:
|
248 |
+
st.markdown(f"{selected_row['original_proposed_value']} {selected_row['original_currency_name']}")
|
249 |
+
st.markdown(str(selected_row["average_value"]))
|
250 |
+
st.markdown(str(selected_row["usd_proposed_value"]))
|
251 |
+
st.markdown(str(selected_row['use_proposed_value_mtco2e']))
|
252 |
+
st.markdown(str(selected_row["usd_conversion_date"]))
|
253 |
+
st.markdown(selected_row["value_units"])
|
254 |
+
st.markdown(selected_row["environmental_units"])
|
255 |
+
st.markdown(selected_row["methodologies_used"])
|
256 |
+
st.markdown(selected_row["calculation_scope"])
|
257 |
+
st.markdown(str(selected_row["is_range"]))
|
258 |
+
|
259 |
+
with tabs[4]: # Data Tab
|
260 |
+
st.subheader("Data")
|
261 |
+
st.dataframe(df)
|
262 |
+
st.markdown("#### Download Data")
|
263 |
+
|
264 |
+
def convert_df(df):
|
265 |
+
return df.to_csv().encode('utf-8')
|
266 |
+
|
267 |
+
csv = convert_df(df)
|
268 |
+
st.download_button(
|
269 |
+
label="Download data as CSV",
|
270 |
+
data=csv,
|
271 |
+
file_name='scc_data.csv',
|
272 |
+
mime='text/csv',
|
273 |
+
)
|
274 |
+
|
275 |
+
st.markdown(f'<a href="{GITHUB_LINK}"><img src="https://img.shields.io/badge/View%20on%20GitHub-blue?logo=github"></a>', unsafe_allow_html=True)
|
276 |
+
|
277 |
+
if __name__ == "__main__":
|
278 |
+
main()
|
calculator-app/app.py
ADDED
@@ -0,0 +1,281 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import plotly.express as px
|
4 |
+
|
5 |
+
# Path to the data file relative to the app.py file
|
6 |
+
DATA_PATH = "data.csv"
|
7 |
+
INSTRUCTIONS_PATH = "instructions.md"
|
8 |
+
|
9 |
+
GITHUB_LINK = "https://github.com/danielrosehill/Emissions-Monetisation-Calculator"
|
10 |
+
|
11 |
+
|
12 |
+
def load_data():
|
13 |
+
try:
|
14 |
+
df = pd.read_csv(DATA_PATH)
|
15 |
+
return df
|
16 |
+
except FileNotFoundError:
|
17 |
+
st.error(
|
18 |
+
f"Error: Could not find the data file at {DATA_PATH}. Please ensure the file exists."
|
19 |
+
)
|
20 |
+
return None
|
21 |
+
|
22 |
+
|
23 |
+
def load_instructions():
|
24 |
+
try:
|
25 |
+
with open(INSTRUCTIONS_PATH, "r") as f:
|
26 |
+
return f.read()
|
27 |
+
except FileNotFoundError:
|
28 |
+
return "Error: Instructions file not found."
|
29 |
+
|
30 |
+
|
31 |
+
def format_currency(value, display_unit):
|
32 |
+
if display_unit == "Millions":
|
33 |
+
formatted_value = f"${value / 1_000_000:.2f} MN"
|
34 |
+
elif display_unit == "Billions":
|
35 |
+
formatted_value = f"${value / 1_000_000_000:.2f} BN"
|
36 |
+
return formatted_value
|
37 |
+
|
38 |
+
|
39 |
+
def main():
|
40 |
+
st.set_page_config(layout="wide")
|
41 |
+
st.markdown("""
|
42 |
+
<style>
|
43 |
+
[data-testid="stHorizontalBlock"] {
|
44 |
+
border: 1px solid #e6e6e6;
|
45 |
+
border-radius: 5px;
|
46 |
+
padding: 1em;
|
47 |
+
margin-bottom: 1em;
|
48 |
+
}
|
49 |
+
</style>
|
50 |
+
""", unsafe_allow_html=True)
|
51 |
+
|
52 |
+
st.title("GHG Emissions Monetization Calculator")
|
53 |
+
st.markdown(
|
54 |
+
"This tool explores the potential financial implications of proposed greenhouse gas emissions costs. It accompanies a repository on Github and Hugging Face that aggregates proposals for the social cost of carbon."
|
55 |
+
)
|
56 |
+
st.markdown(
|
57 |
+
"The social cost of carbon represents the economic damages associated with emitting one additional ton of carbon dioxide into the atmosphere."
|
58 |
+
)
|
59 |
+
st.markdown(
|
60 |
+
"Detailed notes and instructions about the use of this calculator can be found in the Instructions tab."
|
61 |
+
)
|
62 |
+
st.markdown(
|
63 |
+
"This calculator was developed by Daniel Rosehill in December 2024 (danielrosehill.com)."
|
64 |
+
)
|
65 |
+
|
66 |
+
|
67 |
+
# Load the data and instructions
|
68 |
+
df = load_data()
|
69 |
+
instructions = load_instructions()
|
70 |
+
if df is None:
|
71 |
+
return # Don't proceed if data can't be loaded
|
72 |
+
|
73 |
+
# Tabs for calculator, instructions and SCC proposals
|
74 |
+
tabs = st.tabs(["Calculator", "Instructions", "SCC Chart", "SCC Details", "Data"])
|
75 |
+
|
76 |
+
with tabs[0]: # Calculator tab
|
77 |
+
with st.container():
|
78 |
+
st.markdown("### Input your emissions and proposal of interest")
|
79 |
+
left, right = st.columns(2)
|
80 |
+
|
81 |
+
with left:
|
82 |
+
st.subheader("Input Values")
|
83 |
+
st.markdown("Enter your company's greenhouse gas emissions:")
|
84 |
+
scope1_emissions = st.number_input("Scope 1 Emissions", value=0.0)
|
85 |
+
st.markdown("*(Direct emissions from owned or controlled sources)*")
|
86 |
+
scope2_emissions = st.number_input("Scope 2 Emissions", value=0.0)
|
87 |
+
st.markdown("*(Indirect emissions from the generation of purchased energy)*")
|
88 |
+
scope3_emissions = st.number_input("Scope 3 Emissions", value=0.0)
|
89 |
+
st.markdown("*(All other indirect emissions that occur in a company's value chain)*")
|
90 |
+
unit_of_reporting = st.selectbox("Unit of Reporting", ["TCO2E", "MTCO2E"])
|
91 |
+
proposal_names = df['proposal_with_date'].tolist()
|
92 |
+
selected_proposal = st.selectbox("Social cost of carbon proposal", proposal_names)
|
93 |
+
calculate_button = st.button("Calculate Monetized Emissions")
|
94 |
+
|
95 |
+
with right:
|
96 |
+
st.subheader("Calculated Values")
|
97 |
+
if calculate_button:
|
98 |
+
# Calculated emissions
|
99 |
+
scope1_2_emissions = scope1_emissions + scope2_emissions
|
100 |
+
all_scopes_emissions = (
|
101 |
+
scope1_emissions + scope2_emissions + scope3_emissions
|
102 |
+
)
|
103 |
+
st.markdown(
|
104 |
+
f"Scope 1 and 2 Emissions: {scope1_2_emissions:.2f} {unit_of_reporting}"
|
105 |
+
)
|
106 |
+
st.markdown(
|
107 |
+
f"All Scopes Emissions: {all_scopes_emissions:.2f} {unit_of_reporting}"
|
108 |
+
)
|
109 |
+
|
110 |
+
# Find the value in USD per ton
|
111 |
+
selected_row = df[df['proposal_with_date'] == selected_proposal].iloc[0]
|
112 |
+
multiplier = selected_row['usd_proposed_value']
|
113 |
+
|
114 |
+
st.subheader("Monetized Emissions")
|
115 |
+
display_unit = st.radio("Display units", ["Millions", "Billions"])
|
116 |
+
|
117 |
+
if unit_of_reporting == "MTCO2E":
|
118 |
+
scope1_emissions = scope1_emissions * 1_000_000
|
119 |
+
scope2_emissions = scope2_emissions * 1_000_000
|
120 |
+
scope3_emissions = scope3_emissions * 1_000_000
|
121 |
+
all_scopes_emissions = all_scopes_emissions * 1_000_000
|
122 |
+
|
123 |
+
# Monetization calculations
|
124 |
+
monetized_scope1 = scope1_emissions * multiplier
|
125 |
+
monetized_scope2 = scope2_emissions * multiplier
|
126 |
+
monetized_scope3 = scope3_emissions * multiplier
|
127 |
+
monetized_all_scopes = all_scopes_emissions * multiplier
|
128 |
+
|
129 |
+
st.markdown(f"Scope 1: {format_currency(monetized_scope1, display_unit)}")
|
130 |
+
st.markdown(f"Scope 2: {format_currency(monetized_scope2, display_unit)}")
|
131 |
+
st.markdown(f"Scope 3: {format_currency(monetized_scope3, display_unit)}")
|
132 |
+
st.markdown(
|
133 |
+
f"All Scopes: {format_currency(monetized_all_scopes, display_unit)}"
|
134 |
+
)
|
135 |
+
|
136 |
+
with tabs[1]: # Instructions tab
|
137 |
+
st.markdown(instructions)
|
138 |
+
|
139 |
+
with tabs[2]: # SCC Chart tab
|
140 |
+
st.subheader("Social Cost of Carbon Proposals")
|
141 |
+
|
142 |
+
# Convert the 'date' column to datetime objects for proper sorting
|
143 |
+
df['date'] = pd.to_datetime(df['date'])
|
144 |
+
# Sort by value
|
145 |
+
df_sorted = df.sort_values(by='usd_proposed_value', ascending=True)
|
146 |
+
|
147 |
+
# Create horizontal bar chart
|
148 |
+
bar_fig = px.bar(
|
149 |
+
df_sorted,
|
150 |
+
x="usd_proposed_value",
|
151 |
+
y="proposal_with_date",
|
152 |
+
title="Social Cost of Carbon Proposals",
|
153 |
+
labels={
|
154 |
+
"usd_proposed_value": "USD Proposed Value",
|
155 |
+
"proposal_with_date": "Proposal",
|
156 |
+
},
|
157 |
+
orientation='h', # Set orientation to horizontal
|
158 |
+
hover_data={
|
159 |
+
"usd_proposed_value": True,
|
160 |
+
}
|
161 |
+
)
|
162 |
+
bar_fig.update_traces(texttemplate='%{x:.2f}', textposition='outside')
|
163 |
+
st.plotly_chart(bar_fig)
|
164 |
+
|
165 |
+
# Organization filter
|
166 |
+
organizations = df['organization_name'].unique().tolist()
|
167 |
+
selected_org = st.selectbox("Filter by organization", ["All"] + organizations)
|
168 |
+
|
169 |
+
# Filter data
|
170 |
+
if selected_org != "All":
|
171 |
+
filtered_df = df[df['organization_name'] == selected_org]
|
172 |
+
else:
|
173 |
+
filtered_df = df
|
174 |
+
|
175 |
+
# Sort the data by date before creating the line chart
|
176 |
+
filtered_df = filtered_df.sort_values(by='date')
|
177 |
+
|
178 |
+
# Create line chart with data points and custom hover text
|
179 |
+
show_points = st.checkbox("Display Data Points", value=True)
|
180 |
+
line_fig = px.line(
|
181 |
+
filtered_df,
|
182 |
+
x="date",
|
183 |
+
y="usd_proposed_value",
|
184 |
+
title="Trend of Social Cost of Carbon Proposals Over Time",
|
185 |
+
labels={
|
186 |
+
"usd_proposed_value": "USD Proposed Value",
|
187 |
+
"date": "Date",
|
188 |
+
},
|
189 |
+
hover_data={
|
190 |
+
"usd_proposed_value": True,
|
191 |
+
"proposal_with_date": True,
|
192 |
+
"organization_name": True,
|
193 |
+
},
|
194 |
+
)
|
195 |
+
|
196 |
+
line_fig.update_traces(
|
197 |
+
mode="lines+markers" if show_points else "lines",
|
198 |
+
hovertemplate="USD Value: %{y:.2f}<br>Proposal: %{customdata[0]}<br>Organization: %{customdata[1]}",
|
199 |
+
text=filtered_df["proposal_with_date"],
|
200 |
+
marker=dict(size=6),
|
201 |
+
customdata=filtered_df[["proposal_with_date","organization_name"]]
|
202 |
+
)
|
203 |
+
|
204 |
+
st.plotly_chart(line_fig)
|
205 |
+
|
206 |
+
|
207 |
+
with tabs[3]: # SCC Details tab
|
208 |
+
st.subheader("Social Cost of Carbon Proposal Details")
|
209 |
+
proposal_names = df["proposal_with_date"].tolist()
|
210 |
+
selected_proposal = st.selectbox("Select a proposal", proposal_names)
|
211 |
+
|
212 |
+
if selected_proposal:
|
213 |
+
selected_row = df[df["proposal_with_date"] == selected_proposal].iloc[0]
|
214 |
+
|
215 |
+
# Prepare data for the table
|
216 |
+
col1, col2 = st.columns(2)
|
217 |
+
with col1:
|
218 |
+
st.markdown(" **Organization Name:**")
|
219 |
+
st.markdown(" **Organization Description:**")
|
220 |
+
st.markdown(" **Date:**")
|
221 |
+
st.markdown(" **Country:**")
|
222 |
+
st.markdown(" **ISO3:**")
|
223 |
+
st.markdown(" **ISO2:**")
|
224 |
+
st.markdown(" **HDI Value:**")
|
225 |
+
st.markdown(" **HDI Category:**")
|
226 |
+
st.markdown(" **Details:**")
|
227 |
+
with col2:
|
228 |
+
st.markdown(selected_row["organization_name"])
|
229 |
+
st.markdown(selected_row["organization_description"])
|
230 |
+
st.markdown(selected_row["date"].strftime('%Y-%m-%d'))
|
231 |
+
st.markdown(selected_row["country"])
|
232 |
+
st.markdown(selected_row["iso3"])
|
233 |
+
st.markdown(selected_row["iso2"])
|
234 |
+
st.markdown(str(selected_row["hdi_value"]))
|
235 |
+
st.markdown(selected_row["hdi_category"])
|
236 |
+
st.markdown(selected_row["details"])
|
237 |
+
|
238 |
+
col3, col4 = st.columns(2)
|
239 |
+
with col3:
|
240 |
+
st.markdown(" **Original Proposed Value:**")
|
241 |
+
st.markdown(" **Average Value:**")
|
242 |
+
st.markdown(" **USD Proposed Value:**")
|
243 |
+
st.markdown(" **USD Proposed Value (Empty CO2e):**")
|
244 |
+
st.markdown(" **USD Conversion Date:**")
|
245 |
+
st.markdown(" **Value Units:**")
|
246 |
+
st.markdown(" **Environmental Units:**")
|
247 |
+
st.markdown(" **Methodologies Used:**")
|
248 |
+
st.markdown(" **Calculation Scope:**")
|
249 |
+
st.markdown(" **Is Range:**")
|
250 |
+
with col4:
|
251 |
+
st.markdown(f"{selected_row['original_proposed_value']} {selected_row['original_currency_name']}")
|
252 |
+
st.markdown(str(selected_row["average_value"]))
|
253 |
+
st.markdown(str(selected_row["usd_proposed_value"]))
|
254 |
+
st.markdown(str(selected_row['use_proposed_value_mtco2e']))
|
255 |
+
st.markdown(str(selected_row["usd_conversion_date"]))
|
256 |
+
st.markdown(selected_row["value_units"])
|
257 |
+
st.markdown(selected_row["environmental_units"])
|
258 |
+
st.markdown(selected_row["methodologies_used"])
|
259 |
+
st.markdown(selected_row["calculation_scope"])
|
260 |
+
st.markdown(str(selected_row["is_range"]))
|
261 |
+
|
262 |
+
with tabs[4]: # Data Tab
|
263 |
+
st.subheader("Data")
|
264 |
+
st.dataframe(df)
|
265 |
+
st.markdown("#### Download Data")
|
266 |
+
|
267 |
+
def convert_df(df):
|
268 |
+
return df.to_csv().encode('utf-8')
|
269 |
+
|
270 |
+
csv = convert_df(df)
|
271 |
+
st.download_button(
|
272 |
+
label="Download data as CSV",
|
273 |
+
data=csv,
|
274 |
+
file_name='scc_data.csv',
|
275 |
+
mime='text/csv',
|
276 |
+
)
|
277 |
+
|
278 |
+
st.markdown(f'<a href="{GITHUB_LINK}"><img src="https://img.shields.io/badge/View%20on%20GitHub-blue?logo=github"></a>', unsafe_allow_html=True)
|
279 |
+
|
280 |
+
if __name__ == "__main__":
|
281 |
+
main()
|
calculator-app/data.csv
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
proposal_with_date,organization_name,organization_description,date,country,iso3,iso2,hdi_value,hdi_category,details,original_proposed_value,original_currency_name,original_currency_iso,average_value,usd_proposed_value,use_proposed_value_mtco2e,usd_conversion_date,value_units,environmental_units,methodologies_used,calculation_scope,is_range,
|
2 |
+
International Foundation for Valuing Impacts (Apr 2024),International Foundation for Valuing Impacts,A non-profit organization working to standardize impact valuation.,2024-04-01,United States,USA,US,0.92,Very High,Proposed a standardized approach for companies to report GHG emissions monetarily.,$236,US dollars,USD,236,236,236000000,2024-11-20,dollars per ton CO2e,tons of carbon dioxide equivalents,Standardized impact valuation,Social Cost of Carbon,0,
|
3 |
+
EPA (Final Report) (Dec 2023),Environmental Protection Agency,The primary federal agency responsible for environmental protection.,2023-12-01,United States,USA,US,0.92,Very High,Updated SCC values using advanced methodologies and lower discount rates.,$120-$340,US dollars,USD,230,230,230000000,2024-11-20,dollars per ton CO2e,tons of carbon dioxide equivalents,Advanced methodologies,Social Cost of Carbon,1,
|
4 |
+
U.S. EPA (Updated Proposal) (Dec 2023),Environmental Protection Agency,The primary federal agency responsible for environmental protection.,2023-12-01,United States,USA,US,0.92,Very High,"Finalized updated SCC values, reflecting significant increases based on best science.",$190,US dollars,USD,190,190,190000000,2024-11-20,dollars per ton CO2e,tons of carbon dioxide equivalents,Best available science,Social Cost of Carbon,0,
|
5 |
+
UC Davis (July 2023),University of California, Davis,2023-07-01,United States,USA,US,0.92,Very High,Equity-weighted SCC emphasizing climate damages and uncertainty.,$283,US dollars,USD,283,283,283000000,2024-11-20,dollars per ton CO2e,tons of carbon dioxide equivalents,tons of carbon dioxide equivalents,Social Cost of Carbon,0,
|
6 |
+
IMF (Jan 2023),International Monetary Fund,An international organization promoting global financial stability.,2023-01-01,United States,USA,US,0.92,Very High,Proposed international carbon price floor based on income levels of countries.,$15-$50,US dollars,USD,32.5,32.5,32500000,2024-11-20,dollars per ton CO2e,tons of carbon dioxide equivalents,Income-based carbon price floor,Carbon Pricing,1,
|
7 |
+
New York State Agencies (Jan 2021),New York State Agencies,Various state agencies working on climate policy.,2021-01-01,United States,USA,US,0.92,Very High,Guidance under Climate Leadership Act to reduce emissions and achieve net-zero.,$125,US dollars,USD,125,125,125000000,2024-11-20,dollars per ton CO2e,tons of carbon dioxide equivalents,Climate Leadership Act guidance,Social Cost of Carbon,0,
|
8 |
+
Biden Administration (IWG Interim Update) (Feb 2021),Biden Administration Interagency Working Group,A temporary group that develops guidance for federal agencies.,2021-02-01,United States,USA,US,0.92,Very High,Interim update reinstating Obama-era methodology with adjustments.,$51,US dollars,USD,51,51,51000000,2024-11-20,dollars per ton CO2e,tons of carbon dioxide equivalents,Obama-era methodology with adjustments,Social Cost of Carbon,0,
|
9 |
+
Trump Administration (Oct 2017),Trump Administration,The executive branch of the US Federal government under Donald Trump.,2017-10-01,United States,USA,US,0.92,Very High,Lowered SCC estimates focusing on domestic impacts with higher discount rates.,$3-$5,US dollars,USD,4,4,4000000,2024-11-20,dollars per ton CO2e,tons of carbon dioxide equivalents,Domestic impacts,Social Cost of Carbon,1,
|
10 |
+
Climate Leadership Council (Feb 2017),Climate Leadership Council,A coalition advocating for a carbon dividends plan.,2017-02-01,United States,USA,US,0.92,Very High,"Carbon dividends plan starting at $40/ton, increasing annually by 5% above inflation.",$40-$50,US dollars,USD,45,45,45000000,2024-11-20,dollars per ton CO2e,tons of carbon dioxide equivalents,Carbon dividends plan,Carbon Pricing,1,
|
11 |
+
Obama Administration (IWG Update) (Nov 2013),Obama Administration Interagency Working Group,A temporary group that develops guidance for federal agencies.,2013-11-01,United States,USA,US,0.92,Very High,Updated SCC values for regulatory impact analyses under federal guidelines.,$37,US dollars,USD,37,37,37000000,2024-11-20,dollars per ton CO2e,tons of carbon dioxide equivalents,Updated SCC methodology,Social Cost of Carbon,0,
|
12 |
+
UK Government Economic Service (2002-01-01),UK Government Economic Service,The professional body of economists in the UK Civil Service.,2002-01-01,United Kingdom,GBR,GB,0.88,Very High,Recommended illustrative SCC range for policy appraisal across government sectors.,Β£35-Β£140,British pounds,GBP,87.5,109.475,109475000,2024-11-20,pounds per ton CO2e,tons of carbon dioxide equivalents,Illustrative SCC range,Social Cost of Carbon,1,
|
13 |
+
Stern Review (Oct 2006),Stern Review,A landmark report on the economics of climate change.,2006-10-01,United Kingdom,GBR,GB,0.88,Very High,Early influential report advocating for strong climate action.,~$85,US dollars,USD,85,85,85000000,2024-11-20,dollars per ton CO2e,tons of carbon dioxide equivalents,Economic modeling,Social Cost of Carbon,0,
|
14 |
+
Canada Government (Aug 2023),Government of Canada,The federal government of Canada.,2023-08-01,Canada,CAN,CA,0.93,Very High,The Federal Carbon Price was increased to CAD$65 per tonne CO2e in 2023.,CAD$65,Canadian dollars,CAD,65,48.01,48010000,2024-11-20,dollars per ton CO2e,tons of carbon dioxide equivalents,Federal carbon pricing,Carbon Pricing,0,
|
15 |
+
Nordhaus DICE Model (2017),Yale University,Integrated assessment model of climate change and economics.,2017-01-01,United States,USA,US,0.92,Very High,Highly influential integrated assessment model for climate policy.,$31,US dollars,USD,31,31,31000000,2024-11-20,dollars per ton CO2e,tons of carbon dioxide equivalents,Integrated assessment modeling,Social Cost of Carbon,0,
|
16 |
+
RFF (2021),Resources for the Future,Independent research institution focusing on environmental and natural resource issues.,2021-01-01,United States,USA,US,0.92,Very High,Research and analysis on the social cost of carbon.,$51,US dollars,USD,51,51,51000000,2024-11-20,dollars per ton CO2e,tons of carbon dioxide equivalents,SCC modeling analysis,Social Cost of Carbon,0,
|
17 |
+
FUND Model (2019),University College London,A climate economy model.,2019-01-01,United Kingdom,GBR,GB,0.88,Very High,Climate economy model focused on policy evaluation.,$25-$60,US dollars,USD,42.5,42.5,42500000,2024-11-20,dollars per ton CO2e,tons of carbon dioxide equivalents,Climate economy modeling,Social Cost of Carbon,1,
|
18 |
+
PAGE Model (2019),Cambridge University,Policy Analysis model of climate damages.,2019-01-01,United Kingdom,GBR,GB,0.88,Very High,Policy Analysis model for Social Cost of Carbon.,$100-$200,US dollars,USD,150,150,150000000,2024-11-20,dollars per ton CO2e,tons of carbon dioxide equivalents,Policy Analysis Modeling,Social Cost of Carbon,1,
|
calculator-app/instructions.md
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# GHG Emissions Calculator: User Notes & Instructions
|
2 |
+
|
3 |
+
## Access & Installation
|
4 |
+
|
5 |
+
The purpose of this calculator and demo application is to allow the user to conduct monetizations of companies' quantitative greenhouse gas emissions data at various proposed social cost of carbon numbers. These social costs of carbon proposals have been gathered as a data file in the repository located under Data Sources. This repository can be accessed both from Github and Hugging Face as a demonstration space that allows usage. Alternatively, you may wish to clone this repository onto your local machine and run it locally. It uses Streamlit.
|
6 |
+
|
7 |
+
## Monetizing environmental data: use-cases and interest groups.
|
8 |
+
|
9 |
+
Various groups of stakeholders have highlighted the public interest in estimating the approximate cost of companies pollution activities in the form of various metrics. At the governmental and intergovernmental level, the best known of these is the social cost of carbon. The social cost of carbon has been suggested as a mechanism for approximating the cost of carbon emissions on the planets as a whole.
|
10 |
+
|
11 |
+
Beyond the policy context, those advocating for a practice known as impact accounting, have suggested that the cost of this particular environmental impact be integrated into a broader and further-reaching set of practices by which companies' environmental impacts, as well as their social impacts, would be incorporated into their financial reporting. In this practice, the cost of carbon is only one of the environmental impacts that would be thusly "monetized".
|
12 |
+
|
13 |
+
## Unit Standardisation
|
14 |
+
|
15 |
+
The practice of monetizing companies greenhouse gas emissions is nowhere near as simple as might be expected. Additionally, attempting to do so often entails following methodologies that are to a degree, inherently flawed. The motivation for the creation of this calculator, however, and the proposals to do roughly this, is that it's better to use an imperfect methodology than to use none at all.
|
16 |
+
|
17 |
+
The first comparability challenge is that the various proposals for estimating the societal cost of emissions are frequently limited to considering carbon dioxide emissions whereas companies greenhouse gas emissions reporting more commonly reports on their carbon dioxide equivalents, encompassing both their carbon dioxide emissions as well as other gasses which have been linked to pollution, some of which are typically far less prevalent in their emissions but have a higher global warming potential.
|
18 |
+
|
19 |
+
The result is that although the multiplier might be mismatched, the end approximation for the monetized emissions will actually be an understatement, because the multiplier is only monetizing a portion of the companies reported emissions. If a company reports its greenhouse gas emissions as carbon dioxide equivalents, and the multiplier is only the social cost of carbon, then the non carbon dioxide constituents of the CO2E number are not being "monetised." Depending on the constitution of a company's mix of greenhouse gas emissions, this would result in understatements to greater and lesser extents.
|
20 |
+
|
21 |
+
Another challenge in comparing greenhouse gas emissions between industries is that different units of measurements can be used, and the units of measurements used in emissions reporting and those attempts to set a social cost are usually not the same.
|
22 |
+
|
23 |
+
## MTCO2(E) vs TCO2(E)
|
24 |
+
|
25 |
+
The social cost of carbon numbers are typically proposed as prices per ton of carbon dioxide equivalents or carbon dioxide. But depending on the extent of their missions, companies typically report this number in their sustainability and ESG disclosures in higher units. The units which companies report in in their reporting literature are frequently chosen to best align with industry norms. In the case of oil and gas, the units are typically millions of tons of carbon dioxide equivalents but in some industries with far less emissions, such a large single unit would be nonsensical. To complicate matters further, different units are seen as well. But it suggested that tons of carbon dioxide equivalents and millions of tons provide two units that can cater for conversions from the wide range of intermediate units that are occasionally encountered. Therefore, this calculator provides only those two units.
|
26 |
+
|
27 |
+
## Conversion Values & Logic
|
28 |
+
|
29 |
+
In order to simplify the calculation of the monetizations, the calculator assumes that tons of carbon dioxide equivalents is the reporting unit.
|
30 |
+
|
31 |
+
In instances where the user is inputting a value expressed as the higher unit (millions of tonnes of CO 2 equivalents) a multiplication factor of 1 million is used in order to convert this value from tonnes into millions of tonnes.
|
32 |
+
|
33 |
+
An additional value is provided in the data CSV, although it's not used in the calculator. That value is USD conversion value MTCO2E. This is the conversion factor expressed already in millions. Therefore the conversion logic should be different.
|
34 |
+
|
35 |
+
## Currency Conversions & Geospecificity
|
36 |
+
|
37 |
+
Proposals for the social cost of carbon have been expressed over the course of time in different currencies. Additionally, different estimates have dealt with the question of geographical specificity in different ways. A more selective social cost of carbon would be stratified on a per country basis. But most proposals so far have provided the number as a single globally applicable figure, expressed in US dollars.
|
38 |
+
|
39 |
+
To enable Comparisons between Proposals expressed in different currencies all non US dollar proposals were converted to the US dollar at a specific date noted in the CSV. The accuracy of this dynamic value could be improved through integrating this calculator with financial exchange APIs.
|
40 |
+
|
41 |
+
## Range Handling
|
42 |
+
|
43 |
+
In some instances, the proposed social cost of carbon has not been expressed as one value, but rather as a range of values.
|
44 |
+
|
45 |
+
Again, and solely for the purpose of streamlining comparison in this demonstration app. In cases where this was the case, both the range values were noted and the average was used as the figure. In cases where an average was proposed in a currency other than the US dollar, the average was taken and then that average was converted to USD at the date noted in the data.
|
46 |
+
|
47 |
+
A Boolean value called is range was added to the data set in order to help analysts distinguish easily between those estimated social costs of carbon, denoted as a single figure, and those expressed as ranges. The logic is that one or positive means that it was a range and zero is not a range
|
48 |
+
|
49 |
+
## ISO Values
|
50 |
+
|
51 |
+
For the purpose of making this small data set comparable ISO values were added where possible in order to further analysis of this data set by policy analysts and other interested parties. The currency values were expressed in their 3 letter ISO codes. Similarly, the country of the proposing organization was noted and its ISO codes were also provided.
|
52 |
+
|
53 |
+
The country value here was chosen based upon the location of the headquarters of the organization. In the case of international organizations whose headquarters are in a specific country. This value might be slightly misleading, as it's reflective of a global worldview rather than the specific country in which the organization has its formal headquarters. But for the purpose of data conformity it was added nevertheless.
|
54 |
+
|
55 |
+
## HDI Values
|
56 |
+
|
57 |
+
An interesting policy question is the question of whether more affluent countries have expressed their proposed social cost of carbon differently than less affluent countries, who may be more adversely affected by emissions produced by wealthier countries.
|
58 |
+
|
59 |
+
In order to suggest that this data could be included in any analytical uses of this CSV the latest available Human Development Index value for each country was added.
|
60 |
+
|
61 |
+
In the case of the data points in the current grouping, the addition of this parameter doesn't add much to the analysis because the countries which have proposed this value are all in the very high tranche of the HDI index. Additionally, this dataset Is unlikely to ever be very sizable, given that formal proposals for social cost of carbon are not advanced that easily nor frequently. But it may be an interesting angle of exploration if more developing world countries attempt this proposal.
|
docs/additional-notes.md
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
## The Social Cost ... But Of What, Exactly!?
|
2 |
+
|
3 |
+
The idea of trying to integrate environmental data into financial reporting is anything but straightforward.
|
4 |
+
|
5 |
+
This is unfortunate, because the idea of doing this has important ramifications for public policy, financial policy, and the question of how our economic systems should be structured. It should be added: the idea of investigating what effect monetized emissions may have on companies profitability is not an attempt to be punitive. But rather to open the door to what this type of policy might look like in practice. If the purview of the analysis were widened to considering both companies environmental and social impacts, positive impacts could be added to move the analysis away from a framework that only estimates degrees of harm.
|
6 |
+
|
7 |
+
Although obvious, it's important to highlight the following, too:
|
8 |
+
|
9 |
+
Greenhouse gas emissions are often used for this purpose for a plurality of reasons, but chief among them is probably the fact that they are relatively widely available as a datapoint. To calculate what monetized environmental emissions would look like in practice, two things are necessary: Firstly the quantitative data about those emissions and secondly the multiplication factors to convert those to monetary units. To call the latter merely multipliers is also to greatly oversimplify what these are. In reality, to the extent that a simple number is ultimately proposed, the number is the result of a extensive modeling process underpinned by detailed scientific information.
|
10 |
+
|
11 |
+
The broad idea behind proposing a social cost of carbon at all is to fix a number on the extent to which companies emissions have effects that could be monetized. However, there are two large deficiencies in even this approach. The first is that while it might be the most prominent gas in companies emissions profiles, carbon dioxide is but one of several gasses they may be emitting in their overall GHG emissions basket that have been demonstrated scientifically to have damaging effects on the environment (express, numerically, through their GWP values). One approach arround this is to consider for calculation a social cost of greenhouse gasses or SC-GHG.
|
12 |
+
|
13 |
+
The second is the point made previously, that while companies greenhouse gas emissions, even if considered collectively, are relatively easy to document, monitor and report upon, together, they only consider one part of a company's environmental impacts. The Global Value Factors Database released by the International Foundation for Valuing Impacts l(IFVI) in 2024 considers a wide variety of environmental impacts, including in areas such as air pollution, waste management and land use displacement.
|
docs/app-notes.md
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Calculator App Notes
|
2 |
+
|
3 |
+
Simulating the monetization of greenhouse gas emissions is limited by the difficulties of working with two different yardsticks: the social cost of carbon, which only considers carbon dioxide emissions, and the quantitative reporting data from companies for greenhouse gas emissions (GHG), which almost always includes gases beyond carbon dioxide, expressed in carbon dioxide equivalents.
|
4 |
+
|
5 |
+
It has been suggested that organisations should propose a social cost of greenhouse gas emissions encompassing both carbon dioxide and other greenhouse gases with higher global warming potential (GWP) values But doing so would be challenging given the relative paucity of such estimates.
|
6 |
+
|
7 |
+
A further difficulty in this enterprise is that greenhouse gas emissions are reported by companies in several different units, owing to the vastly different emissions footprints seen across different industries. For example, the oil and gas industry reports emissions in millions of tons of carbon dioxide equivalents by convention. But such a large unit of measurement doesn't make sense for companies in different industries, like the technology sector, which might have vastly smaller emissions footprints.
|
8 |
+
|
9 |
+
When working with both of these data points, it's important to be cognizant of these differences. For example, the multiplication factor for converting what an oil and gas company may report as 1 MTCO2E Using the International Foundation for Valuing Impacts (IFVI) rate Of $236 per ton of CO2 equivalents is not 236, but rather 236,000,000. Needless to say, you're omitting this from calculations would result in massive errors.
|
{reference-material β docs}/data-dictionary.md
RENAMED
File without changes
|
{reference-material β docs}/glossary.md
RENAMED
File without changes
|
{reference-material β docs}/units-glossary.md
RENAMED
File without changes
|
requirements.txt
ADDED
File without changes
|