Code Duplication    Length = 38-38 lines in 2 locations

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

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