convert param back to config for "logging" and "run", made "enable" more specific

This commit is contained in:
virio-andreyana 2023-05-17 18:43:30 +02:00 committed by GitHub
parent 61893c3c9b
commit 8208ac033b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 19 additions and 41 deletions

View File

@ -201,7 +201,6 @@ rule build_ship_raster:
rule build_renewable_profiles: rule build_renewable_profiles:
params: params:
run=config["run"],
renewable=config["renewable"], renewable=config["renewable"],
input: input:
base_network=RESOURCES + "networks/base.nc", base_network=RESOURCES + "networks/base.nc",
@ -350,7 +349,7 @@ rule cluster_network:
lines=config["lines"], lines=config["lines"],
renewable=config["renewable"], renewable=config["renewable"],
clustering=config["clustering"], clustering=config["clustering"],
enable=config["enable"], enable=config["enable"].get("custom_busmap", False),
input: input:
network=RESOURCES + "networks/elec_s{simpl}.nc", network=RESOURCES + "networks/elec_s{simpl}.nc",
regions_onshore=RESOURCES + "regions_onshore_elec_s{simpl}.geojson", regions_onshore=RESOURCES + "regions_onshore_elec_s{simpl}.geojson",

View File

@ -4,8 +4,6 @@
rule build_population_layouts: rule build_population_layouts:
params:
logging=config["logging"],
input: input:
nuts3_shapes=RESOURCES + "nuts3_shapes.geojson", nuts3_shapes=RESOURCES + "nuts3_shapes.geojson",
urban_percent="data/urban_percent.csv", urban_percent="data/urban_percent.csv",
@ -72,8 +70,6 @@ rule build_simplified_population_layouts:
if config["sector"]["gas_network"] or config["sector"]["H2_retrofit"]: if config["sector"]["gas_network"] or config["sector"]["H2_retrofit"]:
rule build_gas_network: rule build_gas_network:
params:
logging=config["logging"],
input: input:
gas_network="data/gas_network/scigrid-gas/data/IGGIELGN_PipeSegments.geojson", gas_network="data/gas_network/scigrid-gas/data/IGGIELGN_PipeSegments.geojson",
output: output:
@ -88,8 +84,6 @@ if config["sector"]["gas_network"] or config["sector"]["H2_retrofit"]:
"../scripts/build_gas_network.py" "../scripts/build_gas_network.py"
rule build_gas_input_locations: rule build_gas_input_locations:
params:
logging=config["logging"],
input: input:
lng=HTTP.remote( lng=HTTP.remote(
"https://globalenergymonitor.org/wp-content/uploads/2022/09/Europe-Gas-Tracker-August-2022.xlsx", "https://globalenergymonitor.org/wp-content/uploads/2022/09/Europe-Gas-Tracker-August-2022.xlsx",
@ -116,8 +110,6 @@ if config["sector"]["gas_network"] or config["sector"]["H2_retrofit"]:
"../scripts/build_gas_input_locations.py" "../scripts/build_gas_input_locations.py"
rule cluster_gas_network: rule cluster_gas_network:
params:
logging=config["logging"],
input: input:
cleaned_gas_network=RESOURCES + "gas_network.csv", cleaned_gas_network=RESOURCES + "gas_network.csv",
regions_onshore=RESOURCES regions_onshore=RESOURCES
@ -246,10 +238,8 @@ rule build_solar_thermal_profiles:
rule build_energy_totals: rule build_energy_totals:
params: params:
run=config["run"],
countries=config["countries"], countries=config["countries"],
energy=config["energy"], energy=config["energy"],
logging=config["logging"],
input: input:
nuts3_shapes=RESOURCES + "nuts3_shapes.geojson", nuts3_shapes=RESOURCES + "nuts3_shapes.geojson",
co2="data/eea/UNFCCC_v23.csv", co2="data/eea/UNFCCC_v23.csv",
@ -437,10 +427,8 @@ rule build_industry_sector_ratios:
rule build_industrial_production_per_country: rule build_industrial_production_per_country:
params: params:
run=config["run"],
industry=config["industry"], industry=config["industry"],
countries=config["countries"], countries=config["countries"],
logging=config["logging"],
input: input:
ammonia_production=RESOURCES + "ammonia_production.csv", ammonia_production=RESOURCES + "ammonia_production.csv",
jrc="data/jrc-idees-2015", jrc="data/jrc-idees-2015",
@ -491,7 +479,6 @@ rule build_industrial_distribution_key:
params: params:
industry=config["industry"], industry=config["industry"],
countries=config["countries"], countries=config["countries"],
logging=config["logging"],
input: input:
regions_onshore=RESOURCES + "regions_onshore_elec_s{simpl}_{clusters}.geojson", regions_onshore=RESOURCES + "regions_onshore_elec_s{simpl}_{clusters}.geojson",
clustered_pop_layout=RESOURCES + "pop_layout_elec_s{simpl}_{clusters}.csv", clustered_pop_layout=RESOURCES + "pop_layout_elec_s{simpl}_{clusters}.csv",
@ -567,7 +554,6 @@ rule build_industrial_energy_demand_per_node:
rule build_industrial_energy_demand_per_country_today: rule build_industrial_energy_demand_per_country_today:
params: params:
run=config["run"],
countries=config["countries"], countries=config["countries"],
industry=config["industry"], industry=config["industry"],
input: input:
@ -723,7 +709,6 @@ rule prepare_sector_network:
existing_capacities=config["existing_capacities"], existing_capacities=config["existing_capacities"],
foresight=config["foresight"], foresight=config["foresight"],
costs=config["costs"], costs=config["costs"],
logging=config["logging"],
sector=config["sector"], sector=config["sector"],
industry=config["industry"], industry=config["industry"],
pypsa_eur=config["pypsa_eur"], pypsa_eur=config["pypsa_eur"],

View File

@ -10,7 +10,6 @@ localrules:
rule plot_network: rule plot_network:
params: params:
logging=config["logging"],
foresight=config["foresight"], foresight=config["foresight"],
plotting=config["plotting"], plotting=config["plotting"],
input: input:
@ -74,7 +73,6 @@ rule make_summary:
foresight=config["foresight"], foresight=config["foresight"],
costs=config["costs"], costs=config["costs"],
snapshots=config["snapshots"], snapshots=config["snapshots"],
logging=config["logging"],
scenario=config["scenario"], scenario=config["scenario"],
RDIR=RDIR, RDIR=RDIR,
input: input:
@ -123,7 +121,6 @@ rule make_summary:
rule plot_summary: rule plot_summary:
params: params:
logging=config["logging"],
countries=config["countries"], countries=config["countries"],
scenario=config["scenario"], scenario=config["scenario"],
plotting=config["plotting"], plotting=config["plotting"],

View File

@ -20,7 +20,6 @@ if config["enable"].get("retrieve_databundle", True):
rule retrieve_databundle: rule retrieve_databundle:
params: params:
run=config["run"],
tutorial=config["tutorial"], tutorial=config["tutorial"],
output: output:
expand("data/bundle/{file}", file=datafiles), expand("data/bundle/{file}", file=datafiles),

View File

@ -7,7 +7,6 @@ rule add_existing_baseyear:
params: params:
scenario=config["scenario"], scenario=config["scenario"],
sector=config["sector"], sector=config["sector"],
logging=config["logging"],
existing_capacities=config["existing_capacities"], existing_capacities=config["existing_capacities"],
costs=config["costs"], costs=config["costs"],
input: input:
@ -49,7 +48,6 @@ rule add_existing_baseyear:
rule add_brownfield: rule add_brownfield:
params: params:
logging=config["logging"],
sector=config["sector"], sector=config["sector"],
existing_capacities=config["existing_capacities"], existing_capacities=config["existing_capacities"],
input: input:

View File

@ -139,7 +139,7 @@ if __name__ == "__main__":
planning_horizons=2030, planning_horizons=2030,
) )
logging.basicConfig(level=snakemake.params["logging"]["level"]) logging.basicConfig(level=snakemake.config["logging"]["level"])
update_config_with_sector_opts(snakemake.config, snakemake.wildcards.sector_opts) update_config_with_sector_opts(snakemake.config, snakemake.wildcards.sector_opts)

View File

@ -608,7 +608,7 @@ if __name__ == "__main__":
planning_horizons=2020, planning_horizons=2020,
) )
logging.basicConfig(level=snakemake.params["logging"]["level"]) logging.basicConfig(level=snakemake.config["logging"]["level"])
update_config_with_sector_opts(snakemake.config, snakemake.wildcards.sector_opts) update_config_with_sector_opts(snakemake.config, snakemake.wildcards.sector_opts)

View File

@ -373,7 +373,7 @@ def idees_per_country(ct, year, base_dir):
def build_idees(countries, year): def build_idees(countries, year):
nprocesses = snakemake.threads nprocesses = snakemake.threads
disable_progress = snakemake.params["run"].get("disable_progressbar", False) disable_progress = snakemake.config["run"].get("disable_progressbar", False)
func = partial(idees_per_country, year=year, base_dir=snakemake.input.idees) func = partial(idees_per_country, year=year, base_dir=snakemake.input.idees)
tqdm_kwargs = dict( tqdm_kwargs = dict(
@ -735,7 +735,7 @@ if __name__ == "__main__":
snakemake = mock_snakemake("build_energy_totals") snakemake = mock_snakemake("build_energy_totals")
logging.basicConfig(level=snakemake.params["logging"]["level"]) logging.basicConfig(level=snakemake.config["logging"]["level"])
config = snakemake.params["energy"] config = snakemake.params["energy"]

View File

@ -86,7 +86,7 @@ if __name__ == "__main__":
clusters="37", clusters="37",
) )
logging.basicConfig(level=snakemake.params["logging"]["level"]) logging.basicConfig(level=snakemake.config["logging"]["level"])
regions = load_bus_regions( regions = load_bus_regions(
snakemake.input.regions_onshore, snakemake.input.regions_offshore snakemake.input.regions_onshore, snakemake.input.regions_offshore

View File

@ -147,7 +147,7 @@ if __name__ == "__main__":
snakemake = mock_snakemake("build_gas_network") snakemake = mock_snakemake("build_gas_network")
logging.basicConfig(level=snakemake.params["logging"]["level"]) logging.basicConfig(level=snakemake.config["logging"]["level"])
gas_network = load_dataset(snakemake.input.gas_network) gas_network = load_dataset(snakemake.input.gas_network)

View File

@ -141,7 +141,7 @@ if __name__ == "__main__":
clusters=48, clusters=48,
) )
logging.basicConfig(level=snakemake.params["logging"]["level"]) logging.basicConfig(level=snakemake.config["logging"]["level"])
countries = snakemake.params["countries"] countries = snakemake.params["countries"]

View File

@ -153,7 +153,7 @@ def add_non_eu28_industrial_energy_demand(countries, demand):
def industrial_energy_demand(countries, year): def industrial_energy_demand(countries, year):
nprocesses = snakemake.threads nprocesses = snakemake.threads
disable_progress = snakemake.params["run"].get("disable_progressbar", False) disable_progress = snakemake.config["run"].get("disable_progressbar", False)
func = partial( func = partial(
industrial_energy_demand_per_country, year=year, jrc_dir=snakemake.input.jrc industrial_energy_demand_per_country, year=year, jrc_dir=snakemake.input.jrc
) )

View File

@ -217,7 +217,7 @@ def industry_production_per_country(country, year, eurostat_dir, jrc_dir):
def industry_production(countries, year, eurostat_dir, jrc_dir): def industry_production(countries, year, eurostat_dir, jrc_dir):
nprocesses = snakemake.threads nprocesses = snakemake.threads
disable_progress = snakemake.params["run"].get("disable_progressbar", False) disable_progress = snakemake.config["run"].get("disable_progressbar", False)
func = partial( func = partial(
industry_production_per_country, industry_production_per_country,
@ -277,7 +277,7 @@ if __name__ == "__main__":
snakemake = mock_snakemake("build_industrial_production_per_country") snakemake = mock_snakemake("build_industrial_production_per_country")
logging.basicConfig(level=snakemake.params["logging"]["level"]) logging.basicConfig(level=snakemake.config["logging"]["level"])
countries = snakemake.params["countries"] countries = snakemake.params["countries"]

View File

@ -23,7 +23,7 @@ if __name__ == "__main__":
snakemake = mock_snakemake("build_population_layouts") snakemake = mock_snakemake("build_population_layouts")
logging.basicConfig(level=snakemake.params["logging"]["level"]) logging.basicConfig(level=snakemake.config["logging"]["level"])
cutout = atlite.Cutout(snakemake.input.cutout) cutout = atlite.Cutout(snakemake.input.cutout)

View File

@ -203,7 +203,7 @@ if __name__ == "__main__":
configure_logging(snakemake) configure_logging(snakemake)
nprocesses = int(snakemake.threads) nprocesses = int(snakemake.threads)
noprogress = snakemake.params["run"].get("disable_progressbar", True) noprogress = snakemake.config["run"].get("disable_progressbar", True)
config = snakemake.params["renewable"][snakemake.wildcards.technology] config = snakemake.params["renewable"][snakemake.wildcards.technology]
resource = config["resource"] # pv panel config / wind turbine config resource = config["resource"] # pv panel config / wind turbine config
correction_factor = config.get("correction_factor", 1.0) correction_factor = config.get("correction_factor", 1.0)

View File

@ -110,7 +110,7 @@ if __name__ == "__main__":
snakemake = mock_snakemake("cluster_gas_network", simpl="", clusters="37") snakemake = mock_snakemake("cluster_gas_network", simpl="", clusters="37")
logging.basicConfig(level=snakemake.params["logging"]["level"]) logging.basicConfig(level=snakemake.config["logging"]["level"])
fn = snakemake.input.cleaned_gas_network fn = snakemake.input.cleaned_gas_network
df = pd.read_csv(fn, index_col=0) df = pd.read_csv(fn, index_col=0)

View File

@ -682,7 +682,7 @@ if __name__ == "__main__":
snakemake = mock_snakemake("make_summary") snakemake = mock_snakemake("make_summary")
logging.basicConfig(level=snakemake.params["logging"]["level"]) logging.basicConfig(level=snakemake.config["logging"]["level"])
networks_dict = { networks_dict = {
(cluster, ll, opt + sector_opt, planning_horizon): "results/" (cluster, ll, opt + sector_opt, planning_horizon): "results/"

View File

@ -930,7 +930,7 @@ if __name__ == "__main__":
planning_horizons="2030", planning_horizons="2030",
) )
logging.basicConfig(level=snakemake.params["logging"]["level"]) logging.basicConfig(level=snakemake.config["logging"]["level"])
overrides = override_component_attrs(snakemake.input.overrides) overrides = override_component_attrs(snakemake.input.overrides)
n = pypsa.Network(snakemake.input.network, override_component_attrs=overrides) n = pypsa.Network(snakemake.input.network, override_component_attrs=overrides)

View File

@ -545,7 +545,7 @@ if __name__ == "__main__":
snakemake = mock_snakemake("plot_summary") snakemake = mock_snakemake("plot_summary")
logging.basicConfig(level=snakemake.params["logging"]["level"]) logging.basicConfig(level=snakemake.config["logging"]["level"])
n_header = 4 n_header = 4

View File

@ -3266,7 +3266,7 @@ if __name__ == "__main__":
planning_horizons="2030", planning_horizons="2030",
) )
logging.basicConfig(level=snakemake.params["logging"]["level"]) logging.basicConfig(level=snakemake.config["logging"]["level"])
update_config_with_sector_opts(snakemake.config, snakemake.wildcards.sector_opts) update_config_with_sector_opts(snakemake.config, snakemake.wildcards.sector_opts)

View File

@ -63,7 +63,7 @@ if __name__ == "__main__":
to_fn = Path(f"{rootpath}/data") to_fn = Path(f"{rootpath}/data")
logger.info(f"Downloading databundle from '{url}'.") logger.info(f"Downloading databundle from '{url}'.")
disable_progress = snakemake.params["run"].get("disable_progressbar", False) disable_progress = snakemake.config["run"].get("disable_progressbar", False)
progress_retrieve(url, tarball_fn, disable=disable_progress) progress_retrieve(url, tarball_fn, disable=disable_progress)
logger.info("Extracting databundle.") logger.info("Extracting databundle.")