Skip to content

Commit

Permalink
Merge pull request #891 from openego/features/#888-move-gas-voronoi-c…
Browse files Browse the repository at this point in the history
…lass-definition

Features/#888 move gas voronoi class definition
  • Loading branch information
AmeliaNadal committed Sep 29, 2022
2 parents 8a5f7f3 + 455f0a2 commit 7c19553
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 17 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,8 @@ Bug Fixes
`#781 <https://github.com/openego/eGon-data/issues/781>`_
* Add extendable batteries only to buses at substations
`#852 <https://github.com/openego/eGon-data/issues/852>`_
* Move class definition for grid.egon_gas_voronoi out of etrago_setup
`#888 <https://github.com/openego/eGon-data/issues/888>`_
* Temporarily set upper version limit for pandas
`#829 <https://github.com/openego/eGon-data/issues/829>`_
* Delete eMob MIT data from eTraGo tables on init
Expand Down
Empty file modified src/egon/data/airflow/airflow.cfg
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions src/egon/data/airflow/dags/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@

# Create gas voronoi eGon2035
create_gas_polygons_egon2035 = GasAreaseGon2035(
dependencies=[insert_hydrogen_buses, vg250]
dependencies=[setup_etrago, insert_hydrogen_buses, vg250]
)

# Insert hydrogen grid
Expand Down Expand Up @@ -411,7 +411,7 @@

# Create gas voronoi eGon100RE
create_gas_polygons_egon100RE = GasAreaseGon100RE(
dependencies=[insert_h2_grid, vg250]
dependencies=[create_gas_polygons_egon2035, insert_h2_grid, vg250]
)

# Import gas production
Expand Down
14 changes: 1 addition & 13 deletions src/egon/data/datasets/etrago_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class EtragoSetup(Dataset):
def __init__(self, dependencies):
super().__init__(
name="EtragoSetup",
version="0.0.8",
version="0.0.9",
dependencies=dependencies,
tasks=(create_tables, {temp_resolution, insert_carriers}),
)
Expand Down Expand Up @@ -391,16 +391,6 @@ class EgonPfHvBusmap(Base):
version = Column(Text, primary_key=True, nullable=False)


class EgonPfHvGasVoronoi(Base):
__tablename__ = "egon_gas_voronoi"
__table_args__ = {"schema": "grid"}

scn_name = Column(Text, primary_key=True, nullable=False)
bus_id = Column(BigInteger, primary_key=True, nullable=False)
carrier = Column(Text)
geom = Column(Geometry("GEOMETRY", 4326))


def create_tables():
"""Create tables for eTraGo input data.
Returns
Expand Down Expand Up @@ -505,7 +495,6 @@ def create_tables():
EgonPfHvTransformer.__table__.drop(bind=engine, checkfirst=True)
EgonPfHvTransformerTimeseries.__table__.drop(bind=engine, checkfirst=True)
EgonPfHvBusmap.__table__.drop(bind=engine, checkfirst=True)
EgonPfHvGasVoronoi.__table__.drop(bind=engine, checkfirst=True)
# Create new tables
EgonPfHvBus.__table__.create(bind=engine, checkfirst=True)
EgonPfHvBusTimeseries.__table__.create(bind=engine, checkfirst=True)
Expand All @@ -528,7 +517,6 @@ def create_tables():
bind=engine, checkfirst=True
)
EgonPfHvBusmap.__table__.create(bind=engine, checkfirst=True)
EgonPfHvGasVoronoi.__table__.create(bind=engine, checkfirst=True)


def temp_resolution():
Expand Down
25 changes: 23 additions & 2 deletions src/egon/data/datasets/gas_areas.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"""
from geoalchemy2.types import Geometry
from sqlalchemy import BigInteger, Column, Text
from sqlalchemy.ext.declarative import declarative_base

from egon.data import db
from egon.data.datasets import Dataset
Expand All @@ -12,9 +14,9 @@ class GasAreaseGon2035(Dataset):
def __init__(self, dependencies):
super().__init__(
name="GasAreaseGon2035",
version="0.0.1",
version="0.0.2",
dependencies=dependencies,
tasks=(voronoi_egon2035),
tasks=(create_gas_voronoi_table, voronoi_egon2035),
)


Expand All @@ -28,6 +30,25 @@ def __init__(self, dependencies):
)


Base = declarative_base()


class EgonPfHvGasVoronoi(Base):
__tablename__ = "egon_gas_voronoi"
__table_args__ = {"schema": "grid"}

scn_name = Column(Text, primary_key=True, nullable=False)
bus_id = Column(BigInteger, primary_key=True, nullable=False)
carrier = Column(Text)
geom = Column(Geometry("GEOMETRY", 4326))


def create_gas_voronoi_table():
engine = db.engine()
EgonPfHvGasVoronoi.__table__.drop(bind=engine, checkfirst=True)
EgonPfHvGasVoronoi.__table__.create(bind=engine, checkfirst=True)


def voronoi_egon2035():
"""
Create voronoi polygons for all gas carriers in eGon2035 scenario
Expand Down

0 comments on commit 7c19553

Please sign in to comment.