Move logic to retrieve.smk

This commit is contained in:
euronion 2023-07-14 08:53:39 +02:00
parent 30a81a559f
commit 730b320596
2 changed files with 56 additions and 42 deletions

View File

@ -48,10 +48,7 @@ wildcard_constraints:
include: "rules/common.smk" include: "rules/common.smk"
include: "rules/collect.smk" include: "rules/collect.smk"
if (config["enable"].get("retrieve","auto") == "auto" and has_internet_access())or config["enable"]["retrieve"] is True: include: "rules/retrieve.smk"
include: "rules/retrieve.smk"
else:
print("Datafile downloads disabled in config[retrieve] or no internet access.")
include: "rules/build_electricity.smk" include: "rules/build_electricity.smk"
include: "rules/build_sector.smk" include: "rules/build_sector.smk"
include: "rules/solve_electricity.smk" include: "rules/solve_electricity.smk"

View File

@ -2,7 +2,14 @@
# #
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
if config["enable"].get("retrieve_databundle", True): if config["enable"].get("retrieve", "auto") == "auto":
config["enable"]["retrieve"] = has_internet_access()
if config["enable"]["retrieve"] is False:
print("Datafile downloads disabled in config[retrieve] or no internet access.")
if config["enable"]["retrieve"] and config["enable"].get("retrieve_databundle", True):
datafiles = [ datafiles = [
"ch_cantons.csv", "ch_cantons.csv",
"je-e-21.03.02.xls", "je-e-21.03.02.xls",
@ -32,7 +39,7 @@ if config["enable"].get("retrieve_databundle", True):
"../scripts/retrieve_databundle.py" "../scripts/retrieve_databundle.py"
if config["enable"].get("retrieve_cutout", True): if config["enable"]["retrieve"] and config["enable"].get("retrieve_cutout", True):
rule retrieve_cutout: rule retrieve_cutout:
input: input:
@ -51,7 +58,7 @@ if config["enable"].get("retrieve_cutout", True):
move(input[0], output[0]) move(input[0], output[0])
if config["enable"].get("retrieve_cost_data", True): if config["enable"]["retrieve"] and config["enable"].get("retrieve_cost_data", True):
rule retrieve_cost_data: rule retrieve_cost_data:
input: input:
@ -73,7 +80,9 @@ if config["enable"].get("retrieve_cost_data", True):
move(input[0], output[0]) move(input[0], output[0])
if config["enable"].get("retrieve_natura_raster", True): if config["enable"]["retrieve"] and config["enable"].get(
"retrieve_natura_raster", True
):
rule retrieve_natura_raster: rule retrieve_natura_raster:
input: input:
@ -93,7 +102,9 @@ if config["enable"].get("retrieve_natura_raster", True):
move(input[0], output[0]) move(input[0], output[0])
if config["enable"].get("retrieve_sector_databundle", True): if config["enable"]["retrieve"] and config["enable"].get(
"retrieve_sector_databundle", True
):
datafiles = [ datafiles = [
"data/eea/UNFCCC_v23.csv", "data/eea/UNFCCC_v23.csv",
"data/switzerland-sfoe/switzerland-new_format.csv", "data/switzerland-sfoe/switzerland-new_format.csv",
@ -120,7 +131,9 @@ if config["enable"].get("retrieve_sector_databundle", True):
"../scripts/retrieve_sector_databundle.py" "../scripts/retrieve_sector_databundle.py"
if config["sector"]["gas_network"] or config["sector"]["H2_retrofit"]: if config["enable"]["retrieve"] and (
config["sector"]["gas_network"] or config["sector"]["H2_retrofit"]
):
datafiles = [ datafiles = [
"IGGIELGN_LNGs.geojson", "IGGIELGN_LNGs.geojson",
"IGGIELGN_BorderPoints.geojson", "IGGIELGN_BorderPoints.geojson",
@ -140,37 +153,41 @@ if config["sector"]["gas_network"] or config["sector"]["H2_retrofit"]:
"../scripts/retrieve_gas_infrastructure_data.py" "../scripts/retrieve_gas_infrastructure_data.py"
rule retrieve_electricity_demand: if config["enable"]["retrieve"]:
input:
HTTP.remote( rule retrieve_electricity_demand:
"data.open-power-system-data.org/time_series/2019-06-05/time_series_60min_singleindex.csv", input:
keep_local=True, HTTP.remote(
static=True, "data.open-power-system-data.org/time_series/2019-06-05/time_series_60min_singleindex.csv",
), keep_local=True,
output: static=True,
"data/load_raw.csv", ),
log: output:
LOGS + "retrieve_electricity_demand.log", "data/load_raw.csv",
resources: log:
mem_mb=5000, LOGS + "retrieve_electricity_demand.log",
retries: 2 resources:
run: mem_mb=5000,
move(input[0], output[0]) retries: 2
run:
move(input[0], output[0])
rule retrieve_ship_raster: if config["enable"]["retrieve"]:
input:
HTTP.remote( rule retrieve_ship_raster:
"https://zenodo.org/record/6953563/files/shipdensity_global.zip", input:
keep_local=True, HTTP.remote(
static=True, "https://zenodo.org/record/6953563/files/shipdensity_global.zip",
), keep_local=True,
output: static=True,
"data/shipdensity_global.zip", ),
log: output:
LOGS + "retrieve_ship_raster.log", "data/shipdensity_global.zip",
resources: log:
mem_mb=5000, LOGS + "retrieve_ship_raster.log",
retries: 2 resources:
run: mem_mb=5000,
move(input[0], output[0]) retries: 2
run:
move(input[0], output[0])