Code Duplication    Length = 38-38 lines in 2 locations

src/egon/data/datasets/power_plants/pv_rooftop_buildings.py 1 location

@@ 2311-2348 (lines=38) @@
2308
    return buildings_gdf
2309
2310
2311
def infer_voltage_level(
2312
    units_gdf: gpd.GeoDataFrame,
2313
) -> gpd.GeoDataFrame:
2314
    """
2315
    Infer nan values in voltage level derived from generator capacity to
2316
    the power plants.
2317
2318
    Parameters
2319
    -----------
2320
    units_gdf : geopandas.GeoDataFrame
2321
        GeoDataFrame containing units with voltage levels from MaStR
2322
    Returnsunits_gdf: gpd.GeoDataFrame
2323
    -------
2324
    geopandas.GeoDataFrame
2325
        GeoDataFrame containing units all having assigned a voltage level.
2326
    """
2327
2328
    def voltage_levels(p: float) -> int:
2329
        if p <= 0.1:
2330
            return 7
2331
        elif p <= 0.2:
2332
            return 6
2333
        elif p <= 5.5:
2334
            return 5
2335
        elif p <= 20:
2336
            return 4
2337
        elif p <= 120:
2338
            return 3
2339
        return 1
2340
2341
    units_gdf["voltage_level_inferred"] = False
2342
    mask = units_gdf.voltage_level.isna()
2343
    units_gdf.loc[mask, "voltage_level_inferred"] = True
2344
    units_gdf.loc[mask, "voltage_level"] = units_gdf.loc[mask].capacity.apply(
2345
        voltage_levels
2346
    )
2347
2348
    return units_gdf
2349
2350
2351
def pv_rooftop_to_buildings():

src/egon/data/datasets/power_plants/mastr.py 1 location

@@ 118-155 (lines=38) @@
115
    return standort, found
116
117
118
def infer_voltage_level(
119
    units_gdf: gpd.GeoDataFrame,
120
) -> gpd.GeoDataFrame:
121
    """
122
    Infer nan values in voltage level derived from generator capacity to
123
    the power plants.
124
125
    Parameters
126
    -----------
127
    units_gdf : geopandas.GeoDataFrame
128
        GeoDataFrame containing units with voltage levels from MaStR
129
    Returnsunits_gdf: gpd.GeoDataFrame
130
    -------
131
    geopandas.GeoDataFrame
132
        GeoDataFrame containing units all having assigned a voltage level.
133
    """
134
135
    def voltage_levels(p: float) -> int:
136
        if p <= 100:
137
            return 7
138
        elif p <= 200:
139
            return 6
140
        elif p <= 5500:
141
            return 5
142
        elif p <= 20000:
143
            return 4
144
        elif p <= 120000:
145
            return 3
146
        return 1
147
148
    units_gdf["voltage_level_inferred"] = False
149
    mask = units_gdf.voltage_level.isna()
150
    units_gdf.loc[mask, "voltage_level_inferred"] = True
151
    units_gdf.loc[mask, "voltage_level"] = units_gdf.loc[
152
        mask
153
    ].Nettonennleistung.apply(voltage_levels)
154
155
    return units_gdf
156
157
158
def import_mastr() -> None: