Skip to content

Commit

Permalink
Merge wind offshore eGon100RE
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosEpia committed Oct 11, 2022
2 parents 61186e7 + 4fce37c commit 53ad2a7
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 31 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ Added
`#937 <https://github.com/openego/eGon-data/issues/937>`_
* Add marginal costs for generators abroad and for carriers nuclear and coal
`#907 <https://github.com/openego/eGon-data/issues/907>`_
* Add wind off shore power plants for eGon100RE
`#868 <https://github.com/openego/eGon-data/issues/868>`_

.. _PR #159: https://github.com/openego/eGon-data/pull/159
.. _PR #703: https://github.com/openego/eGon-data/pull/703
Expand Down
80 changes: 49 additions & 31 deletions src/egon/data/datasets/power_plants/wind_offshore.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def insert():
"""
# Read file with all required input/output tables' names
cfg = egon.data.config.datasets()["power_plants"]

# load NEP2035_V2021_scnC2035 file
offshore_path = (
Path(".")
Expand All @@ -32,7 +32,12 @@ def insert():
offshore = pd.read_excel(
offshore_path,
sheet_name="WInd_Offshore_NEP",
usecols=["Netzverknuepfungspunkt", "Spannungsebene in kV", "C 2035"],
usecols=[
"Netzverknuepfungspunkt",
"Spannungsebene in kV",
"C 2035",
"B 2040 ",
],
)
offshore.dropna(subset=["Netzverknuepfungspunkt"], inplace=True)

Expand All @@ -48,7 +53,7 @@ def insert():
"Garrel/Ost": "23837631",
"Diele": "177829920",
"Dörpen/West": "142487746",
"Emden/Borßum": "34835258",
"Emden/Borßum": "34835258",
"Emden/Ost": "34835258",
"Hagermarsch": "79316833",
"Hanekenfähr": "61918154",
Expand All @@ -72,7 +77,7 @@ def insert():
"Garrel/Ost": "16139",
"Diele": "16138",
"Dörpen/West": "15952",
"Emden/Borßum": "15762",
"Emden/Borßum": "15762",
"Emden/Ost": "16140",
"Hagermarsch": "15951",
"Hanekenfähr": "16139",
Expand All @@ -98,39 +103,29 @@ def insert():
SELECT bus_i as bus_id, geom as point, CAST(osm_substation_id AS text)
as osm_id FROM {cfg["sources"]["buses_data"]}
"""

busses = gpd.GeoDataFrame.from_postgis(
sql, con, crs="EPSG:4326", geom_col="point"
)

# Drop NANs in column osm_id
busses.dropna(subset= ['osm_id'], inplace= True)
busses.dropna(subset=["osm_id"], inplace=True)

# Create columns for bus_id and geometry in the offshore df
offshore["bus_id"] = np.nan
offshore["geom"] = Point(0, 0)

# Match bus_id and geometry
for index, wind_park in offshore.iterrows():
if (
len(
busses[
busses["osm_id"] == wind_park["osm_id"]
].index
)
> 0
):
bus_ind = busses[
busses["osm_id"] == wind_park["osm_id"]
].index[0]
if len(busses[busses["osm_id"] == wind_park["osm_id"]].index) > 0:
bus_ind = busses[busses["osm_id"] == wind_park["osm_id"]].index[0]
offshore.at[index, "bus_id"] = busses.at[bus_ind, "bus_id"]
offshore.at[index, "geom"] = busses.at[bus_ind, "point"]
else:
print(f'Wind offshore farm not found: {wind_park["osm_id"]}')


offshore["weather_cell_id"] = offshore['Netzverknuepfungspunkt'].map(w_id)
offshore['weather_cell_id'] = offshore['weather_cell_id'].apply(int)

offshore["weather_cell_id"] = offshore["Netzverknuepfungspunkt"].map(w_id)
offshore["weather_cell_id"] = offshore["weather_cell_id"].apply(int)
# Drop offshore wind farms without found connexion point
offshore.dropna(subset=["bus_id"], inplace=True)

Expand All @@ -144,23 +139,47 @@ def insert():
offshore[offshore["Spannungsebene in kV"] > 110].index, "voltage_level"
] = 1

# Assign static values
offshore["carrier"] = "wind_offshore"
offshore["el_capacity"] = offshore["C 2035"]
offshore["scenario"] = "eGon2035"

# Delete unnecessary columns
offshore.drop(
[
"Netzverknuepfungspunkt",
"Spannungsebene in kV",
"C 2035",
"osm_id",
],
axis=1,
inplace=True,
)

# Assign static values
offshore["carrier"] = "wind_offshore"

# Create wind farms for the different scenarios
offshore_2035 = offshore.drop(columns=["B 2040 "]).copy()
offshore_2035["scenario"] = "eGon2035"
offshore_2035.rename(columns={"C 2035": "el_capacity"}, inplace=True)

offshore_100RE = offshore.drop(columns=["C 2035"]).copy()
offshore_100RE["scenario"] = "eGon100RE"
offshore_100RE.rename(columns={"B 2040 ": "el_capacity"}, inplace=True)

# Import capacity targets for wind_offshore per scenario
sql = f"""
SELECT * FROM {cfg["sources"]["capacities"]}
WHERE scenario_name = 'eGon100RE' AND
carrier = 'wind_offshore'
"""
capacities = pd.read_sql(sql, con)
cap_100RE = capacities.capacity.sum()

# Scale capacities to match target
scale_factor = cap_100RE / offshore_100RE.el_capacity.sum()
offshore_100RE["el_capacity"] = (
offshore_100RE["el_capacity"] * scale_factor
)

# Join power plants from the different scenarios
offshore = pd.concat([offshore_2035, offshore_100RE], axis=0)

# convert column "bus_id" and "voltage_level" to integer
offshore["bus_id"] = offshore["bus_id"].apply(int)
offshore["voltage_level"] = offshore["voltage_level"].apply(int)
Expand Down Expand Up @@ -204,5 +223,4 @@ def insert():
if_exists="append",
)

return 0

return "Off shore wind farms successfully created"

0 comments on commit 53ad2a7

Please sign in to comment.