Skip to content

Commit

Permalink
ITR_UI: Cleanup use of term 'scenario' instead of 'benchmark'
Browse files Browse the repository at this point in the history
The change only touches GUI, where the term 'scenario' was used
for Emissions Intensity benchmark.

This could confuse users

Signed-off-by: Kirill Marinushkin <[email protected]>
  • Loading branch information
kmarinushkin committed Oct 7, 2022
1 parent 537a21d commit ff81d5e
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions examples/ITR_UI.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,24 @@
EI_bm: BaseProviderIntensityBenchmark = None # Emissions Intensity benchmarks, created during `recalculate_individual_itr`

# load default intensity benchmarks
def recalculate_individual_itr(scenario):
def recalculate_individual_itr(eibm):
'''
Reload Emissions Intensity benchmark from a selected file
:param eibm: Emissions Intensity benchmark identifier
'''
global temperature_score, EI_bm

if scenario == 'OECM_PC':
if eibm == 'OECM_PC':
benchmark_file = benchmark_EI_OECM_PC_file
elif scenario == 'OECM_S3':
elif eibm == 'OECM_S3':
benchmark_file = benchmark_EI_OECM_S3_file
elif scenario == 'TPI_2_degrees':
elif eibm == 'TPI_2_degrees':
benchmark_file = benchmark_EI_TPI_file
elif scenario == 'TPI_15_degrees':
elif eibm == 'TPI_15_degrees':
benchmark_file = benchmark_EI_TPI_15_file
elif scenario == 'OECM':
elif eibm == 'OECM':
benchmark_file = benchmark_EI_OECM_file
logger.info('OECM scenario is for backward compatibility only. Use OECM_PC instead.')
logger.info('OECM benchmark is for backward compatibility only. Use OECM_PC instead.')
else:
benchmark_file = benchmark_EI_TPI_below_2_file
# load intensity benchmarks
Expand Down Expand Up @@ -205,7 +209,7 @@ def dequantify_plotly(px_func, df, **kwargs):
[
dbc.Button("\N{books}", id="hover-target3", color="link", n_clicks=0),
dbc.Popover(dbc.PopoverBody(
"Scope of sectors could be different for different emission scenario.\nScope of sectors covered by the tool is constantly growing."),
"Scope of sectors could be different for different emission benchmark.\nScope of sectors covered by the tool is constantly growing."),
id="hover3", target="hover-target3", trigger="hover"),
], width=2,
),
Expand All @@ -228,7 +232,7 @@ def dequantify_plotly(px_func, df, **kwargs):
[
dbc.Button("\N{books}", id="hover-target4", color="link", n_clicks=0),
dbc.Popover(dbc.PopoverBody(
"Scope of countries could be different for different emission scenario"),
"Scope of countries could be different for different emission benchmark"),
id="hover4", target="hover-target4", trigger="hover"),
], width=2,
),
Expand All @@ -255,21 +259,21 @@ def dequantify_plotly(px_func, df, **kwargs):
dbc.Row( # Select Benchmark
[
dbc.Col(
dbc.Label("\N{bar chart} Select climate scenario "),
dbc.Label("\N{bar chart} Select Emissions Intensity benchmark "),
width=9,
),
dbc.Col(
[
dbc.Button("\N{books}", id="hover-target5", color="link", n_clicks=0),
dbc.Popover(dbc.PopoverBody(
"Climate scenario describes emission intensities projection for different regions and sectors"),
"This benchmark describes emission intensities projection for different regions and sectors"),
id="hover5", target="hover-target5", trigger="hover"),
], width=2,
),
],
align="center",
),
dcc.Dropdown(id="scenario-dropdown",
dcc.Dropdown(id="eibm-dropdown",
options=[ # 16.05.2022: make this dynamic
{'label': 'OECM (Prod-Centric) 1.5 degC', 'value': 'OECM_PC'},
{'label': 'OECM (Scope 3) 1.5 degC', 'value': 'OECM_S3'},
Expand All @@ -280,7 +284,7 @@ def dequantify_plotly(px_func, df, **kwargs):
],
value='OECM_PC',
clearable=False,
placeholder="Select emission scenario"),
placeholder="Select Emissions Intensity benchmark"),
html.Div(id='hidden-div', style={'display': 'none'}),
html.Hr(), # small space from the top
dbc.Row( # Mean / Median projection
Expand Down Expand Up @@ -409,8 +413,8 @@ def dequantify_plotly(px_func, df, **kwargs):
dbc.Card(
dbc.CardBody(
[
html.H5("Scenario assumptions", className="macro-filters"),
html.P("Here you could adjust basic assumptions of calculations",
html.H5("Benchmarks", className="macro-filters"),
html.P("Here you could adjust benchmarks of calculations",
className="text-black-50"),
macro,
]
Expand Down Expand Up @@ -559,15 +563,15 @@ def dequantify_plotly(px_func, df, **kwargs):
Input("temp-score", "value"),
Input("sector-dropdown", "value"),
Input("region-dropdown", "value"),
Input("scenario-dropdown", "value"),
Input("eibm-dropdown", "value"),
Input('projection-method', 'value'),
Input("scenarios-cutting", "value"), # winzorization slide
],
)
def update_graph(
te_sc,
sec, reg,
scenario,
eibm,
proj_meth,
winz,
):
Expand All @@ -586,8 +590,8 @@ def update_graph(
template_company_data.projection_controls.UPPER_PERCENTILE = winz[1] / 100
template_company_data = TemplateProviderCompany(excel_path=company_data_path)

amended_portfolio_global = recalculate_individual_itr(
scenario) # we need to recalculate temperature score as we changed th
# we need to recalculate temperature score as we changed benchmark
amended_portfolio_global = recalculate_individual_itr(eibm)

temp_score_mask = (amended_portfolio_global.temperature_score >= Q_(te_sc[0], 'delta_degC')) & (
amended_portfolio_global.temperature_score <= Q_(te_sc[1], 'delta_degC'))
Expand Down Expand Up @@ -779,20 +783,20 @@ def download_xlsx(n_clicks):
],
[
Input('reset-filters-but', 'n_clicks'),
Input("scenario-dropdown", "value")
Input("eibm-dropdown", "value")
]
)

def reset_filters(n_clicks_reset, scenario):
def reset_filters(n_clicks_reset, eibm):
changed_id = [p['prop_id'] for p in dash.callback_context.triggered][0] # to catch which widgets were pressed
if n_clicks_reset is None and 'scenario-dropdown' not in changed_id:
if n_clicks_reset is None and 'eibm-dropdown' not in changed_id:
raise PreventUpdate

ProjectionControls.TREND_CALC_METHOD=staticmethod(pd.DataFrame.median)
ProjectionControls.LOWER_PERCENTILE = 0.1
ProjectionControls.UPPER_PERCENTILE = 0.9
template_company_data = TemplateProviderCompany(excel_path=company_data_path)
amended_portfolio_global = recalculate_individual_itr(scenario)
amended_portfolio_global = recalculate_individual_itr(eibm)
initial_portfolio = amended_portfolio_global

return ( # if button is clicked, reset filters
Expand Down

0 comments on commit ff81d5e

Please sign in to comment.