diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 454d73f8f..57829de8f 100755 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -502,6 +502,8 @@ Changed `#1110 `_ * Use MaStR geocoding results for pv rooftop to buildings mapping workflow `#1095 `_ +* Rename eMob MIT carrier names (use underscores) + `#1105 `_ .. _#799: https://github.com/openego/eGon-data/issues/799 diff --git a/src/egon/data/datasets/power_plants/__init__.py b/src/egon/data/datasets/power_plants/__init__.py index 672431240..71213e66f 100755 --- a/src/egon/data/datasets/power_plants/__init__.py +++ b/src/egon/data/datasets/power_plants/__init__.py @@ -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, diff --git a/src/egon/data/datasets/power_plants/mastr.py b/src/egon/data/datasets/power_plants/mastr.py index 19f2d9b36..225c7c685 100644 --- a/src/egon/data/datasets/power_plants/mastr.py +++ b/src/egon/data/datasets/power_plants/mastr.py @@ -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...") @@ -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 diff --git a/src/egon/data/datasets/power_plants/pv_rooftop_buildings.py b/src/egon/data/datasets/power_plants/pv_rooftop_buildings.py index 9794b19dc..0c625a992 100644 --- a/src/egon/data/datasets/power_plants/pv_rooftop_buildings.py +++ b/src/egon/data/datasets/power_plants/pv_rooftop_buildings.py @@ -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""" @@ -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))