diff --git a/Snakefile b/Snakefile index 7678a401..f3a894fc 100644 --- a/Snakefile +++ b/Snakefile @@ -50,7 +50,7 @@ if config['enable'].get('prepare_links_p_nom', False): datafiles = ['ch_cantons.csv', 'je-e-21.03.02.xls', - 'eez/World_EEZ_v8_2014.shp', 'EIA_hydro_generation_2000_2014.csv', + 'eez/World_EEZ_v8_2014.shp', 'hydro_capacities.csv', 'naturalearth/ne_10m_admin_0_countries.shp', 'NUTS_2013_60M_SH/data/NUTS_RG_60M_2013.shp', 'nama_10r_3popgdp.tsv.gz', 'nama_10r_3gdp.tsv.gz', 'corine/g250_clc06_V18_5.tif'] @@ -208,7 +208,7 @@ rule build_renewable_profiles: rule build_hydro_profile: input: country_shapes='resources/country_shapes.geojson', - eia_hydro_generation='data/bundle/EIA_hydro_generation_2000_2014.csv', + eia_hydro_generation='data/eia_hydro_annual_generation.csv', cutout=f"cutouts/{config['renewable']['hydro']['cutout']}.nc" if "hydro" in config["renewable"] else "config['renewable']['hydro']['cutout'] not configured", output: 'resources/profile_hydro.nc' log: "logs/build_hydro_profile.log" diff --git a/scripts/build_hydro_profile.py b/scripts/build_hydro_profile.py index 74efc2ef..0fb20b06 100644 --- a/scripts/build_hydro_profile.py +++ b/scripts/build_hydro_profile.py @@ -64,7 +64,29 @@ from _helpers import configure_logging import atlite import geopandas as gpd -from vresutils import hydro as vhydro +import pandas as pd + +import country_converter as coco +cc = coco.CountryConverter() + + +def get_eia_annual_hydro_generation(fn, countries): + + # in billion kWh/a = TWh/a + df = pd.read_csv(fn, skiprows=2, index_col=1, na_values=[u' ','--']).iloc[1:, 1:] + df.index = df.index.str.strip() + + df.loc["Germany"] = df.filter(like='Germany', axis=0).sum() + df.loc["Serbia"] += df.loc["Kosovo"] + df = df.loc[~df.index.str.contains('Former')] + + df.index = cc.convert(df.index, to='iso2') + df.index.name = 'countries' + + df = df.T[countries] * 1e6 # in MWh/a + + return df + logger = logging.getLogger(__name__) @@ -82,8 +104,9 @@ if __name__ == "__main__": .set_index('name')['geometry'].reindex(countries)) country_shapes.index.name = 'countries' - eia_stats = vhydro.get_eia_annual_hydro_generation( - snakemake.input.eia_hydro_generation).reindex(columns=countries) + fn = snakemake.input.eia_hydro_generation + eia_stats = get_eia_annual_hydro_generation(fn, countries) + inflow = cutout.runoff(shapes=country_shapes, smooth=True, lower_threshold_quantile=True,