Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into bugfix/waste-heat-chp
Browse files Browse the repository at this point in the history
  • Loading branch information
p-glaum committed Nov 6, 2024
2 parents c61c686 + 0c41cec commit 4968e1f
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 135 deletions.
7 changes: 7 additions & 0 deletions doc/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@ Release Notes

Upcoming Release
================

* Improve `sanitize_carrier`` function by filling in colors of missing carriers with colors mapped after using the function `rename_techs`.

* Bugfix: Adjusted efficiency2 (to atmosphere) for bioliquids-to-oil Link in `prepare_sector_network` to exactly offset the corresponding oil emissions.

* Bugfix: Waste CHPs were added to all electricity buses even if they were not connected to heating network. This is now fixed.

* Bugfix: Duplicates in build_transmission_projects were caught, but not removed from the network. This is now fixed.

* Replaced the Store representation of biogenic carriers (solid biomass, biogas, bioliquids, MSW) in ``prepare_sector_network`` with the extended Generator component that uses the ``e_sum_min`` and ``e_sum_max`` attributes to enforce minimum usage and limit maximum potential, respectively.

* Added option to reduce central heating forward temperatures by annual percentage (see rule :mod:`build_central_heating_temperature_profiles`). This makes COP profiles and heat pump efficiencies planning-horizon-dependent. Myopic and perfect foresight modes were adjusted accordingly to update COPs of existing heat pumps in preceding years to adjusted temperatures.

* Rearranged workflow to cluster the electricity network before calculating
Expand Down
87 changes: 87 additions & 0 deletions scripts/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,3 +829,90 @@ def get_snapshots(snapshots, drop_leap_day=False, freq="h", **kwargs):
time = time[~((time.month == 2) & (time.day == 29))]

return time


def rename_techs(label: str) -> str:
"""
Rename technology labels for better readability.
Removes some prefixes and renames if certain conditions defined in function body are met.
Parameters:
----------
label: str
Technology label to be renamed
Returns:
-------
str
Renamed label
"""
prefix_to_remove = [
"residential ",
"services ",
"urban ",
"rural ",
"central ",
"decentral ",
]

rename_if_contains = [
"CHP",
"gas boiler",
"biogas",
"solar thermal",
"air heat pump",
"ground heat pump",
"resistive heater",
"Fischer-Tropsch",
]

rename_if_contains_dict = {
"water tanks": "hot water storage",
"retrofitting": "building retrofitting",
# "H2 Electrolysis": "hydrogen storage",
# "H2 Fuel Cell": "hydrogen storage",
# "H2 pipeline": "hydrogen storage",
"battery": "battery storage",
"H2 for industry": "H2 for industry",
"land transport fuel cell": "land transport fuel cell",
"land transport oil": "land transport oil",
"oil shipping": "shipping oil",
# "CC": "CC"
}

rename = {
"solar": "solar PV",
"Sabatier": "methanation",
"offwind": "offshore wind",
"offwind-ac": "offshore wind (AC)",
"offwind-dc": "offshore wind (DC)",
"offwind-float": "offshore wind (Float)",
"onwind": "onshore wind",
"ror": "hydroelectricity",
"hydro": "hydroelectricity",
"PHS": "hydroelectricity",
"NH3": "ammonia",
"co2 Store": "DAC",
"co2 stored": "CO2 sequestration",
"AC": "transmission lines",
"DC": "transmission lines",
"B2B": "transmission lines",
}

for ptr in prefix_to_remove:
if label[: len(ptr)] == ptr:
label = label[len(ptr) :]

for rif in rename_if_contains:
if rif in label:
label = rif

for old, new in rename_if_contains_dict.items():
if old in label:
label = new

for old, new in rename.items():
if old == label:
label = new
return label
8 changes: 7 additions & 1 deletion scripts/add_electricity.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
from _helpers import (
configure_logging,
get_snapshots,
rename_techs,
set_scenario_config,
update_p_nom_max,
)
Expand Down Expand Up @@ -202,7 +203,12 @@ def sanitize_carriers(n, config):
n.carriers["nice_name"] = n.carriers.nice_name.where(
n.carriers.nice_name != "", nice_names
)
colors = pd.Series(config["plotting"]["tech_colors"]).reindex(carrier_i)

tech_colors = config["plotting"]["tech_colors"]
colors = pd.Series(tech_colors).reindex(carrier_i)
# try to fill missing colors with tech_colors after renaming
missing_colors_i = colors[colors.isna()].index
colors[missing_colors_i] = missing_colors_i.map(rename_techs).map(tech_colors)
if colors.isna().any():
missing_i = list(colors.index[colors.isna()])
logger.warning(f"tech_colors for carriers {missing_i} not defined in config.")
Expand Down
4 changes: 2 additions & 2 deletions scripts/plot_power_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import matplotlib.pyplot as plt
import pandas as pd
import pypsa
from _helpers import configure_logging, set_scenario_config
from plot_summary import preferred_order, rename_techs
from _helpers import configure_logging, rename_techs, set_scenario_config
from plot_summary import preferred_order
from pypsa.plot import add_legend_circles, add_legend_lines, add_legend_patches

logger = logging.getLogger(__name__)
Expand Down
73 changes: 1 addition & 72 deletions scripts/plot_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,85 +11,14 @@
import matplotlib.gridspec as gridspec
import matplotlib.pyplot as plt
import pandas as pd
from _helpers import configure_logging, set_scenario_config
from _helpers import configure_logging, rename_techs, set_scenario_config
from prepare_sector_network import co2_emissions_year

logger = logging.getLogger(__name__)
plt.style.use("ggplot")


# consolidate and rename
def rename_techs(label):
prefix_to_remove = [
"residential ",
"services ",
"urban ",
"rural ",
"central ",
"decentral ",
]

rename_if_contains = [
"CHP",
"gas boiler",
"biogas",
"solar thermal",
"air heat pump",
"ground heat pump",
"resistive heater",
"Fischer-Tropsch",
]

rename_if_contains_dict = {
"water tanks": "hot water storage",
"retrofitting": "building retrofitting",
# "H2 Electrolysis": "hydrogen storage",
# "H2 Fuel Cell": "hydrogen storage",
# "H2 pipeline": "hydrogen storage",
"battery": "battery storage",
"H2 for industry": "H2 for industry",
"land transport fuel cell": "land transport fuel cell",
"land transport oil": "land transport oil",
"oil shipping": "shipping oil",
# "CC": "CC"
}

rename = {
"solar": "solar PV",
"Sabatier": "methanation",
"offwind": "offshore wind",
"offwind-ac": "offshore wind (AC)",
"offwind-dc": "offshore wind (DC)",
"offwind-float": "offshore wind (Float)",
"onwind": "onshore wind",
"ror": "hydroelectricity",
"hydro": "hydroelectricity",
"PHS": "hydroelectricity",
"NH3": "ammonia",
"co2 Store": "DAC",
"co2 stored": "CO2 sequestration",
"AC": "transmission lines",
"DC": "transmission lines",
"B2B": "transmission lines",
}

for ptr in prefix_to_remove:
if label[: len(ptr)] == ptr:
label = label[len(ptr) :]

for rif in rename_if_contains:
if rif in label:
label = rif

for old, new in rename_if_contains_dict.items():
if old in label:
label = new

for old, new in rename.items():
if old == label:
label = new
return label


preferred_order = pd.Index(
[
Expand Down
Loading

0 comments on commit 4968e1f

Please sign in to comment.