[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2024-02-10 16:22:36 +00:00
parent 6de08bd523
commit e838b63ded
9 changed files with 67 additions and 44 deletions

View File

@ -20,7 +20,7 @@ if config["enable"].get("prepare_links_p_nom", False):
rule build_electricity_demand: rule build_electricity_demand:
params: params:
snapshots={k: config["snapshots"][k] for k in ["start", "end", "inclusive"]}, # TODO: use config provider snapshots={k: config["snapshots"][k] for k in ["start", "end", "inclusive"]}, # TODO: use config provider
countries=config_provider("countries"), countries=config_provider("countries"),
load=config_provider("load"), load=config_provider("load"),
input: input:
@ -62,7 +62,7 @@ rule build_powerplants:
rule base_network: rule base_network:
params: params:
countries=config_provider("countries"), countries=config_provider("countries"),
snapshots={k: config["snapshots"][k] for k in ["start", "end", "inclusive"]}, # TODO: use config provider snapshots={k: config["snapshots"][k] for k in ["start", "end", "inclusive"]}, # TODO: use config provider
lines=config_provider("lines"), lines=config_provider("lines"),
links=config_provider("links"), links=config_provider("links"),
transformers=config_provider("transformers"), transformers=config_provider("transformers"),
@ -145,7 +145,7 @@ if config["enable"].get("build_cutout", False):
rule build_cutout: rule build_cutout:
params: params:
snapshots={k: config["snapshots"][k] for k in ["start", "end", "inclusive"]}, # TODO: use config provider snapshots={k: config["snapshots"][k] for k in ["start", "end", "inclusive"]}, # TODO: use config provider
cutouts=config_provider("atlite", "cutouts"), cutouts=config_provider("atlite", "cutouts"),
input: input:
regions_onshore=resources("regions_onshore.geojson"), regions_onshore=resources("regions_onshore.geojson"),
@ -259,7 +259,7 @@ else:
rule build_renewable_profiles: rule build_renewable_profiles:
params: params:
snapshots={k: config["snapshots"][k] for k in ["start", "end", "inclusive"]}, # TODO: use config provider snapshots={k: config["snapshots"][k] for k in ["start", "end", "inclusive"]}, # TODO: use config provider
renewable=config_provider("renewable"), renewable=config_provider("renewable"),
input: input:
**opt, **opt,
@ -401,18 +401,22 @@ rule add_electricity:
if str(fn).startswith("data/") if str(fn).startswith("data/")
}, },
base_network=resources("networks/base.nc"), base_network=resources("networks/base.nc"),
line_rating=resources("networks/line_rating.nc") line_rating=(
if config["lines"]["dynamic_line_rating"]["activate"] resources("networks/line_rating.nc")
else resources("networks/base.nc"), if config["lines"]["dynamic_line_rating"]["activate"]
else resources("networks/base.nc")
),
tech_costs=COSTS, tech_costs=COSTS,
regions=resources("regions_onshore.geojson"), regions=resources("regions_onshore.geojson"),
powerplants=resources("powerplants.csv"), powerplants=resources("powerplants.csv"),
hydro_capacities=ancient("data/bundle/hydro_capacities.csv"), hydro_capacities=ancient("data/bundle/hydro_capacities.csv"),
geth_hydro_capacities="data/geth2015_hydro_capacities.csv", geth_hydro_capacities="data/geth2015_hydro_capacities.csv",
unit_commitment="data/unit_commitment.csv", unit_commitment="data/unit_commitment.csv",
fuel_price=resources("monthly_fuel_price.csv") fuel_price=(
if config["conventional"]["dynamic_fuel_price"] resources("monthly_fuel_price.csv")
else [], if config["conventional"]["dynamic_fuel_price"]
else []
),
load=resources("load.csv"), load=resources("load.csv"),
nuts3_shapes=resources("nuts3_shapes.geojson"), nuts3_shapes=resources("nuts3_shapes.geojson"),
ua_md_gdp="data/GDP_PPP_30arcsec_v3_mapped_default.csv", ua_md_gdp="data/GDP_PPP_30arcsec_v3_mapped_default.csv",
@ -540,7 +544,8 @@ rule prepare_network:
snapshots={ snapshots={
"resolution": config["snapshots"].get("resolution", False), "resolution": config["snapshots"].get("resolution", False),
"segmentation": config["snapshots"].get("segmentation", False), "segmentation": config["snapshots"].get("segmentation", False),
}, # TODO: use config provider },
# TODO: use config provider
links=config_provider("links"), links=config_provider("links"),
lines=config_provider("lines"), lines=config_provider("lines"),
co2base=config_provider("electricity", "co2base"), co2base=config_provider("electricity", "co2base"),

View File

@ -94,7 +94,9 @@ rule build_gas_input_locations:
regions_offshore=resources("regions_offshore_elec_s{simpl}_{clusters}.geojson"), regions_offshore=resources("regions_offshore_elec_s{simpl}_{clusters}.geojson"),
output: output:
gas_input_nodes=resources("gas_input_locations_s{simpl}_{clusters}.geojson"), gas_input_nodes=resources("gas_input_locations_s{simpl}_{clusters}.geojson"),
gas_input_nodes_simplified=resources("gas_input_locations_s{simpl}_{clusters}_simplified.csv"), gas_input_nodes_simplified=resources(
"gas_input_locations_s{simpl}_{clusters}_simplified.csv"
),
resources: resources:
mem_mb=2000, mem_mb=2000,
log: log:
@ -124,7 +126,7 @@ rule cluster_gas_network:
rule build_daily_heat_demand: rule build_daily_heat_demand:
params: params:
snapshots={k: config["snapshots"][k] for k in ["start", "end", "inclusive"]}, # TODO: use config_provider snapshots={k: config["snapshots"][k] for k in ["start", "end", "inclusive"]}, # TODO: use config_provider
input: input:
pop_layout=resources("pop_layout_{scope}.nc"), pop_layout=resources("pop_layout_{scope}.nc"),
regions_onshore=resources("regions_onshore_elec_s{simpl}_{clusters}.geojson"), regions_onshore=resources("regions_onshore_elec_s{simpl}_{clusters}.geojson"),
@ -167,7 +169,7 @@ rule build_hourly_heat_demand:
rule build_temperature_profiles: rule build_temperature_profiles:
params: params:
snapshots={k: config["snapshots"][k] for k in ["start", "end", "inclusive"]}, # TODO: use config_provider snapshots={k: config["snapshots"][k] for k in ["start", "end", "inclusive"]}, # TODO: use config_provider
input: input:
pop_layout=resources("pop_layout_{scope}.nc"), pop_layout=resources("pop_layout_{scope}.nc"),
regions_onshore=resources("regions_onshore_elec_s{simpl}_{clusters}.geojson"), regions_onshore=resources("regions_onshore_elec_s{simpl}_{clusters}.geojson"),
@ -219,7 +221,7 @@ rule build_cop_profiles:
rule build_solar_thermal_profiles: rule build_solar_thermal_profiles:
params: params:
snapshots={k: config["snapshots"][k] for k in ["start", "end", "inclusive"]}, # TODO use config_provider snapshots={k: config["snapshots"][k] for k in ["start", "end", "inclusive"]}, # TODO use config_provider
solar_thermal=config_provider("solar_thermal"), solar_thermal=config_provider("solar_thermal"),
input: input:
pop_layout=resources("pop_layout_{scope}.nc"), pop_layout=resources("pop_layout_{scope}.nc"),
@ -287,7 +289,9 @@ rule build_biomass_potentials:
biomass_potentials_all=resources( biomass_potentials_all=resources(
"biomass_potentials_all_s{simpl}_{clusters}_{planning_horizons}.csv" "biomass_potentials_all_s{simpl}_{clusters}_{planning_horizons}.csv"
), ),
biomass_potentials=resources("biomass_potentials_s{simpl}_{clusters}_{planning_horizons}.csv"), biomass_potentials=resources(
"biomass_potentials_s{simpl}_{clusters}_{planning_horizons}.csv"
),
threads: 1 threads: 1
resources: resources:
mem_mb=1000, mem_mb=1000,
@ -707,7 +711,7 @@ rule build_shipping_demand:
rule build_transport_demand: rule build_transport_demand:
params: params:
snapshots={k: config["snapshots"][k] for k in ["start", "end", "inclusive"]}, # TODO: use config_provider snapshots={k: config["snapshots"][k] for k in ["start", "end", "inclusive"]}, # TODO: use config_provider
sector=config_provider("sector"), sector=config_provider("sector"),
input: input:
clustered_pop_layout=resources("pop_layout_elec_s{simpl}_{clusters}.csv"), clustered_pop_layout=resources("pop_layout_elec_s{simpl}_{clusters}.csv"),
@ -814,7 +818,9 @@ rule prepare_sector_network:
network=resources("networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc"), network=resources("networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc"),
energy_totals_name=resources("energy_totals.csv"), energy_totals_name=resources("energy_totals.csv"),
eurostat=input_eurostat, eurostat=input_eurostat,
pop_weighted_energy_totals=resources("pop_weighted_energy_totals_s{simpl}_{clusters}.csv"), pop_weighted_energy_totals=resources(
"pop_weighted_energy_totals_s{simpl}_{clusters}.csv"
),
shipping_demand=resources("shipping_demand_s{simpl}_{clusters}.csv"), shipping_demand=resources("shipping_demand_s{simpl}_{clusters}.csv"),
transport_demand=resources("transport_demand_s{simpl}_{clusters}.csv"), transport_demand=resources("transport_demand_s{simpl}_{clusters}.csv"),
transport_data=resources("transport_data_s{simpl}_{clusters}.csv"), transport_data=resources("transport_data_s{simpl}_{clusters}.csv"),
@ -823,10 +829,14 @@ rule prepare_sector_network:
co2_totals_name=resources("co2_totals.csv"), co2_totals_name=resources("co2_totals.csv"),
co2="data/bundle-sector/eea/UNFCCC_v23.csv", co2="data/bundle-sector/eea/UNFCCC_v23.csv",
biomass_potentials=( biomass_potentials=(
resources("biomass_potentials_s{simpl}_{clusters}_" resources(
+ "{}.csv".format(config["biomass"]["year"])) "biomass_potentials_s{simpl}_{clusters}_"
+ "{}.csv".format(config["biomass"]["year"])
)
if config["foresight"] == "overnight" if config["foresight"] == "overnight"
else resources("biomass_potentials_s{simpl}_{clusters}_{planning_horizons}.csv") else resources(
"biomass_potentials_s{simpl}_{clusters}_{planning_horizons}.csv"
)
), ),
costs=( costs=(
"data/costs_{}.csv".format(config["costs"]["year"]) "data/costs_{}.csv".format(config["costs"]["year"])
@ -840,9 +850,15 @@ rule prepare_sector_network:
busmap=resources("busmap_elec_s{simpl}_{clusters}.csv"), busmap=resources("busmap_elec_s{simpl}_{clusters}.csv"),
clustered_pop_layout=resources("pop_layout_elec_s{simpl}_{clusters}.csv"), clustered_pop_layout=resources("pop_layout_elec_s{simpl}_{clusters}.csv"),
simplified_pop_layout=resources("pop_layout_elec_s{simpl}.csv"), simplified_pop_layout=resources("pop_layout_elec_s{simpl}.csv"),
industrial_demand=resources("industrial_energy_demand_elec_s{simpl}_{clusters}_{planning_horizons}.csv"), industrial_demand=resources(
hourly_heat_demand_total=resources("hourly_heat_demand_total_elec_s{simpl}_{clusters}.nc"), "industrial_energy_demand_elec_s{simpl}_{clusters}_{planning_horizons}.csv"
district_heat_share=resources("district_heat_share_elec_s{simpl}_{clusters}_{planning_horizons}.csv"), ),
hourly_heat_demand_total=resources(
"hourly_heat_demand_total_elec_s{simpl}_{clusters}.nc"
),
district_heat_share=resources(
"district_heat_share_elec_s{simpl}_{clusters}_{planning_horizons}.csv"
),
temp_soil_total=resources("temp_soil_total_elec_s{simpl}_{clusters}.nc"), temp_soil_total=resources("temp_soil_total_elec_s{simpl}_{clusters}.nc"),
temp_soil_rural=resources("temp_soil_rural_elec_s{simpl}_{clusters}.nc"), temp_soil_rural=resources("temp_soil_rural_elec_s{simpl}_{clusters}.nc"),
temp_soil_urban=resources("temp_soil_urban_elec_s{simpl}_{clusters}.nc"), temp_soil_urban=resources("temp_soil_urban_elec_s{simpl}_{clusters}.nc"),

View File

@ -24,7 +24,7 @@ rule cluster_networks:
expand( expand(
resources("networks/elec_s{simpl}_{clusters}.nc"), resources("networks/elec_s{simpl}_{clusters}.nc"),
**config["scenario"], **config["scenario"],
run=config["run"]["name"] run=config["run"]["name"],
), ),
@ -33,7 +33,7 @@ rule extra_components_networks:
expand( expand(
resources("networks/elec_s{simpl}_{clusters}_ec.nc"), resources("networks/elec_s{simpl}_{clusters}_ec.nc"),
**config["scenario"], **config["scenario"],
run=config["run"]["name"] run=config["run"]["name"],
), ),
@ -42,7 +42,7 @@ rule prepare_elec_networks:
expand( expand(
resources("networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc"), resources("networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc"),
**config["scenario"], **config["scenario"],
run=config["run"]["name"] run=config["run"]["name"],
), ),
@ -52,7 +52,7 @@ rule prepare_sector_networks:
RESULTS RESULTS
+ "prenetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc", + "prenetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
**config["scenario"], **config["scenario"],
run=config["run"]["name"] run=config["run"]["name"],
), ),
@ -61,7 +61,7 @@ rule solve_elec_networks:
expand( expand(
RESULTS + "networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc", RESULTS + "networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
**config["scenario"], **config["scenario"],
run=config["run"]["name"] run=config["run"]["name"],
), ),
@ -71,7 +71,7 @@ rule solve_sector_networks:
RESULTS RESULTS
+ "postnetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc", + "postnetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
**config["scenario"], **config["scenario"],
run=config["run"]["name"] run=config["run"]["name"],
), ),
@ -81,7 +81,7 @@ rule solve_sector_networks_perfect:
RESULTS RESULTS
+ "maps/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}-costs-all_{planning_horizons}.pdf", + "maps/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}-costs-all_{planning_horizons}.pdf",
**config["scenario"], **config["scenario"],
run=config["run"]["name"] run=config["run"]["name"],
), ),
@ -91,12 +91,12 @@ rule validate_elec_networks:
RESULTS RESULTS
+ "figures/.statistics_plots_elec_s{simpl}_{clusters}_ec_l{ll}_{opts}", + "figures/.statistics_plots_elec_s{simpl}_{clusters}_ec_l{ll}_{opts}",
**config["scenario"], **config["scenario"],
run=config["run"]["name"] run=config["run"]["name"],
), ),
expand( expand(
RESULTS RESULTS
+ "figures/.validation_{kind}_plots_elec_s{simpl}_{clusters}_ec_l{ll}_{opts}", + "figures/.validation_{kind}_plots_elec_s{simpl}_{clusters}_ec_l{ll}_{opts}",
**config["scenario"], **config["scenario"],
run=config["run"]["name"], run=config["run"]["name"],
kind=["production", "prices", "cross_border"] kind=["production", "prices", "cross_border"],
), ),

View File

@ -162,7 +162,7 @@ rule make_summary:
params: params:
foresight=config_provider("foresight"), foresight=config_provider("foresight"),
costs=config_provider("costs"), costs=config_provider("costs"),
snapshots={k: config["snapshots"][k] for k in ["start", "end", "inclusive"]}, # TODO: use config_provider snapshots={k: config["snapshots"][k] for k in ["start", "end", "inclusive"]}, # TODO: use config_provider
scenario=config_provider("scenario"), scenario=config_provider("scenario"),
RDIR=RDIR, RDIR=RDIR,
input: input:
@ -174,7 +174,7 @@ rule make_summary:
RESULTS RESULTS
+ "postnetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc", + "postnetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
**config["scenario"], **config["scenario"],
run=config["run"]["name"] run=config["run"]["name"],
), ),
costs=( costs=(
"data/costs_{}.csv".format(config["costs"]["year"]) "data/costs_{}.csv".format(config["costs"]["year"])
@ -189,7 +189,7 @@ rule make_summary:
RESULTS RESULTS
+ "maps/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}-costs-all_{planning_horizons}.pdf", + "maps/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}-costs-all_{planning_horizons}.pdf",
**config["scenario"], **config["scenario"],
run=config["run"]["name"] run=config["run"]["name"],
), ),
h2_plot=expand( h2_plot=expand(
( (
@ -199,7 +199,7 @@ rule make_summary:
else [] else []
), ),
**config["scenario"], **config["scenario"],
run=config["run"]["name"] run=config["run"]["name"],
), ),
ch4_plot=expand( ch4_plot=expand(
( (
@ -209,7 +209,7 @@ rule make_summary:
else [] else []
), ),
**config["scenario"], **config["scenario"],
run=config["run"]["name"] run=config["run"]["name"],
), ),
output: output:
nodal_costs=RESULTS + "csvs/nodal_costs.csv", nodal_costs=RESULTS + "csvs/nodal_costs.csv",

View File

@ -21,7 +21,9 @@ rule add_existing_baseyear:
), ),
cop_soil_total=resources("cop_soil_total_elec_s{simpl}_{clusters}.nc"), cop_soil_total=resources("cop_soil_total_elec_s{simpl}_{clusters}.nc"),
cop_air_total=resources("cop_air_total_elec_s{simpl}_{clusters}.nc"), cop_air_total=resources("cop_air_total_elec_s{simpl}_{clusters}.nc"),
existing_heating_distribution=resources("existing_heating_distribution_elec_s{simpl}_{clusters}_{planning_horizons}.csv"), existing_heating_distribution=resources(
"existing_heating_distribution_elec_s{simpl}_{clusters}_{planning_horizons}.csv"
),
existing_solar="data/existing_infrastructure/solar_capacity_IRENA.csv", existing_solar="data/existing_infrastructure/solar_capacity_IRENA.csv",
existing_onwind="data/existing_infrastructure/onwind_capacity_IRENA.csv", existing_onwind="data/existing_infrastructure/onwind_capacity_IRENA.csv",
existing_offwind="data/existing_infrastructure/offwind_capacity_IRENA.csv", existing_offwind="data/existing_infrastructure/offwind_capacity_IRENA.csv",
@ -54,7 +56,7 @@ rule add_brownfield:
"sector", "H2_retrofit_capacity_per_CH4" "sector", "H2_retrofit_capacity_per_CH4"
), ),
threshold_capacity=config_provider("existing_capacities", " threshold_capacity"), threshold_capacity=config_provider("existing_capacities", " threshold_capacity"),
snapshots={k: config["snapshots"][k] for k in ["start", "end", "inclusive"]}, # TODO: use config_provider snapshots={k: config["snapshots"][k] for k in ["start", "end", "inclusive"]}, # TODO: use config_provider
carriers=config_provider("electricity", "renewable_carriers"), carriers=config_provider("electricity", "renewable_carriers"),
input: input:
**{ **{

View File

@ -133,7 +133,7 @@ import numpy as np
import pandas as pd import pandas as pd
import pypsa import pypsa
import seaborn as sns import seaborn as sns
from _helpers import configure_logging, update_p_nom_max, set_scenario_config from _helpers import configure_logging, set_scenario_config, update_p_nom_max
from add_electricity import load_costs from add_electricity import load_costs
from packaging.version import Version, parse from packaging.version import Version, parse
from pypsa.clustering.spatial import ( from pypsa.clustering.spatial import (

View File

@ -18,7 +18,7 @@ import numpy as np
import pandas as pd import pandas as pd
import pypsa import pypsa
import xarray as xr import xarray as xr
from _helpers import update_config_with_sector_opts, set_scenario_config from _helpers import set_scenario_config, update_config_with_sector_opts
from add_electricity import calculate_annuity, sanitize_carriers, sanitize_locations from add_electricity import calculate_annuity, sanitize_carriers, sanitize_locations
from build_energy_totals import build_co2_totals, build_eea_co2, build_eurostat_co2 from build_energy_totals import build_co2_totals, build_eea_co2, build_eurostat_co2
from networkx.algorithms import complement from networkx.algorithms import complement

View File

@ -13,8 +13,8 @@ from pathlib import Path
from _helpers import ( from _helpers import (
configure_logging, configure_logging,
progress_retrieve, progress_retrieve,
validate_checksum,
set_scenario_config, set_scenario_config,
validate_checksum,
) )
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -40,8 +40,8 @@ from _benchmark import memory_logger
from _helpers import ( from _helpers import (
configure_logging, configure_logging,
get_opt, get_opt,
update_config_with_sector_opts,
set_scenario_config, set_scenario_config,
update_config_with_sector_opts,
) )
from pypsa.descriptors import get_activity_mask from pypsa.descriptors import get_activity_mask
from pypsa.descriptors import get_switchable_as_dense as get_as_dense from pypsa.descriptors import get_switchable_as_dense as get_as_dense