Skip to content

Commit f2e7623

Browse files
Actually push new sector handling functionality into tool source code.
See #157 for long-term fix. Signed-off-by: MichaelTiemann <[email protected]> Signed-off-by: Michael Tiemann <[email protected]>
1 parent aac042d commit f2e7623

9 files changed

+1352
-1337
lines changed

ITR/configs.py

+18-4
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,36 @@ class ColumnsConfig:
8484

8585

8686
class SectorsConfig:
87+
POWER_UTILITY = "Electricity Utilities"
88+
GAS_UTILITY = "Gas Utilities"
89+
UTILITY = "Utilities"
8790
STEEL = "Steel"
88-
ELECTRICITY = "Electricity Utilities"
91+
ALUMINUM = "Aluminum"
92+
OIL_AND_GAS = "Oil & Gas"
93+
AUTOMOBILE = "Autos"
94+
TRUCKING = "Trucking"
95+
CEMENT = "Cement"
96+
BUILDINGS = "Buildings"
97+
TEXTILES = "Textiles"
98+
CHEMICALS = "Chemicals"
8999
INFORMATION_TECHNOLOGY = "Information Technology"
90100
INDUSTRIALS = "Industrials"
91101
FINANCIALS = "Financials"
92102
HEALTH_CARE = "Health Care"
93-
AUTOMOBILE = "Autos"
94-
OIL_AND_GAS = "Oil & Gas"
95103

96104
@classmethod
97105
def get_configured_sectors(cls) -> List[str]:
98106
"""
99107
Get a list of sectors configured in the tool.
100108
:return: A list of sectors string values
101109
"""
102-
return [SectorsConfig.STEEL, SectorsConfig.ELECTRICITY, SectorsConfig.AUTOMOBILE, SectorsConfig.OIL_AND_GAS]
110+
return [SectorsConfig.POWER_UTILITY, SectorsConfig.GAS_UTILITY, SectorsConfig.UTILITY,
111+
SectorsConfig.STEEL, SectorsConfig.ALUMINUM,
112+
SectorsConfig.OIL_AND_GAS,
113+
SectorsConfig.AUTOMOBILE, SectorsConfig.TRUCKING,
114+
SectorsConfig.CEMENT, SectorsConfig.BUILDINGS,
115+
SectorsConfig.TEXTILES, SectorsConfig.CHEMICALS,
116+
]
103117

104118

105119
class VariablesConfig:

ITR/data/excel.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222

2323

2424
# Excel spreadsheets don't have units elaborated, so we translate sectors to units
25-
sector_to_production_metric = {'Electricity Utilities': 'GJ', 'Steel': 'Fe_ton', 'Oil & Gas': 'boe', 'Autos': 'passenger km'}
26-
sector_to_intensity_metric = {'Electricity Utilities': 't CO2/MWh', 'Steel': 't CO2/Fe_ton', 'Oil & Gas': 'kg CO2/boe', 'Autos': 'g CO2/(passenger km)'}
25+
sector_to_production_metric = {'Electricity Utilities': 'GJ', 'Steel': 'Fe_ton', 'Oil & Gas': 'boe', 'Autos': 'pkm'}
26+
sector_to_intensity_metric = {'Electricity Utilities': 't CO2/MWh', 'Steel': 't CO2/Fe_ton', 'Oil & Gas': 'kg CO2/boe', 'Autos': 'g CO2/pkm'}
2727

2828
# TODO: Force validation for excel benchmarks
2929

ITR/interfaces.py

+20-8
Original file line numberDiff line numberDiff line change
@@ -492,15 +492,27 @@ def _fixup_year_value_list(self, ListType, u_list, metric, inferred_metric):
492492
return r_list
493493

494494
def _sector_to_production_units(self, sector, region="Global"):
495+
sector_unit_dict = {
496+
'Electricity Utilities': { 'North America':'MWh', 'Global': 'GJ' },
497+
'Gas Utilities': { 'Global': 'PJ' },
498+
'Utilities': { 'Global': 'PJ' },
499+
'Steel': { 'Global': 't Steel' },
500+
'Aluminum': { 'Global': 't Aluminum' },
501+
'Oil & Gas': { 'Global': 'mmboe' },
502+
'Autos': { 'Global': 'pkm' },
503+
'Trucking': { 'Global': 'tkm' },
504+
'Cement': { 'Global': 't Cement' },
505+
'Buildings': { 'Global': 'billion m**2' }, # Should it be 'built m**2' ?
506+
'Textiles': { 'Global': 'billion USD' },
507+
'Chemicals': { 'Global': 'billion USD' },
508+
}
495509
units = None
496-
if sector == 'Electricity Utilities':
497-
units = 'MWh' if region == 'North America' else 'GJ'
498-
elif sector == 'Steel':
499-
units = 'Fe_ton'
500-
elif sector == 'Oil & Gas':
501-
units = 'mmboe'
502-
elif sector == 'Autos':
503-
units = '(passenger km)'
510+
if sector_unit_dict.get(sector):
511+
region_unit_dict = sector_unit_dict[sector]
512+
if region_unit_dict.get(region):
513+
units = region_unit_dict[region]
514+
else:
515+
units = region_unit_dict['Global']
504516
else:
505517
raise ValueError(f"No source of production metrics for {self.company_name}")
506518
return units

examples/ITR_UI.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@
9494

9595

9696
# Emission intensities
97-
benchmark_EI_OECM_file = "benchmark_EI_OECM.json"
9897
benchmark_EI_OECM_PC_file = "benchmark_EI_OECM_PC.json"
9998
benchmark_EI_OECM_S3_file = "benchmark_EI_OECM_S3.json"
99+
benchmark_EI_OECM_file = "benchmark_EI_OECM.json" # Deprecated!
100100
benchmark_EI_TPI_15_file = "benchmark_EI_TPI_1_5_degrees.json"
101101
benchmark_EI_TPI_file = "benchmark_EI_TPI_2_degrees.json"
102102
benchmark_EI_TPI_below_2_file = "benchmark_EI_TPI_below_2_degrees.json"
@@ -114,16 +114,17 @@
114114

115115
# load default intensity benchmarks
116116
def recalculate_individual_itr(scenario):
117-
if scenario == 'OECM':
118-
benchmark_file = benchmark_EI_OECM_file
119-
elif scenario == 'OECM_PC':
117+
if scenario == 'OECM_PC':
120118
benchmark_file = benchmark_EI_OECM_PC_file
121119
elif scenario == 'OECM_S3':
122120
benchmark_file = benchmark_EI_OECM_S3_file
123121
elif scenario == 'TPI_2_degrees':
124122
benchmark_file = benchmark_EI_TPI_file
125123
elif scenario == 'TPI_15_degrees':
126124
benchmark_file = benchmark_EI_TPI_15_file
125+
elif scenario == 'OECM':
126+
benchmark_file = benchmark_EI_OECM_file
127+
logger.info('OECM scenario is for backward compatibility only. Use OECM_PC instead.')
127128
else:
128129
benchmark_file = benchmark_EI_TPI_below_2_file
129130
# load intensity benchmarks
@@ -136,7 +137,7 @@ def recalculate_individual_itr(scenario):
136137
return df
137138

138139

139-
initial_portfolio = recalculate_individual_itr('OECM')
140+
initial_portfolio = recalculate_individual_itr('OECM_PC')
140141
amended_portfolio_global = initial_portfolio.copy()
141142
filt_df = initial_portfolio.copy()
142143

@@ -279,14 +280,14 @@ def dequantify_plotly(px_func, df, **kwargs):
279280
),
280281
dcc.Dropdown(id="scenario-dropdown",
281282
options=[ # 16.05.2022: make this dynamic
282-
{'label': 'OECM 1.5 degrees', 'value': 'OECM'},
283283
{'label': 'OECM (Prod-Centric) 1.5 degC', 'value': 'OECM_PC'},
284284
{'label': 'OECM (Scope 3) 1.5 degC', 'value': 'OECM_S3'},
285+
{'label': 'OECM (Deprecated) 1.5 degrees', 'value': 'OECM'},
285286
{'label': 'TPI 1.5 degrees', 'value': 'TPI_15_degrees'},
286287
{'label': 'TPI 2 degrees', 'value': 'TPI_2_degrees'},
287288
{'label': 'TPI below 2 degrees', 'value': 'TPI_below_2_degrees'}
288289
],
289-
value='OECM',
290+
value='OECM_PC',
290291
clearable=False,
291292
placeholder="Select emission scenario"),
292293
html.Div(id='hidden-div', style={'display': 'none'}),
72.7 KB
Binary file not shown.
76.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)