diff --git a/scripts/build_transport_demand.py b/scripts/build_transport_demand.py index be8ad414..33c8faae 100644 --- a/scripts/build_transport_demand.py +++ b/scripts/build_transport_demand.py @@ -13,9 +13,7 @@ import logging import numpy as np import pandas as pd import xarray as xr - -from _helpers import configure_logging -from _helpers import generate_periodic_profiles +from _helpers import configure_logging, generate_periodic_profiles logger = logging.getLogger(__name__) @@ -137,8 +135,10 @@ def bev_availability_profile(fn, snapshots, nodes, options): ) if not avail[avail < 0].empty: - logger.warning("The BEV availability weekly profile has negative values which can " - "lead to infeasibility.") + logger.warning( + "The BEV availability weekly profile has negative values which can " + "lead to infeasibility." + ) return generate_periodic_profiles( dt_index=snapshots, diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index ba3f24c6..8bb9089b 100755 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -1324,7 +1324,7 @@ def add_storage_and_grids(n, costs): n, "H2 pipeline ", carriers=["DC", "gas pipeline"] ) - h2_pipes["p_nom"] = 0. + h2_pipes["p_nom"] = 0.0 if snakemake.input.get("custom_h2_pipelines"): fn = snakemake.input.custom_h2_pipelines @@ -1333,8 +1333,14 @@ def add_storage_and_grids(n, costs): h2_pipes = pd.concat([h2_pipes, wkn]) # drop duplicates according to buses (order can be different) and keep pipe with highest p_nom - h2_pipes['buses_sorted'] = h2_pipes.apply(lambda row: tuple(sorted([row['bus0'], row['bus1']])), axis=1) - h2_pipes = h2_pipes.sort_values('p_nom').drop_duplicates(subset=['buses_sorted'], keep='last').drop(columns = 'buses_sorted') + h2_pipes["buses_sorted"] = h2_pipes.apply( + lambda row: tuple(sorted([row["bus0"], row["bus1"]])), axis=1 + ) + h2_pipes = ( + h2_pipes.sort_values("p_nom") + .drop_duplicates(subset=["buses_sorted"], keep="last") + .drop(columns="buses_sorted") + ) # TODO Add efficiency losses n.madd(