bug fix: add_electricity breaks in specific cases

This commit is contained in:
Irieo 2023-11-03 12:36:40 +01:00
parent 326aeb682b
commit e61da8618e

View File

@ -759,7 +759,10 @@ def estimate_renewable_capacities(n, year, tech_map, expansion_limit, countries)
for ppm_technology, techs in tech_map.items():
tech_i = n.generators.query("carrier in @techs").index
stats = capacities.loc[ppm_technology].reindex(countries, fill_value=0.0)
if ppm_technology in capacities.index.get_level_values("Technology"):
stats = capacities.loc[ppm_technology].reindex(countries, fill_value=0.0)
else:
stats = pd.Series(0.0, index=countries)
country = n.generators.bus[tech_i].map(n.buses.country)
existent = n.generators.p_nom[tech_i].groupby(country).sum()
missing = stats - existent