Skip to content

Commit

Permalink
Remove nan values within postprocessing
Browse files Browse the repository at this point in the history
  • Loading branch information
ClaraBuettner committed Dec 1, 2023
1 parent 25de9e9 commit 530d753
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions etrago/cluster/electrical.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"]
Expand Down

0 comments on commit 530d753

Please sign in to comment.