diff --git a/scripts/make_cumulative_costs.py b/scripts/make_cumulative_costs.py index 2ad00c29f7..223787f88d 100644 --- a/scripts/make_cumulative_costs.py +++ b/scripts/make_cumulative_costs.py @@ -10,6 +10,12 @@ import numpy as np import pandas as pd +try: + from numpy import trapezoid +except ImportError: + # before numpy 2.0 + from numpy import trapz as trapezoid + from scripts._helpers import configure_logging, set_scenario_config idx = pd.IndexSlice @@ -34,7 +40,7 @@ def calculate_cumulative_cost(costs, planning_horizons): for cluster in cumulative_cost.index.get_level_values(level=0).unique(): for sector_opts in cumulative_cost.index.get_level_values(level=1).unique(): cumulative_cost.loc[(cluster, sector_opts, "cumulative cost"), r] = ( - np.trapz( + trapezoid( cumulative_cost.loc[ idx[cluster, sector_opts, planning_horizons], r ].values, diff --git a/scripts/make_summary_perfect.py b/scripts/make_summary_perfect.py index dc83e782da..d8b4e4c6ba 100644 --- a/scripts/make_summary_perfect.py +++ b/scripts/make_summary_perfect.py @@ -13,6 +13,12 @@ from pypsa.descriptors import get_active_assets from six import iteritems +try: + from numpy import trapezoid +except ImportError: + # before numpy 2.0 + from numpy import trapz as trapezoid + from scripts._helpers import load_costs, set_scenario_config from scripts.make_summary import ( assign_carriers, @@ -140,7 +146,7 @@ def calculate_cumulative_cost(): for cluster in cumulative_cost.index.get_level_values(level=0).unique(): for sector_opts in cumulative_cost.index.get_level_values(level=1).unique(): cumulative_cost.loc[(cluster, sector_opts, "cumulative cost"), r] = ( - np.trapz( + trapezoid( cumulative_cost.loc[ idx[cluster, sector_opts, planning_horizons], r ].values,