From 5ea60a1ee09f88a4e831242acdd1593d21829024 Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Thu, 3 Oct 2019 12:32:49 +0200 Subject: [PATCH] modify to run without GEBCO and without hydro --- Snakefile | 29 +++++++++++++++++------------ scripts/add_electricity.py | 3 ++- scripts/build_renewable_profiles.py | 5 +++-- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/Snakefile b/Snakefile index c24bd250..b8cba3b9 100644 --- a/Snakefile +++ b/Snakefile @@ -93,7 +93,7 @@ rule build_bus_regions: script: "scripts/build_bus_regions.py" rule build_cutout: - output: "cutouts/{cutout}" + output: directory("cutouts/{cutout}") resources: mem=config['atlite'].get('nprocesses', 4) * 1000 threads: config['atlite'].get('nprocesses', 4) benchmark: "benchmarks/build_cutout_{cutout}" @@ -110,7 +110,9 @@ rule build_renewable_profiles: base_network="networks/base.nc", corine="data/bundle/corine/g250_clc06_V18_5.tif", natura="resources/natura.tiff", - gebco="data/bundle/GEBCO_2014_2D.nc", + gebco=lambda wildcards: ("data/bundle/GEBCO_2014_2D.nc" + if "max_depth" in config["renewable"][wildcards.technology].keys() + else []), country_shapes='resources/country_shapes.geojson', offshore_shapes='resources/offshore_shapes.geojson', regions=lambda wildcards: ("resources/regions_onshore.geojson" @@ -124,15 +126,16 @@ rule build_renewable_profiles: # group: 'feedin_preparation' script: "scripts/build_renewable_profiles.py" -rule build_hydro_profile: - input: - country_shapes='resources/country_shapes.geojson', - eia_hydro_generation='data/bundle/EIA_hydro_generation_2000_2014.csv', - cutout="cutouts/" + config["renewable"]['hydro']['cutout'] - output: 'resources/profile_hydro.nc' - resources: mem=5000 - # group: 'feedin_preparation' - script: 'scripts/build_hydro_profile.py' +if 'hydro' in config['renewable'].keys(): + rule build_hydro_profile: + input: + country_shapes='resources/country_shapes.geojson', + eia_hydro_generation='data/bundle/EIA_hydro_generation_2000_2014.csv', + cutout="cutouts/" + config["renewable"]['hydro']['cutout'] + output: 'resources/profile_hydro.nc' + resources: mem=5000 + # group: 'feedin_preparation' + script: 'scripts/build_hydro_profile.py' rule add_electricity: input: @@ -305,7 +308,9 @@ rule build_country_flh: base_network="networks/base.nc", corine="data/bundle/corine/g250_clc06_V18_5.tif", natura="resources/natura.tiff", - gebco="data/bundle/GEBCO_2014_2D.nc", + gebco=lambda wildcards: ("data/bundle/GEBCO_2014_2D.nc" + if "max_depth" in config["renewable"][wildcards.technology].keys() + else []), country_shapes='resources/country_shapes.geojson', offshore_shapes='resources/offshore_shapes.geojson', pietzker="data/pietzker2014.xlsx", diff --git a/scripts/add_electricity.py b/scripts/add_electricity.py index b088453f..7d0dc394 100644 --- a/scripts/add_electricity.py +++ b/scripts/add_electricity.py @@ -600,7 +600,8 @@ if __name__ == "__main__": attach_conventional_generators(n, costs, ppl) attach_wind_and_solar(n, costs) - attach_hydro(n, costs, ppl) + if 'hydro' in snakemake.config['renewable']: + attach_hydro(n, costs, ppl) attach_extendable_generators(n, costs, ppl) attach_storage(n, costs) diff --git a/scripts/build_renewable_profiles.py b/scripts/build_renewable_profiles.py index 94411c15..dc1252ae 100644 --- a/scripts/build_renewable_profiles.py +++ b/scripts/build_renewable_profiles.py @@ -184,8 +184,9 @@ def init_globals(bounds_xXyY, n_dx, n_dy, n_config, n_paths): config = n_config paths = n_paths - gebco = gk.raster.loadRaster(paths["gebco"]) - gebco.SetProjection(gk.srs.loadSRS(4326).ExportToWkt()) + if "max_depth" in config: + gebco = gk.raster.loadRaster(paths["gebco"]) + gebco.SetProjection(gk.srs.loadSRS(4326).ExportToWkt()) clc = gk.raster.loadRaster(paths["corine"]) clc.SetProjection(gk.srs.loadSRS(3035).ExportToWkt())