Skip to content

Commit

Permalink
Merge pull request #478 into dev
Browse files Browse the repository at this point in the history
Merge into dev since the CI run was successful
  • Loading branch information
fwitte authored Dec 14, 2021
2 parents 243464d + 2bedb4a commit 0a7e517
Show file tree
Hide file tree
Showing 16 changed files with 1,136 additions and 253 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ Added
`#498 <https://github.com/openego/eGon-data/issues/498>`_
* Include feedin time series for wind offshore
`#531 <https://github.com/openego/eGon-data/issues/531>`_
* Include hydrogen infrastructure for eGon2035 scenario
`#474 <https://github.com/openego/eGon-data/issues/474>`_

.. _PR #159: https://github.com/openego/eGon-data/pull/159

Expand Down
40 changes: 30 additions & 10 deletions src/egon/data/airflow/dags/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from egon.data import db
from egon.data.config import set_numexpr_threads
from egon.data.datasets import database
from egon.data.datasets.saltcavern import SaltcavernData
from egon.data.datasets.calculate_dlr import Calculate_dlr
from egon.data.datasets.ch4_storages import CH4Storages
from egon.data.datasets.chp import Chp
Expand All @@ -25,13 +26,18 @@
from egon.data.datasets.era5 import WeatherData
from egon.data.datasets.etrago_setup import EtragoSetup
from egon.data.datasets.fill_etrago_gen import Egon_etrago_gen
from egon.data.datasets.gas_areas import GasAreas
from egon.data.datasets.gas_grid import GasNodesandPipes
from egon.data.datasets.gas_prod import CH4Production
from egon.data.datasets.heat_demand import HeatDemandImport
from egon.data.datasets.heat_demand_timeseries.HTS import HeatTimeSeries
from egon.data.datasets.heat_etrago import HeatEtrago
from egon.data.datasets.heat_etrago.hts_etrago import HtsEtragoTable
from egon.data.datasets.heat_supply import HeatSupply
from egon.data.datasets.hydrogen_etrago import (
HydrogenBusEtrago, HydrogenStoreEtrago, HydrogenMethaneLinkEtrago,
HydrogenPowerLinkEtrago
)
from egon.data.datasets.hh_demand_profiles import (
hh_demand_setup,
houseprofiles_in_census_cells,
Expand Down Expand Up @@ -59,12 +65,6 @@
from egon.data.datasets.zensus import ZensusPopulation, ZensusMiscellaneous
from egon.data.datasets.zensus_mv_grid_districts import ZensusMvGridDistricts
from egon.data.datasets.zensus_vg250 import ZensusVg250
from egon.data.processing.gas_areas import GasAreas
from egon.data.processing.power_to_h2 import PowertoH2
import egon.data.datasets.gas_grid as gas_grid
import egon.data.processing.gas_areas as gas_areas
import egon.data.processing.power_to_h2 as power_to_h2


# Set number of threads used by numpy and pandas
set_numexpr_threads()
Expand Down Expand Up @@ -144,6 +144,8 @@
"electricity_demand.distribute-household-demands"
]

saltcavern_storage = SaltcavernData(dependencies=[data_bundle, vg250])

# NEP data import
scenario_capacities = ScenarioCapacities(
dependencies=[setup, vg250, data_bundle, zensus_population]
Expand Down Expand Up @@ -199,14 +201,32 @@
dependencies=[etrago_input_data, download_data_bundle, osmtgmod_pypsa]
)

# Power-to-gas installations creation
insert_power_to_h2_installations = PowertoH2(
dependencies=[gas_grid_insert_data]
# Insert hydrogen buses
insert_hydrogen_buses = HydrogenBusEtrago(
dependencies=[
saltcavern_storage,
gas_grid_insert_data,
substation_voronoi
]
)

# H2 steel tanks and saltcavern storage
insert_H2_storage = HydrogenStoreEtrago(
dependencies=[insert_hydrogen_buses])

# Power-to-gas-to-power chain installations
insert_power_to_h2_installations = HydrogenPowerLinkEtrago(
dependencies=[insert_hydrogen_buses, ]
)

# Link between methane grid and respective hydrogen buses
insert_h2_to_ch4_grid_links = HydrogenMethaneLinkEtrago(
dependencies=[insert_hydrogen_buses, ]
)

# Create gas voronoi
create_gas_polygons = GasAreas(
dependencies=[gas_grid_insert_data, vg250_clean_and_prepare]
dependencies=[insert_hydrogen_buses, vg250_clean_and_prepare]
)

# Gas prod import
Expand Down
40 changes: 40 additions & 0 deletions src/egon/data/datasets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ vg250:
"VG250_KRS.shp": "vg250_krs"
"VG250_VWG.shp": "vg250_vwg"
"VG250_GEM.shp": "vg250_gem"

bgr:
processed:
schema: "boundaries"
file_table_map:
"Potenzialbewertung_InSpEE_InSpEE_DS.shp": "saltstructures_inspee"
sources:
vg250_federal_states:
schema: 'boundaries'
table: 'vg250_lan'
saltcaverns:
schema: 'boundaries'
table: 'saltstructures_inspee'
targets:
storage_potential:
schema: 'grid'
table: 'egon_saltstructures_storage_potential'

zensus_population:
original_data:
source:
Expand Down Expand Up @@ -574,6 +592,28 @@ etrago_heat:
schema: 'grid'
table: 'egon_etrago_link_timeseries'

etrago_hydrogen:
sources:
saltcavern_data:
schema: 'grid'
table: 'egon_saltstructures_storage_potential'
buses:
schema: 'grid'
table: 'egon_etrago_bus'
H2_AC_map:
schema: 'grid'
table: 'egon_etrago_ac_h2'
targets:
hydrogen_buses:
schema: 'grid'
table: 'egon_etrago_bus'
hydrogen_links:
schema: 'grid'
table: 'egon_etrago_link'
hydrogen_stores:
schema: 'grid'
table: 'egon_etrago_store'

industrial_sites:
sources:
hotmaps:
Expand Down
74 changes: 44 additions & 30 deletions src/egon/data/datasets/ch4_storages.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@ def __init__(self, dependencies):
tasks=(import_ch4_storages),
)

def import_installed_ch4_storages():
def import_installed_ch4_storages(scn_name):
"""Define dataframe containing the ch4 storage units in Germany from the SciGRID_gas data
Parameters
----------
scn_name : str
Name of the scenario
Returns
-------
Gas_storages_list :
Expand Down Expand Up @@ -85,10 +90,10 @@ def import_installed_ch4_storages():

# Match to associated gas bus
Gas_storages_list = Gas_storages_list.reset_index(drop=True)
Gas_storages_list = assign_ch4_bus_id(Gas_storages_list)
Gas_storages_list = assign_ch4_bus_id(Gas_storages_list, scn_name)

# Add missing columns
c = {'scn_name':'eGon2035', 'carrier':'CH4'}
c = {'scn_name': scn_name, 'carrier': 'CH4'}
Gas_storages_list = Gas_storages_list.assign(**c)

# Remove useless columns
Expand All @@ -99,58 +104,67 @@ def import_installed_ch4_storages():
return Gas_storages_list


def import_ch4_grid_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
def import_ch4_grid_capacity(scn_name):
"""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.
Parameters
----------
scn_name : str
Name of the scenario.
Returns
-------
Gas_storages_list :
Dataframe containing the gas stores in Germany modelling the gas grid storage capacity
"""
"""
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
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

sql_gas = f"""SELECT bus_id, scn_name, carrier, geom
FROM grid.egon_etrago_bus
WHERE carrier = 'CH4';"""
WHERE carrier = 'CH4' AND scn_name = '{scn_name}'
AND country = 'DE';"""
Gas_storages_list = db.select_geodataframe(sql_gas, epsg=4326)
# Add missing column

# Add missing column
Gas_storages_list['e_nom'] = Store_capacity
Gas_storages_list['bus'] = Gas_storages_list['bus_id']

# Remove useless columns
Gas_storages_list = Gas_storages_list.drop(columns=['bus_id', 'geom'])

return Gas_storages_list
return Gas_storages_list


def import_ch4_storages():
"""Insert list of gas storages units in database
Returns
-------
None.
"""
"""
# Connect to local database
engine = db.engine()

# TODO move this to function call, how to do it is directly called in task list?
scn_name = "eGon2035"

# Clean table
db.execute_sql(
f"""
DELETE FROM grid.egon_etrago_store WHERE "carrier" = 'CH4'
AND scn_name = '{scn_name}';
"""
DELETE FROM grid.egon_etrago_store WHERE "carrier" = 'CH4';
"""
)

)

# Select next id value
new_id = db.next_etrago_id('store')

gas_storages_list = pd.concat([import_installed_ch4_storages(), import_ch4_grid_capacity()])

gas_storages_list = pd.concat([
import_installed_ch4_storages(scn_name),
import_ch4_grid_capacity(scn_name)
])
gas_storages_list['store_id'] = range(new_id, new_id + len(gas_storages_list))

gas_storages_list = gas_storages_list.reset_index(drop=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class EgonH2VoronoiTmp(Base):
geom = Column(Geometry("Polygon", 4326))


def create_CH4_voronoi():
def create_CH4_voronoi(scn_name='eGon2035'):
"""
Creates voronoi polygons for CH4 buses
Expand All @@ -69,6 +69,7 @@ def create_CH4_voronoi():
engine = db.engine()
EgonCH4VoronoiTmp.__table__.create(bind=engine, checkfirst=True)

# TODO: do we need scn_name as column here?
db.execute_sql(
"""
DROP TABLE IF EXISTS grid.egon_voronoi_ch4 CASCADE;
Expand All @@ -81,14 +82,14 @@ def create_CH4_voronoi():
)

db.execute_sql(
"""
f"""
DROP TABLE IF EXISTS grid.egon_ch4_bus CASCADE;
SELECT bus_id, bus_id as id, geom as point
INTO grid.egon_ch4_bus
FROM grid.egon_etrago_bus
WHERE carrier = 'CH4';
WHERE carrier = 'CH4' AND scn_name = '{scn_name}'
AND country = 'DE';
"""
)

Expand Down Expand Up @@ -168,7 +169,7 @@ def create_CH4_voronoi():
)


def create_H2_voronoi():
def create_H2_voronoi(scn_name='eGon2035'):
"""
Creates voronoi polygons for H2 buses
Expand Down Expand Up @@ -200,14 +201,14 @@ def create_H2_voronoi():
)

db.execute_sql(
"""
f"""
DROP TABLE IF EXISTS grid.egon_h2_bus CASCADE;
SELECT bus_id, bus_id as id, geom as point
INTO grid.egon_h2_bus
FROM grid.egon_etrago_bus
WHERE carrier = 'H2';
WHERE carrier LIKE 'H2%%' AND scn_name = '{scn_name}'
AND country = 'DE';
"""
)

Expand Down
Loading

0 comments on commit 0a7e517

Please sign in to comment.