Skip to content

Commit

Permalink
Add country parser and option to disable subworkflow
Browse files Browse the repository at this point in the history
  • Loading branch information
davide-f committed Feb 6, 2024
1 parent 7927a21 commit d59166b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
32 changes: 24 additions & 8 deletions Snakefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import sys

sys.path.append("pypsa-earth/scripts")

from os.path import exists
from shutil import copyfile, move
from scripts.helpers import get_last_commit_message

from snakemake.remote.HTTP import RemoteProvider as HTTPRemoteProvider
from _helpers import create_country_list

HTTP = HTTPRemoteProvider()

Expand All @@ -13,7 +18,10 @@ if not exists("config.yaml"):
configfile: "config.yaml"


PYPSAEARTH_FOLDER = "./pypsa-earth"
PYPSAEARTH_FOLDER = "pypsa-earth"

# convert country list according to the desired region
config["countries"] = create_country_list(config["countries"])


SDIR = config["summary_dir"] + config["run"]
Expand Down Expand Up @@ -41,13 +49,21 @@ wildcard_constraints:
h2export="[0-9]+m?|all",


subworkflow pypsaearth:
workdir:
PYPSAEARTH_FOLDER
snakefile:
PYPSAEARTH_FOLDER + "/Snakefile"
configfile:
"./config.pypsa-earth.yaml"
if not config.get("disable_subworkflow", False):

subworkflow pypsaearth:
workdir:
PYPSAEARTH_FOLDER
snakefile:
PYPSAEARTH_FOLDER + "/Sddnakefile"
configfile:
"./config.pypsa-earth.yaml"


if config.get("disable_subworkflow", False):

def pypsaearth(path):
return PYPSAEARTH_FOLDER + "/" + path


if config["enable"].get("retrieve_cost_data", True):
Expand Down
3 changes: 3 additions & 0 deletions config.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ run: test_h2_cons_yearly

foresight: overnight

# option to disable the subworkflow to ease the analyses
disable_subworkflow: false

scenario:
simpl: # only relevant for PyPSA-Eur
- ""
Expand Down
2 changes: 1 addition & 1 deletion config.pypsa-earth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ countries: ["Africa"]
# Can be replaced by country ["NG", "BJ"], continent ["Africa"] or user-specific region, see more at https://pypsa-earth.readthedocs.io/en/latest/configuration.html#top-level-configuration

enable:
retrieve_databundle: false # Recommended 'true', for the first run. Otherwise data might be missing.
retrieve_databundle: true # Recommended 'true', for the first run. Otherwise data might be missing.
retrieve_cost_data: true # true: retrieves cost data from technology data and saves in resources/costs.csv, false: uses cost data in data/costs.csv
download_osm_data: true # If 'true', OpenStreetMap data will be downloaded for the above given countries
build_natura_raster: false # If True, then an exclusion raster will be build
Expand Down
3 changes: 3 additions & 0 deletions test/config.test1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ run: test3

foresight: overnight

# option to disable the subworkflow to ease the analyses
disable_subworkflow: false

scenario:
simpl: # only relevant for PyPSA-Eur
- ""
Expand Down

0 comments on commit d59166b

Please sign in to comment.