From a2012d89373b9a6f2e8911f84e52299b1d4cae76 Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Mon, 20 May 2024 15:49:40 +0200 Subject: [PATCH] pre-commit formatting [no ci] --- data/agg_p_nom_minmax.csv | 2 +- scripts/build_powerplants.py | 6 +++++- scripts/prepare_sector_network.py | 4 +++- scripts/solve_network.py | 25 ++++++++++++++++++------- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/data/agg_p_nom_minmax.csv b/data/agg_p_nom_minmax.csv index 974b13a2..a3a10dc2 100644 --- a/data/agg_p_nom_minmax.csv +++ b/data/agg_p_nom_minmax.csv @@ -30,4 +30,4 @@ DK,solar,,,,,, BE,onwind,,,,,, BE,offwind-ac,,,,,, BE,offwind-dc,,,,,, -BE,solar,,,,,, \ No newline at end of file +BE,solar,,,,,, diff --git a/scripts/build_powerplants.py b/scripts/build_powerplants.py index c4bf10bc..4e2bb88f 100755 --- a/scripts/build_powerplants.py +++ b/scripts/build_powerplants.py @@ -148,7 +148,11 @@ def add_everywhere_powerplants(ppl, substations, everywhere_powerplants): def replace_natural_gas_technology(df): - mapping = {"Steam Turbine": "CCGT", "Combustion Engine": "OCGT", "Not Found": "CCGT"} + mapping = { + "Steam Turbine": "CCGT", + "Combustion Engine": "OCGT", + "Not Found": "CCGT", + } tech = df.Technology.replace(mapping).fillna("CCGT") return df.Technology.mask(df.Fueltype == "Natural Gas", tech) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 1eb3783b..fee927a2 100755 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -973,7 +973,9 @@ def insert_electricity_distribution_grid(n, costs): .get("electricity distribution grid", {}) .get("efficiency_static") ): - logger.info(f"Deducting distribution losses from electricity demand: {100*(1-efficiency)}%") + logger.info( + f"Deducting distribution losses from electricity demand: {100*(1-efficiency)}%" + ) n.loads_t.p_set.loc[:, n.loads.carrier == "electricity"] *= efficiency # this catches regular electricity load and "industry electricity" and diff --git a/scripts/solve_network.py b/scripts/solve_network.py index 689d4de5..a0b28b90 100644 --- a/scripts/solve_network.py +++ b/scripts/solve_network.py @@ -531,28 +531,39 @@ def add_CCL_constraints(n, config): agg_p_nom_limits: data/agg_p_nom_minmax.csv """ agg_p_nom_minmax = pd.read_csv( - config["solving"]["agg_p_nom_limits"]["file"], - index_col=[0, 1], header=[0, 1] + config["solving"]["agg_p_nom_limits"]["file"], index_col=[0, 1], header=[0, 1] )[snakemake.wildcards.planning_horizons] logger.info("Adding generation capacity constraints per carrier and country") p_nom = n.model["Generator-p_nom"] gens = n.generators.query("p_nom_extendable").rename_axis(index="Generator-ext") if config["solving"]["agg_p_nom_limits"]["agg_offwind"]: - rename_offwind = {"offwind-ac": "offwind-all", "offwind-dc": "offwind-all", "offwind": "offwind-all"} + rename_offwind = { + "offwind-ac": "offwind-all", + "offwind-dc": "offwind-all", + "offwind": "offwind-all", + } gens = gens.replace(rename_offwind) grouper = pd.concat([gens.bus.map(n.buses.country), gens.carrier], axis=1) lhs = p_nom.groupby(grouper).sum().rename(bus="country") if config["solving"]["agg_p_nom_limits"]["include_existing"]: - gens_cst = n.generators.query("~p_nom_extendable").rename_axis(index="Generator-cst") + gens_cst = n.generators.query("~p_nom_extendable").rename_axis( + index="Generator-cst" + ) gens_cst = gens_cst[ - (gens_cst["build_year"] + gens_cst["lifetime"]) >= int(snakemake.wildcards.planning_horizons)] + (gens_cst["build_year"] + gens_cst["lifetime"]) + >= int(snakemake.wildcards.planning_horizons) + ] if config["solving"]["agg_p_nom_limits"]["agg_offwind"]: gens_cst = gens_cst.replace(rename_offwind) rhs_cst = ( - pd.concat([gens_cst.bus.map(n.buses.country), gens_cst[["carrier", "p_nom"]]], axis=1) - .groupby(["bus", "carrier"]).sum() + pd.concat( + [gens_cst.bus.map(n.buses.country), gens_cst[["carrier", "p_nom"]]], + axis=1, + ) + .groupby(["bus", "carrier"]) + .sum() ) rhs_cst.index = rhs_cst.index.rename({"bus": "country"}) rhs_min = agg_p_nom_minmax["min"].dropna()