Skip to content

Commit

Permalink
Merge pull request #168 from openego/fix/#59_import_generators
Browse files Browse the repository at this point in the history
Fix/#59 import generators
  • Loading branch information
AnyaHe authored Sep 15, 2020
2 parents d541836 + 3807731 commit 8df6773
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions edisgo/io/generators_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,20 @@ def _import_conv_generators(session):
orm_conv_generators.columns.id,
orm_conv_generators.columns.subst_id,
orm_conv_generators.columns.la_id,
orm_conv_generators.columns.capacity,
(orm_conv_generators.columns.capacity).label("electrical_capacity"),
orm_conv_generators.columns.type,
orm_conv_generators.columns.voltage_level,
orm_conv_generators.columns.fuel,
(orm_conv_generators.columns.fuel).label("generation_type"),
func.ST_AsText(
func.ST_Transform(orm_conv_generators.columns.geom, srid)
),
).label("geom"),
)
.filter(
orm_conv_generators.columns.subst_id
== edisgo_object.topology.mv_grid.id
)
.filter(
orm_conv_generators.columns.voltage_level.in_([4, 5, 6, 7])
orm_conv_generators.columns.voltage_level.in_([4, 5])
)
.filter(orm_conv_generators_version)
)
Expand Down Expand Up @@ -107,11 +107,6 @@ def _import_res_generators(session):
"""

# Create filter for generation technologies
# ToDo: This needs to be removed when all generators can be imported
types_filter = orm_re_generators.columns.generation_type.in_(
["solar", "wind"]
)

# build basic query
generators_sqla = (
Expand Down Expand Up @@ -139,7 +134,6 @@ def _import_res_generators(session):
== edisgo_object.topology.mv_grid.id
)
.filter(orm_re_generators_version)
.filter(types_filter)
)

# extend basic query for MV generators and read data from db
Expand Down Expand Up @@ -180,11 +174,6 @@ def _import_res_generators(session):

return generators_mv, generators_lv

logging.warning(
"Right now only solar and wind generators can be "
"imported from the oedb."
)

def _validate_generation():
"""
Validate generation capacity in updated grids.
Expand All @@ -200,8 +189,7 @@ def _validate_generation():
capacity_imported = (
generators_res_mv["electrical_capacity"].sum()
+ generators_res_lv["electrical_capacity"].sum()
) # + \
# generators_conv_mv['capacity'].sum()
) + generators_conv_mv['electrical_capacity'].sum()

capacity_grid = edisgo_object.topology.generators_df.p_nom.sum()

Expand Down Expand Up @@ -321,18 +309,18 @@ def _validate_sample_geno_location():

# get conventional and renewable generators
with session_scope() as session:
# generators_conv_mv = _import_conv_generators(session)
generators_conv_mv = _import_conv_generators(session)
generators_res_mv, generators_res_lv = _import_res_generators(session)

# generators_mv = generators_conv_mv.append(generators_res_mv)
generators_mv = generators_conv_mv.append(generators_res_mv)

# validate that imported generators are located inside the grid district
_validate_sample_geno_location()

update_grids(
edisgo_object=edisgo_object,
# generators_mv=generators_mv,
imported_generators_mv=generators_res_mv,
imported_generators_mv=generators_mv,
imported_generators_lv=generators_res_lv,
)

Expand Down

0 comments on commit 8df6773

Please sign in to comment.