pypsa-eur/scripts/build_cutout.py

35 lines
795 B
Python
Raw Normal View History

"""
Create cutouts configured in `atlite` config section
2019-08-11 09:40:47 +00:00
Relevant Settings
-----------------
Inputs
------
Outputs
-------
Description
-----------
"""
2018-08-03 09:54:28 +00:00
import os
import atlite
import logging
logger = logging.getLogger(__name__)
if __name__ == "__main__":
logging.basicConfig(level=snakemake.config['logging_level'])
2018-08-03 09:54:28 +00:00
cutout_params = snakemake.config['atlite']['cutouts'][snakemake.wildcards.cutout]
for p in ('xs', 'ys', 'years', 'months'):
if p in cutout_params:
cutout_params[p] = slice(*cutout_params[p])
2018-08-03 10:46:42 +00:00
cutout = atlite.Cutout(snakemake.wildcards.cutout,
cutout_dir=os.path.dirname(snakemake.output[0]),
**cutout_params)
2018-08-03 09:54:28 +00:00
cutout.prepare(nprocesses=snakemake.config['atlite'].get('nprocesses', 4))