Skip to content

Commit

Permalink
Merge branch features/#474
Browse files Browse the repository at this point in the history
  • Loading branch information
fwitte committed Nov 5, 2021
2 parents 794c1e6 + 56c4540 commit c6b8992
Show file tree
Hide file tree
Showing 12 changed files with 1,031 additions and 196 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Expand Up @@ -166,6 +166,10 @@ Added
`#485 <https://github.com/openego/eGon-data/issues/485>`_
* Include biomass CHP plants to eTraGo tables
`#498 <https://github.com/openego/eGon-data/issues/498>`_
* Include allocation of conventional (non CHP) power plants
`#392 <https://github.com/openego/eGon-data/issues/392>`_
* 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 Expand Up @@ -249,6 +253,8 @@ Changed
`#335 <https://github.com/openego/eGon-data/issues/335>`_
* Apply black and isort for all python scripts
`#463 <https://github.com/openego/eGon-data/issues/463>`_
* Update deposit id for zenodo download
`#397 <https://github.com/openego/eGon-data/issues/498>`_


Bug fixes
Expand Down
37 changes: 32 additions & 5 deletions src/egon/data/airflow/dags/pipeline.py
Expand Up @@ -9,8 +9,12 @@
from egon.data import db
from egon.data.config import set_numexpr_threads
from egon.data.datasets import database
<<<<<<< HEAD
from egon.data.datasets.calculate_dlr import Calculate_dlr
from egon.data.datasets.ch4_storages import CH4Storages
=======
from egon.data.datasets.saltcavern import SaltcavernData
>>>>>>> features/#474-insert-hydrogen-infrastructure
from egon.data.datasets.chp import Chp
from egon.data.datasets.chp_etrago import ChpEtrago
from egon.data.datasets.data_bundle import DataBundle
Expand All @@ -25,6 +29,11 @@
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_prod import CH4Production
from egon.data.processing.gas_areas import GasAreas
from egon.data.datasets.ch4_storages import CH4Storages
from egon.data.processing.h2_to_ch4 import H2toCH4toH2
from egon.data.processing.power_to_h2 import PowertoH2toPower
from egon.data.datasets.gas_grid import GasNodesandPipes
from egon.data.datasets.gas_prod import CH4Production
from egon.data.datasets.heat_demand import HeatDemandImport
Expand All @@ -35,6 +44,9 @@
from egon.data.datasets.hh_demand_buildings import (
map_houseprofiles_to_buildings,
)
from egon.data.datasets.hydrogen_etrago import (
HydrogenBusEtrago, HydrogenStoreEtrago
)
from egon.data.datasets.hh_demand_profiles import (
hh_demand_setup,
houseprofiles_in_census_cells,
Expand Down Expand Up @@ -181,6 +193,8 @@
"electricity_demand.distribute-household-demands"
]

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

# NEP data import
scenario_capacities = ScenarioCapacities(
dependencies=[setup, vg250, data_bundle]
Expand Down Expand Up @@ -273,14 +287,27 @@
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])

# 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 = PowertoH2toPower(
dependencies=[insert_hydrogen_buses, ]
)

# Link between methane grid and respective hydrogen buses
insert_h2_to_ch4_grid_links = H2toCH4toH2(
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 Expand Up @@ -325,7 +352,7 @@
feedin_wind_onshore = tasks["renewable_feedin.wind"]
feedin_pv = tasks["renewable_feedin.pv"]
feedin_solar_thermal = tasks["renewable_feedin.solar-thermal"]

# District heating areas demarcation
district_heating_areas = DistrictHeatingAreas(
dependencies=[heat_demand_Germany, scenario_parameters]
Expand Down
42 changes: 41 additions & 1 deletion src/egon/data/datasets.yml
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:
"saltstructures_updated.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 @@ -474,7 +492,7 @@ solar_rooftop:
data-bundle:
sources:
zenodo:
deposit_id: 5211145
deposit_id: 5645351
targets:
file:
'data_bundle_egon_data.zip'
Expand Down Expand Up @@ -568,6 +586,28 @@ etrago_heat:
schema: 'grid'
table: 'egon_etrago_link'

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
8 changes: 4 additions & 4 deletions src/egon/data/datasets/ch4_storages.py
Expand Up @@ -8,7 +8,7 @@
import geopandas

from egon.data.datasets.gas_prod import assign_ch4_bus_id
from egon.data.datasets.gas_grid import define_gas_nodes_list
from egon.data.datasets.gas_grid import ch4_nodes_number_G, define_gas_nodes_list
from egon.data import db
from egon.data.config import settings
from egon.data.datasets import Dataset
Expand Down Expand Up @@ -109,9 +109,9 @@ def import_ch4_grid_capacity():
"""
Gas_grid_capacity = 130000 # G.Volk "Die Herauforderung an die Bundesnetzagentur die Energiewende zu meistern" Berlin, Dec 2012
N_gas_nodes = len(define_gas_nodes_list()) # Number of nodes in Germany
print(N_gas_nodes)
Store_capacity = Gas_grid_capacity / N_gas_nodes
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

sql_gas = """SELECT bus_id, scn_name, carrier, geom
FROM grid.egon_etrago_bus
Expand Down
59 changes: 22 additions & 37 deletions src/egon/data/datasets/gas_grid.py
Expand Up @@ -103,6 +103,26 @@ def define_gas_nodes_list():
return gas_nodes_list


def ch4_nodes_number_G(gas_nodes_list):
"""Insert list of CH4 nodes from SciGRID_gas IGGIELGN data
Parameters
----------
gas_nodes_list : dataframe
Dataframe containing the gas nodes (Europe)
Returns
-------
N_ch4_nodes_G : int
Number of CH4 buses in Germany (independantly from the mode used)
"""

ch4_nodes_list = gas_nodes_list[
gas_nodes_list["country_code"].str.match("DE")
] # A remplacer evtmt par un test sur le NUTS0 ?
N_ch4_nodes_G = len(ch4_nodes_list)

return N_ch4_nodes_G


def insert_CH4_nodes_list(gas_nodes_list):
"""Insert list of CH4 nodes from SciGRID_gas IGGIELGN data
Parameters
Expand All @@ -111,14 +131,15 @@ def insert_CH4_nodes_list(gas_nodes_list):
Dataframe containing the gas nodes (Europe)
Returns
-------
None.
None
"""
# Connect to local database
engine = db.engine()

gas_nodes_list = gas_nodes_list[
gas_nodes_list["country_code"].str.match("DE")
] # A remplacer evtmt par un test sur le NUTS0 ?

# Cut data to federal state if in testmode
NUTS1 = []
for index, row in gas_nodes_list.iterrows():
Expand Down Expand Up @@ -176,7 +197,6 @@ def insert_CH4_nodes_list(gas_nodes_list):
db.execute_sql(
"""
DELETE FROM grid.egon_etrago_bus WHERE "carrier" = 'CH4';
DELETE FROM grid.egon_etrago_bus WHERE "carrier" = 'H2';
"""
)

Expand All @@ -192,40 +212,6 @@ def insert_CH4_nodes_list(gas_nodes_list):
)


def insert_H2_nodes_list():
"""Insert the H2 buses to db, same buses than the CH4 buses
Returns
-------
None.
"""
# Connect to local database
engine = db.engine()

# Select the CH4 buses
sql_CH4 = """SELECT bus_id, scn_name, geom
FROM grid.egon_etrago_bus
WHERE carrier = 'CH4';"""

gdf_H2 = db.select_geodataframe(sql_CH4, epsg=4326)

# Select next id value
new_id = db.next_etrago_id("bus")

gdf_H2["carrier"] = "H2"
gdf_H2["bus_id"] = range(new_id, new_id + len(gdf_H2))

# Insert H2 data to db
print(gdf_H2)
gdf_H2.to_postgis(
"egon_etrago_bus",
engine,
schema="grid",
index=False,
if_exists="append",
dtype={"geom": Geometry()},
)


def insert_gas_pipeline_list(gas_nodes_list):
"""Insert list of gas pipelines from SciGRID_gas IGGIELGN data
Parameters
Expand Down Expand Up @@ -466,6 +452,5 @@ def insert_gas_data():
gas_nodes_list = define_gas_nodes_list()

insert_CH4_nodes_list(gas_nodes_list)
insert_H2_nodes_list()

insert_gas_pipeline_list(gas_nodes_list)

0 comments on commit c6b8992

Please sign in to comment.