Fix up add_nice_carrier_names for new pandas (#178)

* solve #174

* update release notes

Co-authored-by: Fabian Neumann <fabian.neumann@outlook.de>
This commit is contained in:
FabianHofmann 2020-08-24 11:04:54 +02:00 committed by GitHub
parent 2f4852347a
commit 1cde8d300a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View File

@ -15,8 +15,11 @@ Upcoming Release
* Add compatibility for pyomo 5.7.0 in :mod:`cluster_network` and :mod:`simplify_network`.
* Raise a warning if `tech_colors` in the config are not defined for all carriers.
* Corrected HVDC link connections (a) between Norway and Denmark and (b) mainland Italy, Corsica (FR) and Sardinia (IT) (`#181 <https://github.com/PyPSA/pypsa-eur/pull/181>`_)
PyPSA-Eur 0.2.0 (8th June 2020)
==================================

View File

@ -506,10 +506,16 @@ def estimate_renewable_capacities(n, tech_map=None):
def add_nice_carrier_names(n, config=None):
if config is None: config = snakemake.config
nice_names = pd.Series(config['plotting']['nice_names'])
n.carriers['nice_name'] = nice_names[n.carriers.index]
colors = pd.Series(config['plotting']['tech_colors'])
n.carriers['color'] = colors[n.carriers.index]
carrier_i = n.carriers.index
nice_names = (pd.Series(config['plotting']['nice_names'])
.reindex(carrier_i).fillna(carrier_i.to_series().str.title()))
n.carriers['nice_name'] = nice_names
colors = pd.Series(config['plotting']['tech_colors']).reindex(carrier_i)
if colors.isna().any():
missing_i = list(colors.index[colors.isna()])
logger.warning(f'tech_colors for carriers {missing_i} not defined '
'in config.')
n.carriers['color'] = colors
if __name__ == "__main__":