Code Duplication    Length = 38-38 lines in 2 locations

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

@@ 2185-2222 (lines=38) @@
2182
    return buildings_gdf
2183
2184
2185
def infer_voltage_level(
2186
    units_gdf: gpd.GeoDataFrame,
2187
) -> gpd.GeoDataFrame:
2188
    """
2189
    Infer nan values in voltage level derived from generator capacity to
2190
    the power plants.
2191
2192
    Parameters
2193
    -----------
2194
    units_gdf : geopandas.GeoDataFrame
2195
        GeoDataFrame containing units with voltage levels from MaStR
2196
    Returnsunits_gdf: gpd.GeoDataFrame
2197
    -------
2198
    geopandas.GeoDataFrame
2199
        GeoDataFrame containing units all having assigned a voltage level.
2200
    """
2201
2202
    def voltage_levels(p: float) -> int:
2203
        if p <= 100:
2204
            return 7
2205
        elif p <= 200:
2206
            return 6
2207
        elif p <= 5500:
2208
            return 5
2209
        elif p <= 20000:
2210
            return 4
2211
        elif p <= 120000:
2212
            return 3
2213
        return 1
2214
2215
    units_gdf["voltage_level_inferred"] = False
2216
    mask = units_gdf.voltage_level.isna()
2217
    units_gdf.loc[mask, "voltage_level_inferred"] = True
2218
    units_gdf.loc[mask, "voltage_level"] = units_gdf.loc[
2219
        mask
2220
    ].Nettonennleistung.apply(voltage_levels)
2221
2222
    return units_gdf
2223
2224
2225
def pv_rooftop_to_buildings():

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

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