From 530d7538e96e361a0d0d9460bce83b4724e57e93 Mon Sep 17 00:00:00 2001 From: ClaraBuettner Date: Fri, 1 Dec 2023 10:32:23 +0100 Subject: [PATCH] Remove nan values within postprocessing --- etrago/cluster/electrical.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/etrago/cluster/electrical.py b/etrago/cluster/electrical.py index b80b561d..081fe543 100755 --- a/etrago/cluster/electrical.py +++ b/etrago/cluster/electrical.py @@ -866,6 +866,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" @@ -1047,18 +1059,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"]