From 0e6862e9b0af435d37becdbe0fffd30d77ecb4ff Mon Sep 17 00:00:00 2001 From: cpschau Date: Wed, 10 Apr 2024 17:10:56 +0200 Subject: [PATCH 1/2] write shapes to base network --- scripts/base_network.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/base_network.py b/scripts/base_network.py index 346f99a59..f78f4b04d 100644 --- a/scripts/base_network.py +++ b/scripts/base_network.py @@ -697,6 +697,14 @@ def _adjust_capacities_of_under_construction_branches(n, config): return n +def _set_shapes(n, country_shapes, offshore_shapes): + # Write the geodataframes country_shapes and offshore_shapes to the network.shapes component + country_shapes = gpd.read_file(country_shapes).rename(columns={"name": "idx"}) + country_shapes["type"] = "country" + offshore_shapes = gpd.read_file(offshore_shapes).rename(columns={"name": "idx"}) + offshore_shapes["type"] = "offshore" + all_shapes = pd.concat([country_shapes, offshore_shapes]) + n.shapes = pd.concat([n.shapes, all_shapes]) def base_network( eg_buses, @@ -758,12 +766,16 @@ def base_network( n = _adjust_capacities_of_under_construction_branches(n, config) + _set_shapes(n, country_shapes, offshore_shapes) + return n if __name__ == "__main__": if "snakemake" not in globals(): from _helpers import mock_snakemake + import os + os.chdir(os.path.dirname(os.path.abspath(__file__))) snakemake = mock_snakemake("base_network") configure_logging(snakemake) From 8ec2a5333b4d1f0745c2d369c5a354a817fdd82a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 10 Apr 2024 15:16:36 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/base_network.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/base_network.py b/scripts/base_network.py index f78f4b04d..77d3d2507 100644 --- a/scripts/base_network.py +++ b/scripts/base_network.py @@ -697,6 +697,7 @@ def _adjust_capacities_of_under_construction_branches(n, config): return n + def _set_shapes(n, country_shapes, offshore_shapes): # Write the geodataframes country_shapes and offshore_shapes to the network.shapes component country_shapes = gpd.read_file(country_shapes).rename(columns={"name": "idx"}) @@ -704,7 +705,8 @@ def _set_shapes(n, country_shapes, offshore_shapes): offshore_shapes = gpd.read_file(offshore_shapes).rename(columns={"name": "idx"}) offshore_shapes["type"] = "offshore" all_shapes = pd.concat([country_shapes, offshore_shapes]) - n.shapes = pd.concat([n.shapes, all_shapes]) + n.shapes = pd.concat([n.shapes, all_shapes]) + def base_network( eg_buses, @@ -773,8 +775,10 @@ def base_network( if __name__ == "__main__": if "snakemake" not in globals(): - from _helpers import mock_snakemake import os + + from _helpers import mock_snakemake + os.chdir(os.path.dirname(os.path.abspath(__file__))) snakemake = mock_snakemake("base_network")