Skip to content

Commit

Permalink
Merge #474 into CI
Browse files Browse the repository at this point in the history
  • Loading branch information
fwitte committed Nov 12, 2021
2 parents 683b224 + a6b4c16 commit 48c2e06
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 30 deletions.
3 changes: 1 addition & 2 deletions src/egon/data/airflow/dags/pipeline.py
Expand Up @@ -11,6 +11,7 @@
from egon.data.datasets import database
from egon.data.datasets.calculate_dlr import Calculate_dlr
from egon.data.datasets.ch4_storages import CH4Storages
from egon.data.datasets.saltcavern import SaltcavernData
from egon.data.datasets.chp import Chp
from egon.data.datasets.chp_etrago import ChpEtrago
from egon.data.datasets.data_bundle import DataBundle
Expand Down Expand Up @@ -544,9 +545,7 @@
]
)


# HTS to etrago table
hts_etrago_table = HtsEtragoTable(
dependencies = [heat_time_series,mv_grid_districts,
district_heating_areas,heat_etrago])

11 changes: 6 additions & 5 deletions src/egon/data/datasets/ch4_storages.py
Expand Up @@ -100,18 +100,20 @@ def import_installed_ch4_storages():


def import_ch4_grid_capacity():
"""Define dataframe containing the gas storage modelling the ch4 grid storage capacity
"""Define dataframe containing the modelling of the CH4 grid storage
capacity. The whole storage capacity of the grid (130000 MWh, estimation of
the Bundesnetzagentur) is split uniformly between all the german CH4 nodes
of the grid. The capacities of the pipes are not considerated.
Returns
-------
Gas_storages_list :
Dataframe containing the gas stores in Germany modelling the gas grid storage capacity
"""
Gas_grid_capacity = 130000 # G.Volk "Die Herauforderung an die Bundesnetzagentur die Energiewende zu meistern" Berlin, Dec 2012
Gas_grid_capacity = 130000 # Storage capacity of the CH4 grid - G.Volk "Die Herauforderung an die Bundesnetzagentur die Energiewende zu meistern" Berlin, Dec 2012
N_ch4_nodes_G = ch4_nodes_number_G(define_gas_nodes_list()) # Number of nodes in Germany
print(N_ch4_nodes_G)
Store_capacity = Gas_grid_capacity / N_ch4_nodes_G
Store_capacity = Gas_grid_capacity / N_ch4_nodes_G # Storage capacity associated to each CH4 node of the german grid

sql_gas = """SELECT bus_id, scn_name, carrier, geom
FROM grid.egon_etrago_bus
Expand Down Expand Up @@ -154,7 +156,6 @@ def import_ch4_storages():
gas_storages_list = gas_storages_list.reset_index(drop=True)

# Insert data to db
print(gas_storages_list)
gas_storages_list.to_sql('egon_etrago_store',
engine,
schema ='grid',
Expand Down
88 changes: 65 additions & 23 deletions src/egon/data/datasets/hydrogen_etrago/storage.py
Expand Up @@ -150,40 +150,81 @@ def calculate_and_map_saltcavern_storage_potential():
geom_col="geometry",
)

# get saltcavern shapes
saltcavern_data = db.select_geodataframe(
f"""SELECT * FROM
{sources['saltcaverns']['schema']}.
{sources['saltcaverns']['table']}
""",
geom_col="geometry",
)

# hydrogen storage potential data from InSpEE-DS report
hydrogen_storage_potential = pd.DataFrame(
columns=["federal_state", "INSPEEDS", "INSPEE"]
columns=["INSPEEDS", "INSPEE"]
)

# values in MWh, modified to fit the saltstructure data
hydrogen_storage_potential.loc[0] = ["Brandenburg", 353e6, 159e6]
hydrogen_storage_potential.loc[1] = ["Niedersachsen", 253e6, 702e6]
hydrogen_storage_potential.loc[2] = ["Schleswig-Holstein", 0, 413e6]
hydrogen_storage_potential.loc[3] = ["Mecklenburg-Vorpommern", 25e6, 193e6]
hydrogen_storage_potential.loc[4] = ["Nordrhein-Westfalen", 168e6, 0]
hydrogen_storage_potential.loc[5] = ["Sachsen-Anhalt", 318e6, 1614e6]
hydrogen_storage_potential.loc[6] = ["Thüringen", 595e6, 1614e6]
hydrogen_storage_potential.loc["Brandenburg"] = [353e6, 159e6]
hydrogen_storage_potential.loc["Mecklenburg-Vorpommern"] = [25e6, 193e6]
hydrogen_storage_potential.loc["Nordrhein-Westfalen"] = [168e6, 0]
hydrogen_storage_potential.loc["Sachsen-Anhalt"] = [318e6, 147e6]
hydrogen_storage_potential.loc["Thüringen"] = [595e6, 0]

# distribute SH/HH and NDS/HB potentials by area
# overlay saltstructures with federal state, calculate respective area
# map storage potential per federal state to area fraction of summed area
# potential_i = area_i / area_tot * potential_tot
pot_nds_hb = [253e6, 702e6]
pot_sh_hh = [0, 413e6]

potential_data_dict = {
0: {
"federal_states": ["Schleswig-Holstein", "Hamburg"],
"INSPEEDS": 0, "INSPEE": 413e6
},
1: {
"federal_states": ["Niedersachsen", "Bremen"],
"INSPEEDS": 253e6, "INSPEE": 702e6
}
}

# iterate over aggregated state data for SH/HH and NDS/HB
for data in potential_data_dict.values():
individual_areas = {}
# individual state areas
for federal_state in data["federal_states"]:
individual_areas[federal_state] = saltcavern_data.overlay(
vg250_data[vg250_data["gen"] == federal_state],
how="intersection"
).to_crs(epsg=25832).area.sum()

# derives weights from fraction of individual state area to total area
total_area = sum(individual_areas.values())
weights = {
f: individual_areas[f] / total_area if total_area > 0 else 0
for f in data["federal_states"]
}
# write data into potential dataframe
for federal_state in data["federal_states"]:
hydrogen_storage_potential.loc[federal_state] = (
[
data["INSPEEDS"] * weights[federal_state],
data["INSPEE"] * weights[federal_state]
]
)

# calculate total storage potential
hydrogen_storage_potential["total"] = (
# currently only InSpEE saltstructure shapefiles are available
# hydrogen_storage_potential["INSPEEDS"]
hydrogen_storage_potential["INSPEE"]
)

# get saltcavern shapes
saltcavern_data = db.select_geodataframe(
f"""SELECT * FROM
{sources['saltcaverns']['schema']}.
{sources['saltcaverns']['table']}
""",
geom_col="geometry",
)

saltcaverns_in_fed_state = gpd.GeoDataFrame()

# intersection of saltstructures with federal state
for row in hydrogen_storage_potential.index:
federal_state = hydrogen_storage_potential.loc[row, "federal_state"]
for federal_state in hydrogen_storage_potential.index:
federal_state_data = vg250_data[vg250_data["gen"] == federal_state]

# skip if federal state not available (e.g. local testing)
Expand All @@ -193,9 +234,10 @@ def calculate_and_map_saltcavern_storage_potential():
)
# write total potential in column, will be overwritten by actual
# value later
saltcaverns_in_fed_state[
saltcaverns_in_fed_state.loc[
saltcaverns_in_fed_state["gen"] == federal_state,
"potential"
] = hydrogen_storage_potential.loc[row, "total"]
] = hydrogen_storage_potential.loc[federal_state, "total"]

# drop all federal state data columns except name of the state
saltcaverns_in_fed_state.drop(
Expand Down Expand Up @@ -227,7 +269,7 @@ def calculate_and_map_saltcavern_storage_potential():
SELECT * FROM grid.egon_hvmv_substation_voronoi
""",
index_col="bus_id",
).to_crs(4326)
).to_crs(4326).sort_index()

# get substations
substations = db.select_geodataframe(
Expand All @@ -241,7 +283,7 @@ def calculate_and_map_saltcavern_storage_potential():
# epsg for buffer in line with original saltstructre data
substations_inflation = gpd.GeoDataFrame(
geometry=substations.to_crs(25832).buffer(500).to_crs(4326)
)
).sort_index()

# !!row wise!! intersection between the substations inflation and the
# respective voronoi (overlay only allows for intersection to all
Expand Down

0 comments on commit 48c2e06

Please sign in to comment.