Generate cutouts on-demand
This commit is contained in:
parent
6866ce6b06
commit
c6a4de7469
11
Snakefile
11
Snakefile
@ -77,8 +77,16 @@ rule build_bus_regions:
|
|||||||
resources: mem_mb=1000
|
resources: mem_mb=1000
|
||||||
script: "scripts/build_bus_regions.py"
|
script: "scripts/build_bus_regions.py"
|
||||||
|
|
||||||
|
rule build_cutout:
|
||||||
|
output: "cutouts/{cutout}"
|
||||||
|
resources: mem_mb=5000
|
||||||
|
threads: config['atlite'].get('nprocesses', 4)
|
||||||
|
benchmark: "benchmarks/build_cutout_{cutout}"
|
||||||
|
script: "scripts/build_cutout.py"
|
||||||
|
|
||||||
rule build_renewable_potentials:
|
rule build_renewable_potentials:
|
||||||
input:
|
input:
|
||||||
|
cutout=lambda wildcards: "cutouts/" + config["renewable"][wildcards.technology]['cutout'],
|
||||||
corine="data/bundle/corine/g250_clc06_V18_5.tif",
|
corine="data/bundle/corine/g250_clc06_V18_5.tif",
|
||||||
natura="data/bundle/natura/Natura2000_end2015.shp"
|
natura="data/bundle/natura/Natura2000_end2015.shp"
|
||||||
output: "resources/potentials_{technology}.nc"
|
output: "resources/potentials_{technology}.nc"
|
||||||
@ -92,7 +100,8 @@ rule build_renewable_profiles:
|
|||||||
potentials="resources/potentials_{technology}.nc",
|
potentials="resources/potentials_{technology}.nc",
|
||||||
regions=lambda wildcards: ("resources/regions_onshore.geojson"
|
regions=lambda wildcards: ("resources/regions_onshore.geojson"
|
||||||
if wildcards.technology in ('onwind', 'solar')
|
if wildcards.technology in ('onwind', 'solar')
|
||||||
else "resources/regions_offshore.geojson")
|
else "resources/regions_offshore.geojson"),
|
||||||
|
cutout=lambda wildcards: "cutouts/" + config["renewable"][wildcards.technology]['cutout'],
|
||||||
output:
|
output:
|
||||||
profile="resources/profile_{technology}.nc",
|
profile="resources/profile_{technology}.nc",
|
||||||
resources: mem_mb=5000
|
resources: mem_mb=5000
|
||||||
|
22
config.yaml
22
config.yaml
@ -30,9 +30,25 @@ electricity:
|
|||||||
|
|
||||||
conventional_carriers: [nuclear, oil, OCGT, CCGT, coal, lignite, geothermal, biomass]
|
conventional_carriers: [nuclear, oil, OCGT, CCGT, coal, lignite, geothermal, biomass]
|
||||||
|
|
||||||
|
atlite:
|
||||||
|
cutout_directory: 'cutouts'
|
||||||
|
nprocesses: 1
|
||||||
|
cutouts:
|
||||||
|
europe-2013-era5:
|
||||||
|
module: era5
|
||||||
|
xs: [-12., 35.]
|
||||||
|
ys: [72., 33.]
|
||||||
|
years: [2013, 2013]
|
||||||
|
europe-2013-sarah:
|
||||||
|
module: sarah
|
||||||
|
resolution: 0.2
|
||||||
|
xs: [-12., 42.]
|
||||||
|
ys: [65., 33.]
|
||||||
|
years: [2013, 2013]
|
||||||
|
|
||||||
renewable:
|
renewable:
|
||||||
onwind:
|
onwind:
|
||||||
cutout: europe-2012-2016-era5
|
cutout: europe-2013-era5
|
||||||
resource:
|
resource:
|
||||||
method: wind
|
method: wind
|
||||||
turbine: Vestas_V112_3MW
|
turbine: Vestas_V112_3MW
|
||||||
@ -51,7 +67,7 @@ renewable:
|
|||||||
distance_grid_codes: [1, 2, 3, 4, 5, 6]
|
distance_grid_codes: [1, 2, 3, 4, 5, 6]
|
||||||
natura: true
|
natura: true
|
||||||
offwind:
|
offwind:
|
||||||
cutout: europe-2012-2016-era5
|
cutout: europe-2013-era5
|
||||||
resource:
|
resource:
|
||||||
method: wind
|
method: wind
|
||||||
turbine: NREL_ReferenceTurbine_5MW_offshore
|
turbine: NREL_ReferenceTurbine_5MW_offshore
|
||||||
@ -63,7 +79,7 @@ renewable:
|
|||||||
grid_codes: [44, 255]
|
grid_codes: [44, 255]
|
||||||
natura: true
|
natura: true
|
||||||
solar:
|
solar:
|
||||||
cutout: europe-2013-2015-sarah
|
cutout: europe-2013-sarah
|
||||||
resource:
|
resource:
|
||||||
method: pv
|
method: pv
|
||||||
panel: CSi
|
panel: CSi
|
||||||
|
12
scripts/build_cutout.py
Normal file
12
scripts/build_cutout.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import os
|
||||||
|
import atlite
|
||||||
|
import logging
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
logging.basicConfig(level=snakemake.config['logging_level'])
|
||||||
|
|
||||||
|
cutout = atlite.Cutout(snakemake.wildcards.cutout,
|
||||||
|
cutout_dir=os.path.dirname(snakemake.output.cutout),
|
||||||
|
**snakemake.config['atlite']['cutouts'][snakemake.wildcards.cutout])
|
||||||
|
|
||||||
|
cutout.prepare(nprocesses=snakemake.config['atlite'].get('nprocesses', 4))
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import os
|
||||||
import atlite
|
import atlite
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import geopandas as gpd
|
import geopandas as gpd
|
||||||
@ -8,7 +9,8 @@ import logging
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logger.setLevel(level=snakemake.config['logging_level'])
|
logger.setLevel(level=snakemake.config['logging_level'])
|
||||||
|
|
||||||
cutout = atlite.Cutout(snakemake.config['renewable']['hydro']['cutout'])
|
cutout = atlite.Cutout(snakemake.config['renewable']['hydro']['cutout'],
|
||||||
|
cutout_dir=os.path.dirname(snakemake.input.cutout))
|
||||||
|
|
||||||
countries = snakemake.config['countries']
|
countries = snakemake.config['countries']
|
||||||
country_shapes = gpd.read_file(snakemake.input.country_shapes).set_index('id')['geometry'].reindex(countries)
|
country_shapes = gpd.read_file(snakemake.input.country_shapes).set_index('id')['geometry'].reindex(countries)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
import atlite
|
import atlite
|
||||||
import xarray as xr
|
import xarray as xr
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
@ -6,7 +7,8 @@ from vresutils import landuse as vlanduse
|
|||||||
|
|
||||||
config = snakemake.config['renewable'][snakemake.wildcards.technology]
|
config = snakemake.config['renewable'][snakemake.wildcards.technology]
|
||||||
|
|
||||||
cutout = atlite.Cutout(config['cutout'])
|
cutout = atlite.Cutout(config['cutout'],
|
||||||
|
cutout_dir=os.path.dirname(snakemake.input.cutout))
|
||||||
|
|
||||||
total_capacity = config['capacity_per_sqm'] * vlanduse._cutout_cell_areas(cutout)
|
total_capacity = config['capacity_per_sqm'] * vlanduse._cutout_cell_areas(cutout)
|
||||||
potentials = xr.DataArray(total_capacity *
|
potentials = xr.DataArray(total_capacity *
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import os
|
||||||
import atlite
|
import atlite
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import xarray as xr
|
import xarray as xr
|
||||||
@ -18,7 +19,9 @@ params = dict(years=slice(*time.year[[0, -1]]), months=slice(*time.month[[0, -1]
|
|||||||
regions = gpd.read_file(snakemake.input.regions).set_index('name')
|
regions = gpd.read_file(snakemake.input.regions).set_index('name')
|
||||||
regions.index.name = 'bus'
|
regions.index.name = 'bus'
|
||||||
|
|
||||||
cutout = atlite.Cutout(config['cutout'], **params)
|
cutout = atlite.Cutout(config['cutout'],
|
||||||
|
cutout_dir=os.path.dirname(snakemake.input.cutout),
|
||||||
|
**params)
|
||||||
|
|
||||||
# Potentials
|
# Potentials
|
||||||
potentials = xr.open_dataarray(snakemake.input.potentials)
|
potentials = xr.open_dataarray(snakemake.input.potentials)
|
||||||
|
Loading…
Reference in New Issue
Block a user