Bug fixes in add_existing_baseyear: Defaults and missing empty space (#1289)

* Bug fixes in add_existing baseyear.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: lisazeyen <35347358+lisazeyen@users.noreply.github.com>
This commit is contained in:
Bobby Xiong 2024-09-12 17:53:25 +02:00 committed by GitHub
parent 1b97a16bfa
commit 16b0f35cd8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -597,7 +597,7 @@ def add_heating_capacities_installed_before_baseyear(
n.madd(
"Link",
nodes,
suffix=f"{heat_system} gas boiler-{grouping_year}",
suffix=f" {heat_system} gas boiler-{grouping_year}",
bus0="EU gas" if "EU gas" in spatial.gas.nodes else nodes + " gas",
bus1=nodes + " " + heat_system.value + " heat",
bus2="co2 atmosphere",
@ -666,6 +666,22 @@ def add_heating_capacities_installed_before_baseyear(
)
def set_defaults(n):
"""
Set default values for missing values in the network.
Parameters:
n (pypsa.Network): The network object.
Returns:
None
"""
if "Link" in n.components:
if "reversed" in n.links.columns:
# Replace NA values with default value False
n.links.loc[n.links.reversed.isna(), "reversed"] = False
n.links.reversed = n.links.reversed.astype(bool)
# %%
if __name__ == "__main__":
if "snakemake" not in globals():
@ -734,6 +750,9 @@ if __name__ == "__main__":
),
)
# Set defaults for missing missing values
set_defaults(n)
if options.get("cluster_heat_buses", False):
cluster_heat_buses(n)