2018-01-29 21:28:33 +00:00
|
|
|
#!/usr/bin/env python
|
2020-05-29 07:50:55 +00:00
|
|
|
|
|
|
|
# SPDX-FileCopyrightText: : 2017-2020 The PyPSA-Eur Authors
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2019-08-08 13:02:28 +00:00
|
|
|
"""
|
2019-08-11 20:34:18 +00:00
|
|
|
Build hydroelectric inflow time-series for each country.
|
2019-08-08 13:02:28 +00:00
|
|
|
|
2019-08-11 09:40:47 +00:00
|
|
|
Relevant Settings
|
|
|
|
-----------------
|
|
|
|
|
2019-08-11 11:17:36 +00:00
|
|
|
.. code:: yaml
|
|
|
|
|
|
|
|
countries:
|
|
|
|
|
|
|
|
renewable:
|
|
|
|
hydro:
|
|
|
|
cutout:
|
|
|
|
clip_min_inflow:
|
|
|
|
|
2019-11-14 16:50:24 +00:00
|
|
|
.. seealso::
|
2019-08-13 08:03:46 +00:00
|
|
|
Documentation of the configuration file ``config.yaml`` at
|
|
|
|
:ref:`toplevel_cf`, :ref:`renewable_cf`
|
|
|
|
|
2019-08-11 09:40:47 +00:00
|
|
|
Inputs
|
|
|
|
------
|
|
|
|
|
2019-08-12 17:01:53 +00:00
|
|
|
- ``data/bundle/EIA_hydro_generation_2000_2014.csv``: Hydroelectricity net generation per country and year (`EIA <https://www.eia.gov/beta/international/data/browser/#/?pa=000000000000000000000000000000g&c=1028i008006gg6168g80a4k000e0ag00gg0004g800ho00g8&ct=0&ug=8&tl_id=2-A&vs=INTL.33-12-ALB-BKWH.A&cy=2014&vo=0&v=H&start=2000&end=2016>`_)
|
|
|
|
|
2019-08-14 13:36:46 +00:00
|
|
|
.. image:: ../img/hydrogeneration.png
|
2019-08-12 17:01:53 +00:00
|
|
|
:scale: 33 %
|
|
|
|
|
2019-08-11 20:34:18 +00:00
|
|
|
- ``resources/country_shapes.geojson``: confer :ref:`shapes`
|
|
|
|
- ``"cutouts/" + config["renewable"]['hydro']['cutout']``: confer :ref:`cutout`
|
|
|
|
|
2019-08-11 09:40:47 +00:00
|
|
|
Outputs
|
|
|
|
-------
|
|
|
|
|
2019-08-11 20:34:18 +00:00
|
|
|
- ``resources/profile_hydro.nc``:
|
|
|
|
|
2019-08-12 21:48:16 +00:00
|
|
|
=================== ================ =========================================================
|
|
|
|
Field Dimensions Description
|
|
|
|
=================== ================ =========================================================
|
|
|
|
inflow countries, time Inflow to the state of charge (in MW),
|
|
|
|
e.g. due to river inflow in hydro reservoir.
|
|
|
|
=================== ================ =========================================================
|
|
|
|
|
2019-08-14 13:36:46 +00:00
|
|
|
.. image:: ../img/inflow-ts.png
|
2019-08-13 13:48:21 +00:00
|
|
|
:scale: 33 %
|
2019-11-14 16:50:24 +00:00
|
|
|
|
2019-08-14 13:36:46 +00:00
|
|
|
.. image:: ../img/inflow-box.png
|
2019-08-13 13:48:21 +00:00
|
|
|
:scale: 33 %
|
|
|
|
|
2019-08-11 09:40:47 +00:00
|
|
|
Description
|
|
|
|
-----------
|
|
|
|
|
|
|
|
.. seealso::
|
2019-08-12 17:01:53 +00:00
|
|
|
:mod:`build_renewable_profiles`
|
2019-08-08 13:02:28 +00:00
|
|
|
"""
|
2018-01-29 21:28:33 +00:00
|
|
|
|
2019-11-28 07:22:52 +00:00
|
|
|
import logging
|
|
|
|
from _helpers import configure_logging
|
|
|
|
|
2018-08-03 09:54:28 +00:00
|
|
|
import os
|
2018-01-29 21:28:33 +00:00
|
|
|
import atlite
|
2018-08-03 09:53:14 +00:00
|
|
|
import geopandas as gpd
|
|
|
|
from vresutils import hydro as vhydro
|
2018-01-29 21:28:33 +00:00
|
|
|
|
2020-09-11 10:40:53 +00:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
2019-08-08 13:02:28 +00:00
|
|
|
if __name__ == "__main__":
|
2019-12-09 20:29:15 +00:00
|
|
|
if 'snakemake' not in globals():
|
|
|
|
from _helpers import mock_snakemake
|
|
|
|
snakemake = mock_snakemake('build_hydro_profile')
|
2019-11-28 07:22:52 +00:00
|
|
|
configure_logging(snakemake)
|
2019-12-09 20:29:15 +00:00
|
|
|
|
2020-10-20 11:53:43 +00:00
|
|
|
year = snakemake.wildcards.year
|
2019-08-08 13:02:28 +00:00
|
|
|
config = snakemake.config['renewable']['hydro']
|
2020-09-11 10:40:53 +00:00
|
|
|
cutout_dir = os.path.dirname(snakemake.input.cutout)
|
2020-10-20 11:53:43 +00:00
|
|
|
cutout_config = config['cutout']
|
|
|
|
if year: cutout_config = cutout_config.format(year=year)
|
|
|
|
|
|
|
|
cutout = atlite.Cutout(cutout_config, cutout_dir=cutout_dir)
|
2019-08-08 13:02:28 +00:00
|
|
|
|
|
|
|
countries = snakemake.config['countries']
|
|
|
|
country_shapes = gpd.read_file(snakemake.input.country_shapes).set_index('name')['geometry'].reindex(countries)
|
|
|
|
country_shapes.index.name = 'countries'
|
2018-01-29 21:28:33 +00:00
|
|
|
|
2019-08-08 13:02:28 +00:00
|
|
|
eia_stats = vhydro.get_eia_annual_hydro_generation(snakemake.input.eia_hydro_generation).reindex(columns=countries)
|
2020-10-20 11:53:43 +00:00
|
|
|
|
|
|
|
if year not in eia_stats.index:
|
|
|
|
eia_stats.loc[year] = eia_stats.mean()
|
|
|
|
|
2019-08-08 13:02:28 +00:00
|
|
|
inflow = cutout.runoff(shapes=country_shapes,
|
2020-09-11 10:40:53 +00:00
|
|
|
smooth=True,
|
|
|
|
lower_threshold_quantile=True,
|
|
|
|
normalize_using_yearly=eia_stats)
|
2018-01-29 21:28:33 +00:00
|
|
|
|
2019-08-08 13:02:28 +00:00
|
|
|
if 'clip_min_inflow' in config:
|
|
|
|
inflow.values[inflow.values < config['clip_min_inflow']] = 0.
|
2018-12-21 12:44:59 +00:00
|
|
|
|
2019-08-08 13:02:28 +00:00
|
|
|
inflow.to_netcdf(snakemake.output[0])
|