pypsa-eur/scripts/build_hydro_profile.py

26 lines
929 B
Python
Raw Normal View History

#!/usr/bin/env python
2018-08-03 09:54:28 +00:00
import os
import atlite
import pandas as pd
import geopandas as gpd
from vresutils import hydro as vhydro
import logging
logger = logging.getLogger(__name__)
logger.setLevel(level=snakemake.config['logging_level'])
2018-08-03 09:54:28 +00:00
cutout = atlite.Cutout(snakemake.config['renewable']['hydro']['cutout'],
cutout_dir=os.path.dirname(snakemake.input.cutout))
countries = snakemake.config['countries']
country_shapes = gpd.read_file(snakemake.input.country_shapes).set_index('id')['geometry'].reindex(countries)
country_shapes.index.name = 'countries'
eia_stats = vhydro.get_eia_annual_hydro_generation(snakemake.input.eia_hydro_generation).reindex(columns=countries)
inflow = cutout.runoff(shapes=country_shapes,
smooth=True,
lower_threshold_quantile=True,
normalize_using_yearly=eia_stats)
inflow.to_netcdf(snakemake.output[0])