Skip to content

Commit d286c5b

Browse files
measrainseykhaeru
authored andcommittedMar 10, 2025
Raise error when a technology is assigned a reduction rate it does not have
1 parent a45fce4 commit d286c5b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
 

‎message_ix_models/tools/costs/decay.py

+21
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,27 @@ def get_technology_reduction_scenarios_data(
350350
cost_reduction_long, on=["message_technology", "reduction_rate"], how="left"
351351
).merge(adj_first_year, on="message_technology", how="left")
352352

353+
# filter for rows where cost_reduction is NaN and reduction rate is not "none"
354+
# these are instances where a technology has a reduction_rate that
355+
# does not have a cost_reduction value
356+
check_nan = df.query("cost_reduction.isnull() and reduction_rate != 'none'")[
357+
["message_technology", "scenario", "reduction_rate"]
358+
]
359+
360+
if not check_nan.empty:
361+
check_nan["print"] = (
362+
check_nan.message_technology
363+
+ " + "
364+
+ check_nan.scenario
365+
+ " + "
366+
+ check_nan.reduction_rate
367+
)
368+
369+
raise ValueError(
370+
f"The following technology + scenario + reduction rate combinations are missing data. Please check the reduction rate exists for the technology.\n\
371+
{check_nan.print.unique().tolist()}."
372+
)
373+
353374
# if reduction_rate is "none", then set cost_reduction to 0
354375
df["cost_reduction"] = np.where(df.reduction_rate == "none", 0, df.cost_reduction)
355376

0 commit comments

Comments
 (0)
Please sign in to comment.