Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion scripts/make_cumulative_costs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
8 changes: 7 additions & 1 deletion scripts/make_summary_perfect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Loading