diff --git a/message_ix_models/tools/costs/decay.py b/message_ix_models/tools/costs/decay.py index a28fcb0341..71b19f1403 100644 --- a/message_ix_models/tools/costs/decay.py +++ b/message_ix_models/tools/costs/decay.py @@ -314,8 +314,6 @@ def get_technology_reduction_scenarios_data( scenarios_reduction = _get_module_scenarios_reduction(module, energy_map, tech_map) cost_reduction = _get_module_cost_reduction(module, energy_map, tech_map) - cost_reduction.query("message_technology == 'bio_hpl'") - # get first year values adj_first_year = ( tech_map[["message_technology", "first_year_original"]] @@ -350,6 +348,29 @@ def get_technology_reduction_scenarios_data( cost_reduction_long, on=["message_technology", "reduction_rate"], how="left" ).merge(adj_first_year, on="message_technology", how="left") + # filter for rows where cost_reduction is NaN and reduction rate is not "none" + # these are instances where a technology has a reduction_rate that + # does not have a cost_reduction value + check_nan = df.query("cost_reduction.isnull() and reduction_rate != 'none'")[ + ["message_technology", "scenario", "reduction_rate"] + ] + + if not check_nan.empty: + check_nan["print"] = ( + check_nan.message_technology + + " + " + + check_nan.scenario + + " + " + + check_nan.reduction_rate + ) + + raise ValueError( + "The following technology + scenario + reduction rate combinations " + "are missing data. " + "Please check that the reduction rate exists for the technology.\n" + f"{check_nan.print.unique().tolist()}." + ) + # if reduction_rate is "none", then set cost_reduction to 0 df["cost_reduction"] = np.where(df.reduction_rate == "none", 0, df.cost_reduction)