diff --git a/doc/release_notes.rst b/doc/release_notes.rst index 5a9358e5..884df00a 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -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 `_) + PyPSA-Eur 0.2.0 (8th June 2020) ================================== diff --git a/scripts/add_electricity.py b/scripts/add_electricity.py index 55e9e7c2..573bc29f 100755 --- a/scripts/add_electricity.py +++ b/scripts/add_electricity.py @@ -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__":