Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features/#392 include powerplants #453

Merged
merged 26 commits into from
Nov 2, 2021
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9ba6a89
First implementation to import power plants from NEP
IlkaCu Aug 31, 2021
412fa24
Add city and plz to egon_mastr_conventional_without_chp table
IlkaCu Sep 2, 2021
6a03f6d
Add code to import remaining power plants
IlkaCu Sep 2, 2021
3268186
Apply matching function
IlkaCu Sep 6, 2021
e49fd15
Add federal state to mastr data
IlkaCu Sep 21, 2021
57541db
Match NEP carriers to eGon carriers and rename table
ClaraBuettner Sep 21, 2021
9794743
Adjust table renaming in power plants dataset
IlkaCu Sep 23, 2021
7019ed2
Include loop to cover all carriers
IlkaCu Sep 23, 2021
a113515
Integrate methods into workflow, renaming module and fix data export
IlkaCu Sep 24, 2021
e1fc62e
Move function to __init__.py
IlkaCu Sep 24, 2021
c65df8d
Increase version number
IlkaCu Sep 24, 2021
cf92500
Merge dev into features branch
IlkaCu Sep 24, 2021
432585d
Update CHANGELOG.rst
IlkaCu Sep 24, 2021
9341555
Remove duplicate imports
IlkaCu Sep 24, 2021
2bffb51
üMerge branch 'features/#392-include-powerplants' of https://github.c…
IlkaCu Sep 24, 2021
bcd426f
Remove delete statement from loop
IlkaCu Sep 30, 2021
446c4a7
Increase version number
IlkaCu Sep 30, 2021
2e8ed77
Code formatting using black
IlkaCu Sep 30, 2021
e0acd6b
Merge dev into features branch
IlkaCu Sep 30, 2021
54eaee0
Adjust print statement and increase version number
IlkaCu Oct 4, 2021
10a3242
Merge branch 'dev' into features/#392-include-powerplants
ClaraBuettner Oct 6, 2021
85351f9
Fix dependency bug
IlkaCu Oct 7, 2021
3687de4
Add missing dependency
IlkaCu Nov 2, 2021
b649188
Move power plants part to another section
IlkaCu Nov 2, 2021
03a63b4
Merge dev into features branch
IlkaCu Nov 2, 2021
6459deb
Apply black and isort
IlkaCu Nov 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add federal state to mastr data
  • Loading branch information
IlkaCu committed Sep 21, 2021
commit e49fd1518a3690d511a264b372754f45a0ae383d
41 changes: 31 additions & 10 deletions src/egon/data/datasets/power_plants/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

import pandas as pd
import geopandas
import geopandas as gpd
import egon.data.config
from egon.data import db, config
from egon.data.datasets.power_plants import (
Expand Down Expand Up @@ -119,6 +119,25 @@ def select_no_chp_combustion_mastr(carrier):
mastr.EinheitMastrNummer = mastr.EinheitMastrNummer.str.slice(stop=15)
mastr = mastr.merge(MaStR_konv, how="left", left_on=["EinheitMastrNummer"], right_on=["EinheitMastrNummer"] )

# Import geodataframe on federal states and their borders

fs = db.select_geodataframe(
f"""
SELECT gen,
geometry
FROM {cfg['sources']['geom_federal_states']}
WHERE gf = 4;
""",
index_col= None,
geom_col='geometry',
epsg = 4326
)

# Spatial join to add name of federal state to dataframe containing MaStR data

mastr = gpd.sjoin(mastr, fs, how='inner', op='intersects').drop(columns=['index_right']).rename(columns={'gen':'federal_state'})


return mastr

def match_nep_no_chp(nep, mastr, matched, buffer_capacity=0.1,
Expand Down Expand Up @@ -151,20 +170,20 @@ def match_nep_no_chp(nep, mastr, matched, buffer_capacity=0.1,
list_federal_states = pd.Series(
{"Hamburg": "HH",
"Sachsen": "SN",
"MecklenburgVorpommern": "MV",
"Thueringen": "TH",
"SchleswigHolstein": "SH",
"Mecklenburg-Vorpommern": "MV",
"Thüringen": "TH",
"Schleswig-Holstein": "SH",
"Bremen": "HB",
"Saarland": "SL",
"Bayern": "BY",
"BadenWuerttemberg": "BW",
"Baden-Württemberg": "BW",
"Brandenburg": "BB",
"Hessen": "HE",
"NordrheinWestfalen": "NW",
"Nordrhein-Westfalen": "NW",
"Berlin": "BE",
"Niedersachsen": "NI",
"SachsenAnhalt": "ST",
"RheinlandPfalz": "RP"})
"Sachsen-Anhalt": "ST",
"Rheinland-Pfalz": "RP"})

for ET in nep['carrier'].unique():

Expand Down Expand Up @@ -209,7 +228,7 @@ def match_nep_no_chp(nep, mastr, matched, buffer_capacity=0.1,
# If a plant could be matched, add this to matched
if len(selected) > 0:
matched = matched.append(
geopandas.GeoDataFrame(
gpd.GeoDataFrame(
data = {
'source': 'MaStR scaled with NEP 2021 list',
'MaStRNummer': selected.EinheitMastrNummer.head(1),
Expand All @@ -232,6 +251,8 @@ def match_nep_no_chp(nep, mastr, matched, buffer_capacity=0.1,

def merge_nep_mastr():

carrier = []

cfg = egon.data.config.datasets()["power_plants"]

nep = select_nep_power_plants('Mineralöl-\nprodukte')
Expand All @@ -243,7 +264,7 @@ def merge_nep_mastr():
), cfg)

# Initalize DataFrame for matching power plants
matched = geopandas.GeoDataFrame(
matched = gpd.GeoDataFrame(
columns = [
'carrier','chp','el_capacity','th_capacity', 'scenario','geometry',
'MaStRNummer', 'source', 'voltage_level'])
Expand Down