From 803805c5e57c663fa722e84a64c1534d3afd5850 Mon Sep 17 00:00:00 2001 From: CarlosEpia Date: Mon, 26 Feb 2024 08:52:46 +0100 Subject: [PATCH 1/5] fix wind offshore for eGon100RE --- src/egon/data/datasets/power_plants/wind_offshore.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/egon/data/datasets/power_plants/wind_offshore.py b/src/egon/data/datasets/power_plants/wind_offshore.py index 68cb09d59..cba700dab 100644 --- a/src/egon/data/datasets/power_plants/wind_offshore.py +++ b/src/egon/data/datasets/power_plants/wind_offshore.py @@ -12,7 +12,7 @@ def map_id_bus(scenario): # Import manually generated list of wind offshore farms with their # connection points (OSM_id) - if scenario == "eGon2035": + if scenario in ["eGon2035", "eGon100RE"]: id_bus = { "Büttel": "136034396", "Heide/West": "603661085", @@ -186,6 +186,7 @@ def insert(): ], ) offshore.dropna(subset=["Netzverknuepfungspunkt"], inplace=True) + offshore.rename(columns={"B 2040 ": "el_capacity"}, inplace=True) elif scenario == "status2019": offshore_path = ( @@ -276,7 +277,7 @@ def insert(): WHERE scenario_name = 'eGon100RE' AND carrier = 'wind_offshore' """ - ) + ).iloc[0,0] # Scale capacities to match target scale_factor = cap_100RE / offshore.el_capacity.sum() From bacdb8721ea26fdd71208c7f64dfe962435d1c3b Mon Sep 17 00:00:00 2001 From: CarlosEpia Date: Wed, 24 Apr 2024 15:36:05 +0200 Subject: [PATCH 2/5] update osm_id offshore wind --- src/egon/data/datasets/power_plants/wind_offshore.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/egon/data/datasets/power_plants/wind_offshore.py b/src/egon/data/datasets/power_plants/wind_offshore.py index cba700dab..cd5ef469c 100644 --- a/src/egon/data/datasets/power_plants/wind_offshore.py +++ b/src/egon/data/datasets/power_plants/wind_offshore.py @@ -15,7 +15,7 @@ def map_id_bus(scenario): if scenario in ["eGon2035", "eGon100RE"]: id_bus = { "Büttel": "136034396", - "Heide/West": "603661085", + "Heide/West": "289836713", "Suchraum Gemeinden Ibbenbüren/Mettingen/Westerkappeln": "114319248", "Suchraum Zensenbusch": "76185022", "Rommerskirchen": "24839976", @@ -24,13 +24,13 @@ def map_id_bus(scenario): "Diele": "177829920", "Dörpen/West": "142487746", "Emden/Borßum": "34835258", - "Emden/Ost": "34835258", + "Emden/Ost": "177829920", "Hagermarsch": "79316833", "Hanekenfähr": "61918154", "Inhausen": "29420322", "Unterweser": "32076853", "Wehrendorf": "33411203", - "Wilhelmshaven 2": "23744346", + "Wilhelmshaven 2": "23837631", "Rastede": "23837631", "Bentwisch": "32063539", "Lubmin": "460134233", From 3c25912eb32c3041a54bc03a363fe30d5d933002 Mon Sep 17 00:00:00 2001 From: CarlosEpia Date: Wed, 24 Apr 2024 15:37:19 +0200 Subject: [PATCH 3/5] deal with max_id when no previous registers --- src/egon/data/datasets/power_plants/wind_offshore.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/egon/data/datasets/power_plants/wind_offshore.py b/src/egon/data/datasets/power_plants/wind_offshore.py index cd5ef469c..31f1880d0 100644 --- a/src/egon/data/datasets/power_plants/wind_offshore.py +++ b/src/egon/data/datasets/power_plants/wind_offshore.py @@ -312,15 +312,17 @@ def insert(): offshore = gpd.GeoDataFrame(offshore, geometry="geom", crs=4326) # Look for the maximum id in the table egon_power_plants - next_id = ( - db.select_dataframe( + next_id = db.select_dataframe( "SELECT MAX(id) FROM " + cfg["target"]["schema"] + "." + cfg["target"]["table"] - ).iloc[0, 0] - + 1 - ) + ).iloc[0, 0] + + if next_id: + next_id+=1 + else: + next_id = 1 # Reset index offshore.index = pd.RangeIndex( From fdf8f1a301884c7abe8c48aa79e566e1d0ce8806 Mon Sep 17 00:00:00 2001 From: CarlosEpia Date: Wed, 24 Apr 2024 15:37:48 +0200 Subject: [PATCH 4/5] using Black --- .../data/datasets/power_plants/wind_offshore.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/egon/data/datasets/power_plants/wind_offshore.py b/src/egon/data/datasets/power_plants/wind_offshore.py index 31f1880d0..b0d0916b4 100644 --- a/src/egon/data/datasets/power_plants/wind_offshore.py +++ b/src/egon/data/datasets/power_plants/wind_offshore.py @@ -277,7 +277,7 @@ def insert(): WHERE scenario_name = 'eGon100RE' AND carrier = 'wind_offshore' """ - ).iloc[0,0] + ).iloc[0, 0] # Scale capacities to match target scale_factor = cap_100RE / offshore.el_capacity.sum() @@ -313,14 +313,14 @@ def insert(): # Look for the maximum id in the table egon_power_plants next_id = db.select_dataframe( - "SELECT MAX(id) FROM " - + cfg["target"]["schema"] - + "." - + cfg["target"]["table"] - ).iloc[0, 0] + "SELECT MAX(id) FROM " + + cfg["target"]["schema"] + + "." + + cfg["target"]["table"] + ).iloc[0, 0] if next_id: - next_id+=1 + next_id += 1 else: next_id = 1 From d2d815b63fca3773328cdaaa946622bff921f0e7 Mon Sep 17 00:00:00 2001 From: CarlosEpia Date: Tue, 30 Jul 2024 15:20:27 +0200 Subject: [PATCH 5/5] make selection of ids dependent of OSM years --- .../datasets/power_plants/wind_offshore.py | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/egon/data/datasets/power_plants/wind_offshore.py b/src/egon/data/datasets/power_plants/wind_offshore.py index b0d0916b4..90f86de7f 100644 --- a/src/egon/data/datasets/power_plants/wind_offshore.py +++ b/src/egon/data/datasets/power_plants/wind_offshore.py @@ -12,10 +12,13 @@ def map_id_bus(scenario): # Import manually generated list of wind offshore farms with their # connection points (OSM_id) + osm_year = egon.data.config.datasets()["openstreetmap"]["original_data"][ + "source" + ]["url"] + if scenario in ["eGon2035", "eGon100RE"]: id_bus = { "Büttel": "136034396", - "Heide/West": "289836713", "Suchraum Gemeinden Ibbenbüren/Mettingen/Westerkappeln": "114319248", "Suchraum Zensenbusch": "76185022", "Rommerskirchen": "24839976", @@ -24,13 +27,11 @@ def map_id_bus(scenario): "Diele": "177829920", "Dörpen/West": "142487746", "Emden/Borßum": "34835258", - "Emden/Ost": "177829920", "Hagermarsch": "79316833", "Hanekenfähr": "61918154", "Inhausen": "29420322", "Unterweser": "32076853", "Wehrendorf": "33411203", - "Wilhelmshaven 2": "23837631", "Rastede": "23837631", "Bentwisch": "32063539", "Lubmin": "460134233", @@ -39,6 +40,25 @@ def map_id_bus(scenario): "inhausen": "29420322", "Cloppenburg": "50643382", } + if "200101" in osm_year: + id_bus2 = { + "Heide/West": "289836713", + "Emden/Ost": "177829920", + "Wilhelmshaven 2": "23837631", + } + elif "220101" in osm_year: + id_bus2 = { + "Heide/West": "603661085", + "Emden/Ost": "34835258", + "Wilhelmshaven 2": "23744346", + } + else: + raise Exception( + """The OSM year used is not yet compatible with + this function""" + ) + id_bus = {**id_bus, **id_bus2} + elif scenario == "status2019": id_bus = { "UW Inhausen": "29420322",