pypsa-eur/scripts/build_cutout.py

50 lines
1.0 KiB
Python
Raw Normal View History

"""
2019-08-11 20:34:18 +00:00
Create cutouts with `atlite <https://atlite.readthedocs.io/en/latest/>`_.
2019-08-11 09:40:47 +00:00
Relevant Settings
-----------------
2019-08-11 11:17:36 +00:00
.. code:: yaml
atlite:
nprocesses:
cutouts:
{cutout}:
.. seealso::
Documentation of the configuration file ``config.yaml`` at
:ref:`atlite_cf`
2019-08-11 09:40:47 +00:00
Inputs
------
2019-08-11 20:34:18 +00:00
*None*
2019-08-11 09:40:47 +00:00
Outputs
-------
2019-08-11 20:34:18 +00:00
- ``cutouts/{cutout}``:
2019-08-11 09:40:47 +00:00
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))