diff --git a/etrago/cluster/electrical.py b/etrago/cluster/electrical.py index ad373fc2..e92b7d34 100755 --- a/etrago/cluster/electrical.py +++ b/etrago/cluster/electrical.py @@ -872,6 +872,18 @@ def postprocessing(etrago, busmap, busmap_foreign, medoid_idx=None, line_strategies=strategies_lines(), ) + # Drop nan values after clustering + clustering.network.links.min_up_time.fillna(0, inplace=True) + clustering.network.links.min_down_time.fillna(0, inplace=True) + clustering.network.links.up_time_before.fillna(0, inplace=True) + clustering.network.links.down_time_before.fillna(0, inplace=True) + # Drop nan values in timeseries after clustering + for c in clustering.network.iterate_components(): + for pnl in c.attrs[ + (c.attrs.status == "Output") & (c.attrs.varying) + ].index: + c.pnl[pnl] = pd.DataFrame(index=clustering.network.snapshots) + if method == "kmedoids-dijkstra": for i in clustering.network.buses[ clustering.network.buses.carrier == "AC" @@ -1053,18 +1065,6 @@ def run_spatial_clustering(self): # which sets slack bus(es). set_control_strategies(self.network) - # Drop nan values after clustering - self.network.links.min_up_time.fillna(0, inplace=True) - self.network.links.min_down_time.fillna(0, inplace=True) - self.network.links.up_time_before.fillna(0, inplace=True) - self.network.links.down_time_before.fillna(0, inplace=True) - # Drop nan values in timeseries after clustering - for c in self.network.iterate_components(): - for pnl in c.attrs[ - (c.attrs.status == "Output") & (c.attrs.varying) - ].index: - c.pnl[pnl] = pd.DataFrame(index=self.network.snapshots) - logger.info( "Network clustered to {} buses with ".format( self.args["network_clustering"]["n_clusters_AC"] diff --git a/etrago/tools/utilities.py b/etrago/tools/utilities.py index 4adb6302..221174b1 100755 --- a/etrago/tools/utilities.py +++ b/etrago/tools/utilities.py @@ -2884,7 +2884,28 @@ def manual_fixes_datamodel(etrago): ] = 25 # Set r value if missing + if not etrago.network.lines.loc[etrago.network.lines.r == 0, "r"].empty: + logger.info( + f""" + There are {len( + etrago.network.lines.loc[etrago.network.lines.r == 0, "r"] + )} lines without a resistance (r) in the data model. + The resistance of these lines will be automatically set to 0.0001. + """ + ) + etrago.network.lines.loc[etrago.network.lines.r == 0, "r"] = 0.0001 + + if not etrago.network.transformers.loc[ + etrago.network.transformers.r == 0, "r" + ].empty: + logger.info( + f"""There are {len(etrago.network.transformers.loc[ + etrago.network.transformers.r == 0, "r"] + )} trafos without a resistance (r) in the data model. + The resistance of these trafos will be automatically set to 0.0001. + """ + ) etrago.network.transformers.loc[ etrago.network.transformers.r == 0, "r" ] = 0.0001