Skip to content

Commit

Permalink
Merge branch 'features/#1095-mastr-status-quo' into continuous-integr…
Browse files Browse the repository at this point in the history
…ation/run-everything-2022-11-10
  • Loading branch information
khelfen committed Mar 30, 2023
2 parents 06ce2a0 + 64c68b0 commit b4e54ca
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,8 @@ Changed
`#1110 <https://github.com/openego/eGon-data/issues/1110>`_
* Use MaStR geocoding results for pv rooftop to buildings mapping workflow
`#1095 <https://github.com/openego/eGon-data/issues/1095>`_
* Rename eMob MIT carrier names (use underscores)
`#1105 <https://github.com/openego/eGon-data/issues/1105>`_

.. _#799: https://github.com/openego/eGon-data/issues/799

Expand Down
2 changes: 1 addition & 1 deletion src/egon/data/datasets/power_plants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class PowerPlants(Dataset):
def __init__(self, dependencies):
super().__init__(
name="PowerPlants",
version="0.0.17",
version="0.0.18",
dependencies=dependencies,
tasks=(
create_tables,
Expand Down
11 changes: 6 additions & 5 deletions src/egon/data/datasets/power_plants/mastr.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,11 @@ def import_mastr() -> None:

units = units.loc[units.geometry.within(boundary)]

logger.debug(
f"{init_len - len(units)}/{init_len} "
f"({((init_len - len(units)) / init_len) * 100: g} %) dropped."
)
if init_len > 0:
logger.debug(
f"{init_len - len(units)}/{init_len} "
f"({((init_len - len(units)) / init_len) * 100: g} %) dropped."
)

# drop unnecessary and rename columns
logger.debug("Reformatting...")
Expand All @@ -499,7 +500,7 @@ def import_mastr() -> None:
units["voltage_level"] = units.voltage_level.fillna(-1).astype(int)

units.set_geometry("geom", inplace=True)
units["id"] = range(0, len(units))
units["id"] = range(len(units))

# change capacity unit: kW to MW
units["capacity"] = units["capacity"] / 1e3
Expand Down
42 changes: 41 additions & 1 deletion src/egon/data/datasets/power_plants/pv_rooftop_buildings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2182,6 +2182,46 @@ def add_bus_ids_sq(
return buildings_gdf


def infer_voltage_level(
units_gdf: gpd.GeoDataFrame,
) -> gpd.GeoDataFrame:
"""
Infer nan values in voltage level derived from generator capacity to
the power plants.
Parameters
-----------
units_gdf : geopandas.GeoDataFrame
GeoDataFrame containing units with voltage levels from MaStR
Returnsunits_gdf: gpd.GeoDataFrame
-------
geopandas.GeoDataFrame
GeoDataFrame containing units all having assigned a voltage level.
"""

def voltage_levels(p: float) -> int:
if p <= 0.1:
return 7
elif p <= 0.2:
return 6
elif p <= 5.5:
return 5
elif p <= 20:
return 4
elif p <= 120:
return 3
return 1

units_gdf["voltage_level_inferred"] = False
mask = units_gdf.voltage_level.isna()
units_gdf.loc[mask, "voltage_level_inferred"] = True
units_gdf.loc[mask, "voltage_level"] = units_gdf.loc[mask].capacity.apply(
voltage_levels
)

return units_gdf


def pv_rooftop_to_buildings():
"""Main script, executed as task"""

Expand Down Expand Up @@ -2234,4 +2274,4 @@ def pv_rooftop_to_buildings():
all_buildings_gdf = add_bus_ids_sq(all_buildings_gdf)

# export scenario
create_scenario_table(all_buildings_gdf)
create_scenario_table(infer_voltage_level(all_buildings_gdf))

0 comments on commit b4e54ca

Please sign in to comment.