From c5e8c9ad25a08c73c93d1a3010840dc5be473358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20H=C3=B6rsch?= Date: Mon, 12 Nov 2018 21:43:33 +0100 Subject: [PATCH] add_electricity: Extend the assignment of max_hours --- Snakefile | 1 + config.yaml | 2 ++ data/geth2015_hydro_capacities.csv | 32 ++++++++++++++++++++++++++++++ scripts/add_electricity.py | 23 +++++++++++++++------ 4 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 data/geth2015_hydro_capacities.csv diff --git a/Snakefile b/Snakefile index 97e2aa0a..3aa649a9 100644 --- a/Snakefile +++ b/Snakefile @@ -142,6 +142,7 @@ rule add_electricity: regions="resources/regions_onshore.geojson", powerplants='resources/powerplants.csv', hydro_capacities='data/bundle/hydro_capacities.csv', + geth_hydro_capacities='data/geth2015_hydro_capacities.csv', opsd_load='data/bundle/time_series_60min_singleindex_filtered.csv', nuts3_shapes='resources/nuts3_shapes.geojson', **{'profile_' + t: "resources/profile_" + t + ".nc" diff --git a/config.yaml b/config.yaml index 82988f13..10ade504 100644 --- a/config.yaml +++ b/config.yaml @@ -102,6 +102,8 @@ renewable: cutout: europe-2013-era5 carriers: [ror, PHS, hydro] PHS_max_hours: 6 + hydro_max_hours: "energy_capacity_totals_by_country" # one of energy_capacity_totals_by_country, + # estimate_by_large_installations or a float lines: diff --git a/data/geth2015_hydro_capacities.csv b/data/geth2015_hydro_capacities.csv new file mode 100644 index 00000000..ddb91bae --- /dev/null +++ b/data/geth2015_hydro_capacities.csv @@ -0,0 +1,32 @@ +# Table 25 from F. Geth et al., An overview of large-scale stationary electricity storage plants in Europe (2015) 1212–1227 +country,n,p_nom_discharge,p_nom_charge,e_stor +AT,19,4.051,3.246,132.41 +BE,3,1.301,1.196,5.71 +BG,3,1.399,0.93,11.13 +HR,3,0.281,0.246,2.34 +CY,0,-,-,- +CZ,3,1.119,1.145,5.72 +DK,0,-,-,- +EE,0,-,-,- +FI ,0,-,-,- +FR,10,5.512,4.317,83.37 +DE,34,6.805,6.417,39.12 +GR,2,0.735,-,4.97 +HU,0,-,-,- +IE,1,0.292,-,1.8 +IT,25,7.833,7.64,68.27 +LV,0,-,-,- +LT,1,0.9,0.88,10.8 +LU,1,1.296,1.05,4.92 +MT,0,-,-,- +NL,0,-,-,- +PL,6,1.757,1.647,7.96 +PT,7,1.279,-,40.77 +RO,5,0.285,0.2,10.2 +SK,4,1.016,0.79,3.63 +SI,1,0.185,0.18,0.5 +ES,26,6.358,5.859,70 +SE,2,0.091,-,72.12 +GB,4,2.788,2.65,26.7 +NO,8,1.273,0.892,399.39 +CH,20,2.291,1.512,311.48 diff --git a/scripts/add_electricity.py b/scripts/add_electricity.py index 2a460db1..04565035 100644 --- a/scripts/add_electricity.py +++ b/scripts/add_electricity.py @@ -219,13 +219,13 @@ def attach_hydro(n, costs, ppl): has_pump=ppl.technology.str.contains('Pumped Storage') ) - country = ppl.loc[ppl.has_inflow, 'bus'].map(n.buses.country) + country = ppl['bus'].map(n.buses.country) # distribute by p_nom in each country dist_key = ppl.loc[ppl.has_inflow, 'p_nom'].groupby(country).transform(normed) with xr.open_dataarray(snakemake.input.profile_hydro) as inflow: inflow_t = ( - inflow.sel(countries=country.values) + inflow.sel(countries=country.loc[ppl.has_inflow].values) .rename({'countries': 'name'}) .assign_coords(name=ppl.index[ppl.has_inflow]) .transpose('time', 'name') @@ -260,13 +260,24 @@ def attach_hydro(n, costs, ppl): inflow=inflow_t.loc[:, phs.index[phs.has_inflow]]) if 'hydro' in carriers: - hydro = ppl.loc[ppl.has_store & ~ ppl.has_pump & ppl.has_inflow] + hydro = ppl.loc[ppl.has_store & ~ ppl.has_pump & ppl.has_inflow].join(country.rename('country')) hydro_max_hours = c.get('hydro_max_hours') - if hydro_max_hours is None: + if hydro_max_hours == 'energy_capacity_totals_by_country': hydro_e_country = pd.read_csv(snakemake.input.hydro_capacities, index_col=0)["E_store[TWh]"].clip(lower=0.2)*1e6 - hydro_max_hours_country = hydro_e_country / hydro.p_nom.groupby(country).sum() - hydro_max_hours = country.loc[hydro.index].map(hydro_max_hours_country) + hydro_max_hours_country = hydro_e_country / hydro.groupby('country').p_nom.sum() + hydro_max_hours = hydro.country.map(hydro_e_country / hydro.groupby('country').p_nom.sum()) + elif hydro_max_hours == 'estimate_by_large_installations': + hydro_capacities = pd.read_csv(snakemake.input.hydro_capacities, comment="#", na_values='-', index_col=0) + estim_hydro_max_hours = hydro_capacities.e_stor / hydro_capacities.p_nom_discharge + + missing_countries = (pd.Index(hydro['country'].unique()) + .difference(estim_hydro_max_hours.dropna().index)) + if not missing_countries.empty: + logger.warning("Assuming max_hours=6 for hydro reservoirs in the countries: {}" + .format(", ".join(missing_countries))) + + hydro_max_hours = hydro['country'].map(estim_hydro_max_hours).fillna(6) n.madd('StorageUnit', hydro.index, carrier='hydro', bus=hydro['bus'],