2023-02-16 10:50:55 +00:00
|
|
|
# SPDX-FileCopyrightText: : 2017-2023 The PyPSA-Eur Authors
|
2020-05-29 07:50:55 +00:00
|
|
|
#
|
2021-09-14 14:37:41 +00:00
|
|
|
# SPDX-License-Identifier: MIT
|
2020-05-29 07:50:55 +00:00
|
|
|
|
2019-11-28 15:33:33 +00:00
|
|
|
from os.path import normpath, exists
|
2022-02-22 18:34:47 +00:00
|
|
|
from shutil import copyfile, move
|
2019-11-28 15:33:33 +00:00
|
|
|
|
2021-04-27 12:54:54 +00:00
|
|
|
from snakemake.remote.HTTP import RemoteProvider as HTTPRemoteProvider
|
2022-09-16 13:04:04 +00:00
|
|
|
|
2021-04-27 12:54:54 +00:00
|
|
|
HTTP = HTTPRemoteProvider()
|
|
|
|
|
2023-02-16 10:51:39 +00:00
|
|
|
if not exists("config.yaml"):
|
|
|
|
copyfile("config.default.yaml", "config.yaml")
|
2019-11-22 14:13:46 +00:00
|
|
|
|
2022-09-16 13:04:04 +00:00
|
|
|
|
2017-12-18 19:34:15 +00:00
|
|
|
configfile: "config.yaml"
|
|
|
|
|
2022-09-16 13:04:04 +00:00
|
|
|
|
2022-09-08 07:52:00 +00:00
|
|
|
run = config.get("run", {})
|
2022-09-13 07:47:11 +00:00
|
|
|
RDIR = run["name"] + "/" if run.get("name") else ""
|
2022-09-16 13:04:04 +00:00
|
|
|
CDIR = RDIR if not run.get("shared_cutouts") else ""
|
2022-09-08 07:52:00 +00:00
|
|
|
|
|
|
|
COSTS = "resources/" + RDIR + "costs.csv"
|
2022-09-16 13:04:04 +00:00
|
|
|
ATLITE_NPROCESSES = config["atlite"].get("nprocesses", 4)
|
2018-10-25 14:43:24 +00:00
|
|
|
|
2022-09-08 07:52:00 +00:00
|
|
|
|
2017-12-18 19:34:15 +00:00
|
|
|
wildcard_constraints:
|
2018-10-26 08:28:54 +00:00
|
|
|
simpl="[a-zA-Z0-9]*|all",
|
|
|
|
clusters="[0-9]+m?|all",
|
2020-12-03 18:50:53 +00:00
|
|
|
ll="(v|c)([0-9\.]+|opt|all)|all",
|
2022-09-16 13:04:04 +00:00
|
|
|
opts="[-+a-zA-Z0-9\.]*",
|
2017-12-18 19:34:15 +00:00
|
|
|
|
2019-02-03 13:00:45 +00:00
|
|
|
|
2020-12-05 16:54:50 +00:00
|
|
|
rule cluster_all_networks:
|
2022-09-16 13:04:04 +00:00
|
|
|
input:
|
|
|
|
expand("networks/" + RDIR + "elec_s{simpl}_{clusters}.nc", **config["scenario"]),
|
2020-01-09 13:09:28 +00:00
|
|
|
|
2017-12-18 19:34:15 +00:00
|
|
|
|
2020-12-05 16:54:50 +00:00
|
|
|
rule extra_components_all_networks:
|
2022-09-16 13:04:04 +00:00
|
|
|
input:
|
|
|
|
expand(
|
|
|
|
"networks/" + RDIR + "elec_s{simpl}_{clusters}_ec.nc", **config["scenario"]
|
|
|
|
),
|
2020-12-03 18:50:53 +00:00
|
|
|
|
2020-01-09 13:09:28 +00:00
|
|
|
|
2020-12-05 16:54:50 +00:00
|
|
|
rule prepare_all_networks:
|
2022-09-16 13:04:04 +00:00
|
|
|
input:
|
|
|
|
expand(
|
|
|
|
"networks/" + RDIR + "elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
|
|
|
|
**config["scenario"]
|
|
|
|
),
|
2020-12-03 18:50:53 +00:00
|
|
|
|
2017-12-18 19:34:15 +00:00
|
|
|
|
2020-12-05 16:54:50 +00:00
|
|
|
rule solve_all_networks:
|
2022-09-16 13:04:04 +00:00
|
|
|
input:
|
|
|
|
expand(
|
|
|
|
"results/networks/" + RDIR + "elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
|
|
|
|
**config["scenario"]
|
|
|
|
),
|
|
|
|
|
2020-12-03 18:50:53 +00:00
|
|
|
|
2022-09-16 13:04:04 +00:00
|
|
|
if config["enable"].get("prepare_links_p_nom", False):
|
2018-01-30 22:48:29 +00:00
|
|
|
|
2018-08-13 12:09:20 +00:00
|
|
|
rule prepare_links_p_nom:
|
2022-09-16 13:04:04 +00:00
|
|
|
output:
|
|
|
|
"data/links_p_nom.csv",
|
|
|
|
log:
|
|
|
|
"logs/" + RDIR + "prepare_links_p_nom.log",
|
2018-08-13 12:09:20 +00:00
|
|
|
threads: 1
|
2022-09-16 13:04:04 +00:00
|
|
|
resources:
|
2022-12-27 11:16:02 +00:00
|
|
|
mem_mb=1500,
|
2022-09-16 13:04:04 +00:00
|
|
|
script:
|
|
|
|
"scripts/prepare_links_p_nom.py"
|
|
|
|
|
|
|
|
|
|
|
|
datafiles = [
|
|
|
|
"ch_cantons.csv",
|
|
|
|
"je-e-21.03.02.xls",
|
|
|
|
"eez/World_EEZ_v8_2014.shp",
|
|
|
|
"hydro_capacities.csv",
|
|
|
|
"naturalearth/ne_10m_admin_0_countries.shp",
|
|
|
|
"NUTS_2013_60M_SH/data/NUTS_RG_60M_2013.shp",
|
|
|
|
"nama_10r_3popgdp.tsv.gz",
|
|
|
|
"nama_10r_3gdp.tsv.gz",
|
|
|
|
"corine/g250_clc06_V18_5.tif",
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
if not config.get("tutorial", False):
|
2019-11-06 16:50:57 +00:00
|
|
|
datafiles.extend(["natura/Natura2000_end2015.shp", "GEBCO_2014_2D.nc"])
|
2019-11-05 11:53:21 +00:00
|
|
|
|
2020-12-03 18:50:53 +00:00
|
|
|
|
2022-09-16 13:04:04 +00:00
|
|
|
if config["enable"].get("retrieve_databundle", True):
|
|
|
|
|
2019-11-19 14:56:44 +00:00
|
|
|
rule retrieve_databundle:
|
2022-09-16 13:04:04 +00:00
|
|
|
output:
|
|
|
|
expand("data/bundle/{file}", file=datafiles),
|
|
|
|
log:
|
|
|
|
"logs/" + RDIR + "retrieve_databundle.log",
|
|
|
|
resources:
|
|
|
|
mem_mb=1000,
|
|
|
|
script:
|
|
|
|
"scripts/retrieve_databundle.py"
|
2019-11-05 11:53:21 +00:00
|
|
|
|
2020-08-25 19:41:21 +00:00
|
|
|
|
2021-11-10 09:37:09 +00:00
|
|
|
rule retrieve_load_data:
|
2022-09-16 13:04:04 +00:00
|
|
|
input:
|
|
|
|
HTTP.remote(
|
|
|
|
"data.open-power-system-data.org/time_series/2019-06-05/time_series_60min_singleindex.csv",
|
|
|
|
keep_local=True,
|
|
|
|
static=True,
|
|
|
|
),
|
|
|
|
output:
|
|
|
|
"data/load_raw.csv",
|
|
|
|
resources:
|
|
|
|
mem_mb=5000,
|
2022-09-16 11:33:38 +00:00
|
|
|
run:
|
|
|
|
move(input[0], output[0])
|
2021-11-10 09:37:09 +00:00
|
|
|
|
|
|
|
|
2020-12-03 11:49:04 +00:00
|
|
|
rule build_load_data:
|
2022-09-16 13:04:04 +00:00
|
|
|
input:
|
|
|
|
"data/load_raw.csv",
|
|
|
|
output:
|
|
|
|
"resources/" + RDIR + "load.csv",
|
|
|
|
log:
|
|
|
|
"logs/" + RDIR + "build_load_data.log",
|
|
|
|
resources:
|
|
|
|
mem_mb=5000,
|
|
|
|
script:
|
|
|
|
"scripts/build_load_data.py"
|
|
|
|
|
2020-08-25 19:41:21 +00:00
|
|
|
|
2019-10-31 15:45:13 +00:00
|
|
|
rule build_powerplants:
|
2019-11-06 14:59:34 +00:00
|
|
|
input:
|
2022-09-08 07:52:00 +00:00
|
|
|
base_network="networks/" + RDIR + "base.nc",
|
2022-09-16 13:04:04 +00:00
|
|
|
custom_powerplants="data/custom_powerplants.csv",
|
|
|
|
output:
|
|
|
|
"resources/" + RDIR + "powerplants.csv",
|
|
|
|
log:
|
|
|
|
"logs/" + RDIR + "build_powerplants.log",
|
2019-10-31 15:45:13 +00:00
|
|
|
threads: 1
|
2022-09-16 13:04:04 +00:00
|
|
|
resources:
|
|
|
|
mem_mb=5000,
|
|
|
|
script:
|
|
|
|
"scripts/build_powerplants.py"
|
2017-12-18 19:34:15 +00:00
|
|
|
|
2020-12-03 18:50:53 +00:00
|
|
|
|
2017-12-18 19:34:15 +00:00
|
|
|
rule base_network:
|
|
|
|
input:
|
2022-09-16 13:04:04 +00:00
|
|
|
eg_buses="data/entsoegridkit/buses.csv",
|
|
|
|
eg_lines="data/entsoegridkit/lines.csv",
|
|
|
|
eg_links="data/entsoegridkit/links.csv",
|
|
|
|
eg_converters="data/entsoegridkit/converters.csv",
|
|
|
|
eg_transformers="data/entsoegridkit/transformers.csv",
|
|
|
|
parameter_corrections="data/parameter_corrections.yaml",
|
|
|
|
links_p_nom="data/links_p_nom.csv",
|
|
|
|
links_tyndp="data/links_tyndp.csv",
|
2022-09-08 07:52:00 +00:00
|
|
|
country_shapes="resources/" + RDIR + "country_shapes.geojson",
|
|
|
|
offshore_shapes="resources/" + RDIR + "offshore_shapes.geojson",
|
2022-09-16 13:04:04 +00:00
|
|
|
europe_shape="resources/" + RDIR + "europe_shape.geojson",
|
|
|
|
output:
|
|
|
|
"networks/" + RDIR + "base.nc",
|
|
|
|
log:
|
|
|
|
"logs/" + RDIR + "base_network.log",
|
|
|
|
benchmark:
|
|
|
|
"benchmarks/" + RDIR + "base_network"
|
2017-12-18 19:34:15 +00:00
|
|
|
threads: 1
|
2022-09-16 13:04:04 +00:00
|
|
|
resources:
|
2022-12-27 11:16:02 +00:00
|
|
|
mem_mb=1500,
|
2022-09-16 13:04:04 +00:00
|
|
|
script:
|
|
|
|
"scripts/base_network.py"
|
2017-12-18 19:34:15 +00:00
|
|
|
|
2020-12-03 18:50:53 +00:00
|
|
|
|
2018-08-03 09:49:23 +00:00
|
|
|
rule build_shapes:
|
|
|
|
input:
|
2022-09-16 13:04:04 +00:00
|
|
|
naturalearth="data/bundle/naturalearth/ne_10m_admin_0_countries.shp",
|
|
|
|
eez="data/bundle/eez/World_EEZ_v8_2014.shp",
|
|
|
|
nuts3="data/bundle/NUTS_2013_60M_SH/data/NUTS_RG_60M_2013.shp",
|
|
|
|
nuts3pop="data/bundle/nama_10r_3popgdp.tsv.gz",
|
|
|
|
nuts3gdp="data/bundle/nama_10r_3gdp.tsv.gz",
|
|
|
|
ch_cantons="data/bundle/ch_cantons.csv",
|
|
|
|
ch_popgdp="data/bundle/je-e-21.03.02.xls",
|
2018-08-03 09:49:23 +00:00
|
|
|
output:
|
2022-09-08 07:52:00 +00:00
|
|
|
country_shapes="resources/" + RDIR + "country_shapes.geojson",
|
|
|
|
offshore_shapes="resources/" + RDIR + "offshore_shapes.geojson",
|
|
|
|
europe_shape="resources/" + RDIR + "europe_shape.geojson",
|
2022-09-16 13:04:04 +00:00
|
|
|
nuts3_shapes="resources/" + RDIR + "nuts3_shapes.geojson",
|
|
|
|
log:
|
|
|
|
"logs/" + RDIR + "build_shapes.log",
|
2018-08-03 09:49:23 +00:00
|
|
|
threads: 1
|
2022-09-16 13:04:04 +00:00
|
|
|
resources:
|
2022-12-27 11:16:02 +00:00
|
|
|
mem_mb=1500,
|
2022-09-16 13:04:04 +00:00
|
|
|
script:
|
|
|
|
"scripts/build_shapes.py"
|
2018-08-03 09:49:23 +00:00
|
|
|
|
2020-12-03 18:50:53 +00:00
|
|
|
|
2018-01-29 21:28:33 +00:00
|
|
|
rule build_bus_regions:
|
2017-12-18 19:34:15 +00:00
|
|
|
input:
|
2022-09-08 07:52:00 +00:00
|
|
|
country_shapes="resources/" + RDIR + "country_shapes.geojson",
|
|
|
|
offshore_shapes="resources/" + RDIR + "offshore_shapes.geojson",
|
2022-09-16 13:04:04 +00:00
|
|
|
base_network="networks/" + RDIR + "base.nc",
|
2018-01-29 21:28:33 +00:00
|
|
|
output:
|
2022-09-08 07:52:00 +00:00
|
|
|
regions_onshore="resources/" + RDIR + "regions_onshore.geojson",
|
2022-09-16 13:04:04 +00:00
|
|
|
regions_offshore="resources/" + RDIR + "regions_offshore.geojson",
|
|
|
|
log:
|
|
|
|
"logs/" + RDIR + "build_bus_regions.log",
|
2020-12-03 18:50:53 +00:00
|
|
|
threads: 1
|
2022-09-16 13:04:04 +00:00
|
|
|
resources:
|
|
|
|
mem_mb=1000,
|
|
|
|
script:
|
|
|
|
"scripts/build_bus_regions.py"
|
|
|
|
|
|
|
|
|
|
|
|
if config["enable"].get("build_cutout", False):
|
2018-01-29 21:28:33 +00:00
|
|
|
|
2019-11-05 11:53:21 +00:00
|
|
|
rule build_cutout:
|
2022-09-16 13:04:04 +00:00
|
|
|
input:
|
2022-09-08 07:52:00 +00:00
|
|
|
regions_onshore="resources/" + RDIR + "regions_onshore.geojson",
|
2022-09-16 13:04:04 +00:00
|
|
|
regions_offshore="resources/" + RDIR + "regions_offshore.geojson",
|
|
|
|
output:
|
|
|
|
"cutouts/" + CDIR + "{cutout}.nc",
|
|
|
|
log:
|
|
|
|
"logs/" + CDIR + "build_cutout/{cutout}.log",
|
|
|
|
benchmark:
|
|
|
|
"benchmarks/" + CDIR + "build_cutout_{cutout}"
|
2020-12-03 18:50:53 +00:00
|
|
|
threads: ATLITE_NPROCESSES
|
2022-09-16 13:04:04 +00:00
|
|
|
resources:
|
|
|
|
mem_mb=ATLITE_NPROCESSES * 1000,
|
|
|
|
script:
|
|
|
|
"scripts/build_cutout.py"
|
2020-03-16 14:51:47 +00:00
|
|
|
|
2020-12-03 18:50:53 +00:00
|
|
|
|
2022-09-16 13:04:04 +00:00
|
|
|
if config["enable"].get("retrieve_cutout", True):
|
|
|
|
|
2019-11-05 11:53:21 +00:00
|
|
|
rule retrieve_cutout:
|
2022-09-16 13:04:04 +00:00
|
|
|
input:
|
|
|
|
HTTP.remote(
|
|
|
|
"zenodo.org/record/6382570/files/{cutout}.nc",
|
|
|
|
keep_local=True,
|
|
|
|
static=True,
|
|
|
|
),
|
|
|
|
output:
|
|
|
|
"cutouts/" + CDIR + "{cutout}.nc",
|
|
|
|
log:
|
|
|
|
"logs/" + CDIR + "retrieve_cutout_{cutout}.log",
|
|
|
|
resources:
|
|
|
|
mem_mb=5000,
|
2022-09-16 11:33:38 +00:00
|
|
|
run:
|
|
|
|
move(input[0], output[0])
|
2017-12-18 19:34:15 +00:00
|
|
|
|
2022-09-16 13:04:04 +00:00
|
|
|
|
|
|
|
if config["enable"].get("retrieve_cost_data", True):
|
|
|
|
|
2020-08-26 08:06:10 +00:00
|
|
|
rule retrieve_cost_data:
|
2022-09-16 13:04:04 +00:00
|
|
|
input:
|
|
|
|
HTTP.remote(
|
|
|
|
f"raw.githubusercontent.com/PyPSA/technology-data/{config['costs']['version']}/outputs/costs_{config['costs']['year']}.csv",
|
|
|
|
keep_local=True,
|
|
|
|
),
|
|
|
|
output:
|
|
|
|
COSTS,
|
|
|
|
log:
|
|
|
|
"logs/" + RDIR + "retrieve_cost_data.log",
|
|
|
|
resources:
|
|
|
|
mem_mb=5000,
|
2022-09-16 11:33:38 +00:00
|
|
|
run:
|
|
|
|
move(input[0], output[0])
|
2020-08-25 19:41:21 +00:00
|
|
|
|
2022-09-16 13:04:04 +00:00
|
|
|
|
|
|
|
if config["enable"].get("build_natura_raster", False):
|
|
|
|
|
2022-06-27 17:00:41 +00:00
|
|
|
rule build_natura_raster:
|
|
|
|
input:
|
|
|
|
natura="data/bundle/natura/Natura2000_end2015.shp",
|
2022-09-16 13:04:04 +00:00
|
|
|
cutouts=expand("cutouts/" + CDIR + "{cutouts}.nc", **config["atlite"]),
|
|
|
|
output:
|
|
|
|
"resources/" + RDIR + "natura.tiff",
|
|
|
|
resources:
|
|
|
|
mem_mb=5000,
|
|
|
|
log:
|
|
|
|
"logs/" + RDIR + "build_natura_raster.log",
|
|
|
|
script:
|
|
|
|
"scripts/build_natura_raster.py"
|
|
|
|
|
2022-06-27 17:00:41 +00:00
|
|
|
|
2022-09-16 13:04:04 +00:00
|
|
|
if config["enable"].get("retrieve_natura_raster", True):
|
2022-06-27 17:00:41 +00:00
|
|
|
|
|
|
|
rule retrieve_natura_raster:
|
2022-09-16 13:04:04 +00:00
|
|
|
input:
|
|
|
|
HTTP.remote(
|
|
|
|
"zenodo.org/record/4706686/files/natura.tiff",
|
|
|
|
keep_local=True,
|
|
|
|
static=True,
|
|
|
|
),
|
|
|
|
output:
|
|
|
|
"resources/" + RDIR + "natura.tiff",
|
|
|
|
resources:
|
|
|
|
mem_mb=5000,
|
2022-09-16 11:33:38 +00:00
|
|
|
run:
|
|
|
|
move(input[0], output[0])
|
2022-06-27 17:00:41 +00:00
|
|
|
|
|
|
|
|
2022-08-02 13:56:47 +00:00
|
|
|
rule retrieve_ship_raster:
|
2022-09-16 13:04:04 +00:00
|
|
|
input:
|
|
|
|
HTTP.remote(
|
|
|
|
"https://zenodo.org/record/6953563/files/shipdensity_global.zip",
|
|
|
|
keep_local=True,
|
|
|
|
static=True,
|
|
|
|
),
|
|
|
|
output:
|
|
|
|
"data/shipdensity_global.zip",
|
|
|
|
resources:
|
|
|
|
mem_mb=5000,
|
2022-09-16 11:33:38 +00:00
|
|
|
run:
|
|
|
|
move(input[0], output[0])
|
2022-07-28 08:38:24 +00:00
|
|
|
|
|
|
|
|
2022-08-02 13:56:47 +00:00
|
|
|
rule build_ship_raster:
|
|
|
|
input:
|
|
|
|
ship_density="data/shipdensity_global.zip",
|
2023-03-06 14:43:45 +00:00
|
|
|
cutouts=expand(
|
|
|
|
"cutouts/" + CDIR + "{cutout}.nc",
|
|
|
|
cutout=[
|
|
|
|
config["renewable"][k]["cutout"]
|
|
|
|
for k in config["electricity"]["renewable_carriers"]
|
|
|
|
],
|
|
|
|
),
|
2022-09-16 13:04:04 +00:00
|
|
|
output:
|
|
|
|
"resources/" + RDIR + "shipdensity_raster.nc",
|
|
|
|
log:
|
|
|
|
"logs/" + RDIR + "build_ship_raster.log",
|
|
|
|
resources:
|
|
|
|
mem_mb=5000,
|
|
|
|
benchmark:
|
|
|
|
"benchmarks/" + RDIR + "build_ship_raster"
|
|
|
|
script:
|
|
|
|
"scripts/build_ship_raster.py"
|
2022-08-02 13:56:47 +00:00
|
|
|
|
2022-07-28 08:38:24 +00:00
|
|
|
|
2018-01-29 21:28:33 +00:00
|
|
|
rule build_renewable_profiles:
|
2017-12-18 19:34:15 +00:00
|
|
|
input:
|
2022-09-08 07:52:00 +00:00
|
|
|
base_network="networks/" + RDIR + "base.nc",
|
2018-12-10 17:40:54 +00:00
|
|
|
corine="data/bundle/corine/g250_clc06_V18_5.tif",
|
2022-09-16 13:04:04 +00:00
|
|
|
natura=lambda w: (
|
|
|
|
"resources/" + RDIR + "natura.tiff"
|
|
|
|
if config["renewable"][w.technology]["natura"]
|
|
|
|
else []
|
|
|
|
),
|
|
|
|
gebco=lambda w: (
|
|
|
|
"data/bundle/GEBCO_2014_2D.nc"
|
2023-02-22 18:28:07 +00:00
|
|
|
if config["renewable"][w.technology].get("max_depth")
|
2022-09-16 13:04:04 +00:00
|
|
|
else []
|
|
|
|
),
|
|
|
|
ship_density=lambda w: (
|
|
|
|
"resources/" + RDIR + "shipdensity_raster.nc"
|
|
|
|
if "ship_threshold" in config["renewable"][w.technology].keys()
|
|
|
|
else []
|
|
|
|
),
|
2022-09-08 07:52:00 +00:00
|
|
|
country_shapes="resources/" + RDIR + "country_shapes.geojson",
|
|
|
|
offshore_shapes="resources/" + RDIR + "offshore_shapes.geojson",
|
2022-09-16 13:04:04 +00:00
|
|
|
regions=lambda w: (
|
|
|
|
"resources/" + RDIR + "regions_onshore.geojson"
|
|
|
|
if w.technology in ("onwind", "solar")
|
|
|
|
else "resources/" + RDIR + "regions_offshore.geojson"
|
|
|
|
),
|
|
|
|
cutout=lambda w: "cutouts/"
|
|
|
|
+ CDIR
|
|
|
|
+ config["renewable"][w.technology]["cutout"]
|
|
|
|
+ ".nc",
|
|
|
|
output:
|
|
|
|
profile="resources/" + RDIR + "profile_{technology}.nc",
|
|
|
|
log:
|
|
|
|
"logs/" + RDIR + "build_renewable_profile_{technology}.log",
|
|
|
|
benchmark:
|
|
|
|
"benchmarks/" + RDIR + "build_renewable_profiles_{technology}"
|
2020-12-03 18:50:53 +00:00
|
|
|
threads: ATLITE_NPROCESSES
|
2022-09-16 13:04:04 +00:00
|
|
|
resources:
|
|
|
|
mem_mb=ATLITE_NPROCESSES * 5000,
|
|
|
|
wildcard_constraints:
|
|
|
|
technology="(?!hydro).*", # Any technology other than hydro
|
|
|
|
script:
|
|
|
|
"scripts/build_renewable_profiles.py"
|
2017-12-18 19:34:15 +00:00
|
|
|
|
2020-12-03 18:50:53 +00:00
|
|
|
|
2022-03-18 10:13:58 +00:00
|
|
|
rule build_hydro_profile:
|
|
|
|
input:
|
2022-09-08 07:52:00 +00:00
|
|
|
country_shapes="resources/" + RDIR + "country_shapes.geojson",
|
2022-09-19 10:06:38 +00:00
|
|
|
eia_hydro_generation="data/eia_hydro_annual_generation.csv",
|
2023-03-06 14:41:02 +00:00
|
|
|
cutout=f"cutouts/" + CDIR + config["renewable"]["hydro"]["cutout"] + ".nc",
|
2022-09-19 10:06:38 +00:00
|
|
|
output:
|
|
|
|
"resources/" + RDIR + "profile_hydro.nc",
|
|
|
|
log:
|
|
|
|
"logs/" + RDIR + "build_hydro_profile.log",
|
|
|
|
resources:
|
|
|
|
mem_mb=5000,
|
|
|
|
script:
|
|
|
|
"scripts/build_hydro_profile.py"
|
2017-12-18 19:34:15 +00:00
|
|
|
|
2020-12-03 18:50:53 +00:00
|
|
|
|
2017-12-18 19:34:15 +00:00
|
|
|
rule add_electricity:
|
|
|
|
input:
|
2022-09-16 13:04:04 +00:00
|
|
|
**{
|
|
|
|
f"profile_{tech}": "resources/" + RDIR + f"profile_{tech}.nc"
|
2023-03-06 14:41:02 +00:00
|
|
|
for tech in config["electricity"]["renewable_carriers"]
|
2022-09-16 13:04:04 +00:00
|
|
|
},
|
|
|
|
**{
|
|
|
|
f"conventional_{carrier}_{attr}": fn
|
|
|
|
for carrier, d in config.get("conventional", {None: {}}).items()
|
|
|
|
for attr, fn in d.items()
|
|
|
|
if str(fn).startswith("data/")
|
|
|
|
},
|
2022-09-08 07:52:00 +00:00
|
|
|
base_network="networks/" + RDIR + "base.nc",
|
2018-10-25 14:43:24 +00:00
|
|
|
tech_costs=COSTS,
|
2022-09-08 07:52:00 +00:00
|
|
|
regions="resources/" + RDIR + "regions_onshore.geojson",
|
|
|
|
powerplants="resources/" + RDIR + "powerplants.csv",
|
2022-09-16 13:04:04 +00:00
|
|
|
hydro_capacities="data/bundle/hydro_capacities.csv",
|
|
|
|
geth_hydro_capacities="data/geth2015_hydro_capacities.csv",
|
2022-09-08 07:52:00 +00:00
|
|
|
load="resources/" + RDIR + "load.csv",
|
|
|
|
nuts3_shapes="resources/" + RDIR + "nuts3_shapes.geojson",
|
2022-09-16 13:04:04 +00:00
|
|
|
output:
|
|
|
|
"networks/" + RDIR + "elec.nc",
|
|
|
|
log:
|
|
|
|
"logs/" + RDIR + "add_electricity.log",
|
|
|
|
benchmark:
|
|
|
|
"benchmarks/" + RDIR + "add_electricity"
|
2017-12-18 19:34:15 +00:00
|
|
|
threads: 1
|
2022-09-16 13:04:04 +00:00
|
|
|
resources:
|
|
|
|
mem_mb=5000,
|
|
|
|
script:
|
|
|
|
"scripts/add_electricity.py"
|
2017-12-18 19:34:15 +00:00
|
|
|
|
2020-12-03 18:50:53 +00:00
|
|
|
|
2018-01-30 22:11:16 +00:00
|
|
|
rule simplify_network:
|
2018-01-29 21:28:33 +00:00
|
|
|
input:
|
2022-09-08 07:52:00 +00:00
|
|
|
network="networks/" + RDIR + "elec.nc",
|
2018-10-27 01:41:38 +00:00
|
|
|
tech_costs=COSTS,
|
2022-09-08 07:52:00 +00:00
|
|
|
regions_onshore="resources/" + RDIR + "regions_onshore.geojson",
|
2022-09-16 13:04:04 +00:00
|
|
|
regions_offshore="resources/" + RDIR + "regions_offshore.geojson",
|
2018-01-29 21:28:33 +00:00
|
|
|
output:
|
2022-09-08 07:52:00 +00:00
|
|
|
network="networks/" + RDIR + "elec_s{simpl}.nc",
|
|
|
|
regions_onshore="resources/" + RDIR + "regions_onshore_elec_s{simpl}.geojson",
|
|
|
|
regions_offshore="resources/" + RDIR + "regions_offshore_elec_s{simpl}.geojson",
|
|
|
|
busmap="resources/" + RDIR + "busmap_elec_s{simpl}.csv",
|
2022-09-16 13:04:04 +00:00
|
|
|
connection_costs="resources/" + RDIR + "connection_costs_s{simpl}.csv",
|
|
|
|
log:
|
|
|
|
"logs/" + RDIR + "simplify_network/elec_s{simpl}.log",
|
|
|
|
benchmark:
|
|
|
|
"benchmarks/" + RDIR + "simplify_network/elec_s{simpl}"
|
2018-01-30 22:11:16 +00:00
|
|
|
threads: 1
|
2022-09-16 13:04:04 +00:00
|
|
|
resources:
|
|
|
|
mem_mb=4000,
|
|
|
|
script:
|
|
|
|
"scripts/simplify_network.py"
|
2018-01-30 22:11:16 +00:00
|
|
|
|
2020-12-03 18:50:53 +00:00
|
|
|
|
2018-01-30 22:11:16 +00:00
|
|
|
rule cluster_network:
|
|
|
|
input:
|
2022-09-08 07:52:00 +00:00
|
|
|
network="networks/" + RDIR + "elec_s{simpl}.nc",
|
|
|
|
regions_onshore="resources/" + RDIR + "regions_onshore_elec_s{simpl}.geojson",
|
|
|
|
regions_offshore="resources/" + RDIR + "regions_offshore_elec_s{simpl}.geojson",
|
|
|
|
busmap=ancient("resources/" + RDIR + "busmap_elec_s{simpl}.csv"),
|
2022-09-16 13:04:04 +00:00
|
|
|
custom_busmap=(
|
|
|
|
"data/custom_busmap_elec_s{simpl}_{clusters}.csv"
|
|
|
|
if config["enable"].get("custom_busmap", False)
|
|
|
|
else []
|
|
|
|
),
|
|
|
|
tech_costs=COSTS,
|
2018-01-30 22:11:16 +00:00
|
|
|
output:
|
2022-09-08 07:52:00 +00:00
|
|
|
network="networks/" + RDIR + "elec_s{simpl}_{clusters}.nc",
|
2022-09-16 13:04:04 +00:00
|
|
|
regions_onshore="resources/"
|
|
|
|
+ RDIR
|
|
|
|
+ "regions_onshore_elec_s{simpl}_{clusters}.geojson",
|
|
|
|
regions_offshore="resources/"
|
|
|
|
+ RDIR
|
|
|
|
+ "regions_offshore_elec_s{simpl}_{clusters}.geojson",
|
2022-09-08 07:52:00 +00:00
|
|
|
busmap="resources/" + RDIR + "busmap_elec_s{simpl}_{clusters}.csv",
|
2022-09-16 13:04:04 +00:00
|
|
|
linemap="resources/" + RDIR + "linemap_elec_s{simpl}_{clusters}.csv",
|
|
|
|
log:
|
|
|
|
"logs/" + RDIR + "cluster_network/elec_s{simpl}_{clusters}.log",
|
|
|
|
benchmark:
|
|
|
|
"benchmarks/" + RDIR + "cluster_network/elec_s{simpl}_{clusters}"
|
2018-01-29 21:28:33 +00:00
|
|
|
threads: 1
|
2022-09-16 13:04:04 +00:00
|
|
|
resources:
|
|
|
|
mem_mb=6000,
|
|
|
|
script:
|
|
|
|
"scripts/cluster_network.py"
|
2018-01-29 21:28:33 +00:00
|
|
|
|
2019-11-19 18:36:28 +00:00
|
|
|
|
|
|
|
rule add_extra_components:
|
|
|
|
input:
|
2022-09-08 07:52:00 +00:00
|
|
|
network="networks/" + RDIR + "elec_s{simpl}_{clusters}.nc",
|
2019-11-19 18:36:28 +00:00
|
|
|
tech_costs=COSTS,
|
2022-09-16 13:04:04 +00:00
|
|
|
output:
|
|
|
|
"networks/" + RDIR + "elec_s{simpl}_{clusters}_ec.nc",
|
|
|
|
log:
|
|
|
|
"logs/" + RDIR + "add_extra_components/elec_s{simpl}_{clusters}.log",
|
|
|
|
benchmark:
|
|
|
|
"benchmarks/" + RDIR + "add_extra_components/elec_s{simpl}_{clusters}_ec"
|
2019-11-19 18:36:28 +00:00
|
|
|
threads: 1
|
2022-09-16 13:04:04 +00:00
|
|
|
resources:
|
|
|
|
mem_mb=3000,
|
|
|
|
script:
|
|
|
|
"scripts/add_extra_components.py"
|
2019-11-19 18:36:28 +00:00
|
|
|
|
|
|
|
|
2018-01-29 21:28:33 +00:00
|
|
|
rule prepare_network:
|
2022-09-16 13:04:04 +00:00
|
|
|
input:
|
|
|
|
"networks/" + RDIR + "elec_s{simpl}_{clusters}_ec.nc",
|
|
|
|
tech_costs=COSTS,
|
|
|
|
output:
|
|
|
|
"networks/" + RDIR + "elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
|
|
|
|
log:
|
|
|
|
"logs/" + RDIR + "prepare_network/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.log",
|
|
|
|
benchmark:
|
|
|
|
(
|
|
|
|
"benchmarks/"
|
|
|
|
+ RDIR
|
|
|
|
+ "prepare_network/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}"
|
|
|
|
)
|
2018-01-29 21:28:33 +00:00
|
|
|
threads: 1
|
2022-09-16 13:04:04 +00:00
|
|
|
resources:
|
|
|
|
mem_mb=4000,
|
|
|
|
script:
|
|
|
|
"scripts/prepare_network.py"
|
2018-01-29 21:28:33 +00:00
|
|
|
|
2020-12-03 18:50:53 +00:00
|
|
|
|
2018-02-19 09:03:25 +00:00
|
|
|
def memory(w):
|
2022-09-16 13:04:04 +00:00
|
|
|
factor = 3.0
|
|
|
|
for o in w.opts.split("-"):
|
|
|
|
m = re.match(r"^(\d+)h$", o, re.IGNORECASE)
|
2018-10-22 21:28:56 +00:00
|
|
|
if m is not None:
|
|
|
|
factor /= int(m.group(1))
|
|
|
|
break
|
2022-09-16 13:04:04 +00:00
|
|
|
for o in w.opts.split("-"):
|
|
|
|
m = re.match(r"^(\d+)seg$", o, re.IGNORECASE)
|
2020-12-03 15:02:21 +00:00
|
|
|
if m is not None:
|
|
|
|
factor *= int(m.group(1)) / 8760
|
|
|
|
break
|
2022-09-16 13:04:04 +00:00
|
|
|
if w.clusters.endswith("m"):
|
2018-10-22 21:28:56 +00:00
|
|
|
return int(factor * (18000 + 180 * int(w.clusters[:-1])))
|
2022-03-02 13:22:16 +00:00
|
|
|
elif w.clusters == "all":
|
|
|
|
return int(factor * (18000 + 180 * 4000))
|
2018-02-19 09:03:25 +00:00
|
|
|
else:
|
2019-02-06 10:46:39 +00:00
|
|
|
return int(factor * (10000 + 195 * int(w.clusters)))
|
2020-12-03 18:50:53 +00:00
|
|
|
|
2018-02-10 16:19:46 +00:00
|
|
|
|
2017-12-18 19:34:15 +00:00
|
|
|
rule solve_network:
|
2022-09-16 13:04:04 +00:00
|
|
|
input:
|
|
|
|
"networks/" + RDIR + "elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
|
|
|
|
output:
|
|
|
|
"results/networks/" + RDIR + "elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
|
2017-12-18 19:34:15 +00:00
|
|
|
log:
|
2022-09-16 13:04:04 +00:00
|
|
|
solver=normpath(
|
|
|
|
"logs/"
|
|
|
|
+ RDIR
|
|
|
|
+ "solve_network/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_solver.log"
|
|
|
|
),
|
|
|
|
python="logs/"
|
|
|
|
+ RDIR
|
|
|
|
+ "solve_network/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_python.log",
|
|
|
|
memory="logs/"
|
|
|
|
+ RDIR
|
|
|
|
+ "solve_network/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_memory.log",
|
|
|
|
benchmark:
|
|
|
|
"benchmarks/" + RDIR + "solve_network/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}"
|
2017-12-18 19:34:15 +00:00
|
|
|
threads: 4
|
2022-09-16 13:04:04 +00:00
|
|
|
resources:
|
|
|
|
mem_mb=memory,
|
|
|
|
shadow:
|
|
|
|
"minimal"
|
|
|
|
script:
|
|
|
|
"scripts/solve_network.py"
|
2017-12-18 19:34:15 +00:00
|
|
|
|
2020-12-03 18:50:53 +00:00
|
|
|
|
2018-02-19 09:17:49 +00:00
|
|
|
rule solve_operations_network:
|
|
|
|
input:
|
2022-09-08 07:52:00 +00:00
|
|
|
unprepared="networks/" + RDIR + "elec_s{simpl}_{clusters}_ec.nc",
|
2022-09-16 13:04:04 +00:00
|
|
|
optimized="results/networks/"
|
|
|
|
+ RDIR
|
|
|
|
+ "elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
|
|
|
|
output:
|
|
|
|
"results/networks/" + RDIR + "elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_op.nc",
|
2018-02-19 09:17:49 +00:00
|
|
|
log:
|
2022-09-16 13:04:04 +00:00
|
|
|
solver=normpath(
|
|
|
|
"logs/"
|
|
|
|
+ RDIR
|
|
|
|
+ "solve_operations_network/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_op_solver.log"
|
|
|
|
),
|
|
|
|
python="logs/"
|
|
|
|
+ RDIR
|
|
|
|
+ "solve_operations_network/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_op_python.log",
|
|
|
|
memory="logs/"
|
|
|
|
+ RDIR
|
|
|
|
+ "solve_operations_network/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_op_memory.log",
|
|
|
|
benchmark:
|
|
|
|
(
|
|
|
|
"benchmarks/"
|
|
|
|
+ RDIR
|
|
|
|
+ "solve_operations_network/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}"
|
|
|
|
)
|
2018-02-19 09:17:49 +00:00
|
|
|
threads: 4
|
2022-09-16 13:04:04 +00:00
|
|
|
resources:
|
|
|
|
mem_mb=(lambda w: 5000 + 372 * int(w.clusters)),
|
|
|
|
shadow:
|
|
|
|
"minimal"
|
|
|
|
script:
|
|
|
|
"scripts/solve_operations_network.py"
|
2018-02-19 09:17:49 +00:00
|
|
|
|
2020-12-03 18:50:53 +00:00
|
|
|
|
2017-12-18 19:34:15 +00:00
|
|
|
rule plot_network:
|
|
|
|
input:
|
2022-09-16 13:04:04 +00:00
|
|
|
network="results/networks/"
|
|
|
|
+ RDIR
|
|
|
|
+ "elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
|
|
|
|
tech_costs=COSTS,
|
2017-12-18 19:34:15 +00:00
|
|
|
output:
|
2022-09-16 13:04:04 +00:00
|
|
|
only_map="results/plots/"
|
|
|
|
+ RDIR
|
|
|
|
+ "elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{attr}.{ext}",
|
|
|
|
ext="results/plots/"
|
|
|
|
+ RDIR
|
|
|
|
+ "elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{attr}_ext.{ext}",
|
|
|
|
log:
|
|
|
|
"logs/"
|
|
|
|
+ RDIR
|
|
|
|
+ "plot_network/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{attr}_{ext}.log",
|
|
|
|
script:
|
|
|
|
"scripts/plot_network.py"
|
2017-12-18 19:34:15 +00:00
|
|
|
|
2020-12-03 18:50:53 +00:00
|
|
|
|
2019-02-03 12:50:05 +00:00
|
|
|
def input_make_summary(w):
|
2018-10-26 08:28:54 +00:00
|
|
|
# It's mildly hacky to include the separate costs input as first entry
|
2019-02-10 15:08:39 +00:00
|
|
|
if w.ll.endswith("all"):
|
|
|
|
ll = config["scenario"]["ll"]
|
|
|
|
if len(w.ll) == 4:
|
|
|
|
ll = [l for l in ll if l[0] == w.ll[0]]
|
|
|
|
else:
|
|
|
|
ll = w.ll
|
2022-09-16 13:04:04 +00:00
|
|
|
return [COSTS] + expand(
|
|
|
|
"results/networks/" + RDIR + "elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
|
|
|
|
ll=ll,
|
|
|
|
**{
|
|
|
|
k: config["scenario"][k] if getattr(w, k) == "all" else getattr(w, k)
|
|
|
|
for k in ["simpl", "clusters", "opts"]
|
|
|
|
}
|
|
|
|
)
|
2017-12-18 19:34:15 +00:00
|
|
|
|
2020-12-03 18:50:53 +00:00
|
|
|
|
2018-10-26 08:28:54 +00:00
|
|
|
rule make_summary:
|
2022-09-16 13:04:04 +00:00
|
|
|
input:
|
|
|
|
input_make_summary,
|
|
|
|
output:
|
|
|
|
directory(
|
|
|
|
"results/summaries/"
|
|
|
|
+ RDIR
|
|
|
|
+ "elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{country}"
|
|
|
|
),
|
|
|
|
log:
|
|
|
|
"logs/"
|
|
|
|
+ RDIR
|
|
|
|
+ "make_summary/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{country}.log",
|
|
|
|
resources:
|
2022-12-27 11:16:02 +00:00
|
|
|
mem_mb=1500,
|
2022-09-16 13:04:04 +00:00
|
|
|
script:
|
|
|
|
"scripts/make_summary.py"
|
2017-12-18 19:34:15 +00:00
|
|
|
|
2020-12-03 18:50:53 +00:00
|
|
|
|
2018-10-26 08:28:54 +00:00
|
|
|
rule plot_summary:
|
2022-09-16 13:04:04 +00:00
|
|
|
input:
|
|
|
|
"results/summaries/"
|
|
|
|
+ RDIR
|
|
|
|
+ "elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{country}",
|
|
|
|
output:
|
|
|
|
"results/plots/"
|
|
|
|
+ RDIR
|
|
|
|
+ "summary_{summary}_elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{country}.{ext}",
|
|
|
|
log:
|
|
|
|
"logs/"
|
|
|
|
+ RDIR
|
|
|
|
+ "plot_summary/{summary}_elec_s{simpl}_{clusters}_ec_l{ll}_{opts}_{country}_{ext}.log",
|
|
|
|
resources:
|
2022-12-27 11:16:02 +00:00
|
|
|
mem_mb=1500,
|
2022-09-16 13:04:04 +00:00
|
|
|
script:
|
|
|
|
"scripts/plot_summary.py"
|
2017-12-18 19:34:15 +00:00
|
|
|
|
2020-12-03 18:50:53 +00:00
|
|
|
|
|
|
|
def input_plot_p_nom_max(w):
|
2022-09-16 13:04:04 +00:00
|
|
|
return [
|
|
|
|
(
|
|
|
|
"results/networks/"
|
|
|
|
+ RDIR
|
|
|
|
+ "elec_s{simpl}{maybe_cluster}.nc".format(
|
|
|
|
maybe_cluster=("" if c == "full" else ("_" + c)), **w
|
|
|
|
)
|
|
|
|
)
|
|
|
|
for c in w.clusts.split(",")
|
|
|
|
]
|
2020-12-03 18:50:53 +00:00
|
|
|
|
|
|
|
|
2019-02-03 13:22:12 +00:00
|
|
|
rule plot_p_nom_max:
|
2022-09-16 13:04:04 +00:00
|
|
|
input:
|
|
|
|
input_plot_p_nom_max,
|
|
|
|
output:
|
|
|
|
"results/plots/"
|
|
|
|
+ RDIR
|
|
|
|
+ "elec_s{simpl}_cum_p_nom_max_{clusts}_{techs}_{country}.{ext}",
|
|
|
|
log:
|
|
|
|
"logs/"
|
|
|
|
+ RDIR
|
|
|
|
+ "plot_p_nom_max/elec_s{simpl}_{clusts}_{techs}_{country}_{ext}.log",
|
|
|
|
resources:
|
2022-12-27 11:16:02 +00:00
|
|
|
mem_mb=1500,
|
2022-09-16 13:04:04 +00:00
|
|
|
script:
|
|
|
|
"scripts/plot_p_nom_max.py"
|