incorporate suggestions
This commit is contained in:
parent
8f5415f69c
commit
d0e2fed4d7
@ -345,7 +345,7 @@ def attach_hydro(n, costs, ppl):
|
|||||||
|
|
||||||
country = ppl['bus'].map(n.buses.country).rename("country")
|
country = ppl['bus'].map(n.buses.country).rename("country")
|
||||||
|
|
||||||
inflow_idx = ror.index ^ hydro.index
|
inflow_idx = ror.index | hydro.index
|
||||||
if not inflow_idx.empty:
|
if not inflow_idx.empty:
|
||||||
dist_key = ppl.loc[inflow_idx, 'p_nom'].groupby(country).transform(normed)
|
dist_key = ppl.loc[inflow_idx, 'p_nom'].groupby(country).transform(normed)
|
||||||
|
|
||||||
@ -391,31 +391,30 @@ def attach_hydro(n, costs, ppl):
|
|||||||
|
|
||||||
if 'hydro' in carriers and not hydro.empty:
|
if 'hydro' in carriers and not hydro.empty:
|
||||||
hydro_max_hours = c.get('hydro_max_hours')
|
hydro_max_hours = c.get('hydro_max_hours')
|
||||||
|
hydro_stats = pd.read_csv(snakemake.input.hydro_capacities,
|
||||||
|
comment="#", na_values='-', index_col=0)
|
||||||
|
e_target = hydro_stats["E_store[TWh]"].clip(lower=0.2) * 1e6
|
||||||
|
e_installed = hydro.eval('p_nom * max_hours').groupby(hydro.country).sum()
|
||||||
|
e_missing = e_target - e_installed
|
||||||
|
missing_mh_i = hydro.query('max_hours == 0').index
|
||||||
|
|
||||||
if hydro_max_hours == 'energy_capacity_totals_by_country':
|
if hydro_max_hours == 'energy_capacity_totals_by_country':
|
||||||
# TODO: check where the statistics come from, IE's p_nom is totally
|
# watch out some p_nom values like IE's are totally underrepresented
|
||||||
# underrepresented
|
max_hours_country = e_missing / \
|
||||||
e_target = (pd.read_csv(snakemake.input.hydro_capacities,
|
hydro.loc[missing_mh_i].groupby('country').p_nom.sum()
|
||||||
index_col=0)["E_store[TWh]"].clip(lower=0.2)*1e6)
|
|
||||||
e_installed = hydro.eval('p_nom * max_hours').groupby(hydro.country).sum()
|
|
||||||
e_missing = e_target - e_installed
|
|
||||||
missing_mh_i = hydro.query('max_hours == 0').index
|
|
||||||
|
|
||||||
max_hours_country = e_missing / hydro.loc[missing_mh_i].groupby('country').p_nom.sum()
|
|
||||||
hydro_max_hours = hydro.max_hours.where(hydro.max_hours > 0,
|
|
||||||
hydro.country.map(max_hours_country))
|
|
||||||
elif hydro_max_hours == 'estimate_by_large_installations':
|
elif hydro_max_hours == 'estimate_by_large_installations':
|
||||||
hydro_capacities = pd.read_csv(snakemake.input.hydro_capacities,
|
max_hours_country = hydro_stats['E_store[TWh]'] * 1e3 / \
|
||||||
comment="#", na_values='-', index_col=0)
|
hydro_stats['p_nom_discharge[GW]']
|
||||||
estim_hydro_max_hours = hydro_capacities['E_store[TWh]'] * 1e3 / \
|
|
||||||
hydro_capacities['p_nom_discharge[GW]']
|
|
||||||
|
|
||||||
missing_countries = (pd.Index(hydro['country'].unique())
|
missing_countries = (pd.Index(hydro['country'].unique())
|
||||||
.difference(estim_hydro_max_hours.dropna().index))
|
.difference(max_hours_country.dropna().index))
|
||||||
if not missing_countries.empty:
|
if not missing_countries.empty:
|
||||||
logger.warning("Assuming max_hours=6 for hydro reservoirs in the countries: {}"
|
logger.warning("Assuming max_hours=6 for hydro reservoirs in the countries: {}"
|
||||||
.format(", ".join(missing_countries)))
|
.format(", ".join(missing_countries)))
|
||||||
|
hydro_max_hours = hydro.max_hours.where(hydro.max_hours > 0,
|
||||||
|
hydro.country.map(max_hours_country)).fillna(6)
|
||||||
|
|
||||||
hydro_max_hours = hydro['country'].map(estim_hydro_max_hours).fillna(6)
|
|
||||||
|
|
||||||
n.madd('StorageUnit', hydro.index, carrier='hydro',
|
n.madd('StorageUnit', hydro.index, carrier='hydro',
|
||||||
bus=hydro['bus'],
|
bus=hydro['bus'],
|
||||||
|
@ -8,8 +8,8 @@ Relevant Settings
|
|||||||
.. code:: yaml
|
.. code:: yaml
|
||||||
|
|
||||||
electricity:
|
electricity:
|
||||||
powerplants_filter:
|
powerplants_filter:
|
||||||
custom_powerplants:
|
custom_powerplants:
|
||||||
|
|
||||||
.. seealso::
|
.. seealso::
|
||||||
Documentation of the configuration file ``config.yaml`` at
|
Documentation of the configuration file ``config.yaml`` at
|
||||||
@ -88,10 +88,13 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
cntries_without_ppl = [c for c in countries if c not in ppl.Country.unique()]
|
cntries_without_ppl = [c for c in countries if c not in ppl.Country.unique()]
|
||||||
|
|
||||||
substation_i = n.buses.query('substation_lv').index
|
for c in countries:
|
||||||
kdtree = KDTree(n.buses.loc[substation_i, ['x','y']].values)
|
substation_i = n.buses.query('substation_lv and country == @c').index
|
||||||
|
kdtree = KDTree(n.buses.loc[substation_i, ['x','y']].values)
|
||||||
|
ppl_i = ppl.query('Country == @c').index
|
||||||
|
|
||||||
ppl['bus'] = substation_i[kdtree.query(ppl[['lon','lat']].values)[1]]
|
ppl.loc[ppl_i, 'bus'] = substation_i[kdtree.query(ppl.loc[ppl_i,
|
||||||
|
['lon','lat']].values)[1]]
|
||||||
|
|
||||||
if cntries_without_ppl:
|
if cntries_without_ppl:
|
||||||
logging.warning(f"No powerplants known in: {', '.join(cntries_without_ppl)}")
|
logging.warning(f"No powerplants known in: {', '.join(cntries_without_ppl)}")
|
||||||
|
Loading…
Reference in New Issue
Block a user