From 774ba81315eea69ca6fdf3e80d1be0888c89748f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 17:54:41 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- Snakefile | 18 ++++++++++-------- scripts/build_base_energy_totals.py | 20 ++++++++++---------- scripts/build_industrial_database.py | 12 ++++++------ scripts/plot_network_eur.py | 2 +- scripts/plot_summary.py | 8 +++++--- scripts/prepare_sector_network.py | 8 +++++--- 6 files changed, 37 insertions(+), 31 deletions(-) diff --git a/Snakefile b/Snakefile index 3ad348ae..0fe3cf20 100644 --- a/Snakefile +++ b/Snakefile @@ -73,7 +73,7 @@ rule prepare_sector_networks: RDIR + "/prenetworks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{sopts}_{planning_horizons}_{discountrate}_{demand}.nc", **config["scenario"], - **config["costs"] + **config["costs"], ), @@ -84,7 +84,7 @@ rule override_res_all_nets: + "/prenetworks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{sopts}_{planning_horizons}_{discountrate}_{demand}_presec.nc", **config["scenario"], **config["costs"], - **config["export"] + **config["export"], ), @@ -95,7 +95,7 @@ rule solve_all_networks: + "/postnetworks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{sopts}_{planning_horizons}_{discountrate}_{demand}_{h2export}export.nc", **config["scenario"], **config["costs"], - **config["export"] + **config["export"], ), @@ -161,9 +161,11 @@ rule prepare_sector_network: shapes_path=pypsaearth( "resources/bus_regions/regions_onshore_elec_s{simpl}_{clusters}.geojson" ), - pipelines="resources/custom_data/pipelines.csv" - if config["custom_data"]["gas_network"] - else "resources/gas_networks/gas_network_elec_s{simpl}_{clusters}.csv", + pipelines=( + "resources/custom_data/pipelines.csv" + if config["custom_data"]["gas_network"] + else "resources/gas_networks/gas_network_elec_s{simpl}_{clusters}.csv" + ), output: RDIR + "/prenetworks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{sopts}_{planning_horizons}_{discountrate}_{demand}.nc", @@ -480,7 +482,7 @@ rule make_summary: + "/postnetworks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{sopts}_{planning_horizons}_{discountrate}_{demand}_{h2export}export.nc", **config["scenario"], **config["costs"], - **config["export"] + **config["export"], ), costs=CDIR + "costs_{}.csv".format(config["scenario"]["planning_horizons"][0]), plots=expand( @@ -488,7 +490,7 @@ rule make_summary: + "/maps/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{sopts}-costs-all_{planning_horizons}_{discountrate}_{demand}_{h2export}export.pdf", **config["scenario"], **config["costs"], - **config["export"] + **config["export"], ), output: nodal_costs=SDIR + "/csvs/nodal_costs.csv", diff --git a/scripts/build_base_energy_totals.py b/scripts/build_base_energy_totals.py index 731f75ba..2d1b9c8f 100644 --- a/scripts/build_base_energy_totals.py +++ b/scripts/build_base_energy_totals.py @@ -76,9 +76,9 @@ def calc_sector(sector): energy_totals_base.at[country, "total domestic aviation"] = np.NaN elif sector == "navigation": - energy_totals_base.at[ - country, "total international navigation" - ] = np.NaN + energy_totals_base.at[country, "total international navigation"] = ( + np.NaN + ) energy_totals_base.at[country, "total domestic navigation"] = np.NaN _logger.warning("No data for " + country + " in the sector " + sector + ".") @@ -229,13 +229,13 @@ def calc_sector(sector): ) elif sector == "navigation": - energy_totals_base.at[ - country, "total international navigation" - ] = round( - df_sector[ - df_sector.Transaction == "International marine bunkers" - ].Quantity_TWh.sum(), - 4, + energy_totals_base.at[country, "total international navigation"] = ( + round( + df_sector[ + df_sector.Transaction == "International marine bunkers" + ].Quantity_TWh.sum(), + 4, + ) ) energy_totals_base.at[country, "total domestic navigation"] = round( df_sector[ diff --git a/scripts/build_industrial_database.py b/scripts/build_industrial_database.py index f04453ef..9da3ef86 100644 --- a/scripts/build_industrial_database.py +++ b/scripts/build_industrial_database.py @@ -276,9 +276,9 @@ def create_cement_db(): ) avg_c_cap = df_cement.groupby(df_cement.country)["capacity"].mean() df_cement["capacity"] = df_cement.apply( - lambda x: avg_c_cap[x["country"]] - if math.isnan(x["capacity"]) - else x["capacity"], + lambda x: ( + avg_c_cap[x["country"]] if math.isnan(x["capacity"]) else x["capacity"] + ), axis=1, ) @@ -454,9 +454,9 @@ def create_paper_df(): na_index df_paper["capacity"] = df_paper.apply( - lambda x: avg_c_cap[x["country"]] - if math.isnan(x["capacity"]) - else x["capacity"], + lambda x: ( + avg_c_cap[x["country"]] if math.isnan(x["capacity"]) else x["capacity"] + ), axis=1, ) diff --git a/scripts/plot_network_eur.py b/scripts/plot_network_eur.py index 7221b594..c7b0001c 100644 --- a/scripts/plot_network_eur.py +++ b/scripts/plot_network_eur.py @@ -743,7 +743,7 @@ def plot_series(network, carrier="AC", name="test"): "plot_network", simpl="", clusters=4, - planning_horizons=2030 + planning_horizons=2030, # lv=1.5, # opts='', # sector_opts='Co2L0-168H-T-H-B-I-solar+p3-dist1', diff --git a/scripts/plot_summary.py b/scripts/plot_summary.py index 228dbbb8..5921d693 100644 --- a/scripts/plot_summary.py +++ b/scripts/plot_summary.py @@ -269,9 +269,11 @@ def plot_balances(): # remove trailing link ports df.index = [ - i[:-1] - if ((i != "co2") and (i != "H2") and (i[-1:] in ["0", "1", "2", "3"])) - else i + ( + i[:-1] + if ((i != "co2") and (i != "H2") and (i[-1:] in ["0", "1", "2", "3"])) + else i + ) for i in df.index ] diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 36f6ae3f..708b97f8 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -1279,9 +1279,11 @@ def add_industry(n, costs): nodes, suffix=" low-temperature heat for industry", bus=[ - node + " urban central heat" - if node + " urban central heat" in n.buses.index - else node + " services urban decentral heat" + ( + node + " urban central heat" + if node + " urban central heat" in n.buses.index + else node + " services urban decentral heat" + ) for node in nodes ], carrier="low-temperature heat for industry",