@@ -252,13 +252,17 @@ def correct_close_events(self, nb_days_max=20):
252252 """
253253
254254 _time = self .time
255- segment = self .segment .copy ()
255+ # segment used to correct and track changes
256+ segment = self .segment_track_array .copy ()
257+ # final segment used to copy into self.segment
258+ segment_copy = self .segment
259+
256260 segments_connexion = dict ()
257261
258262 previous_obs , next_obs = self .previous_obs , self .next_obs
259263
260264 # record for every segments, the slice, indice of next obs & indice of previous obs
261- for i , seg , _ in self .iter_on (self . segment ):
265+ for i , seg , _ in self .iter_on (segment ):
262266 if i .start == i .stop :
263267 continue
264268
@@ -270,6 +274,10 @@ def correct_close_events(self, nb_days_max=20):
270274
271275 # the segment ID has to be corrected, because we may have changed it since
272276 seg_corrected = segment [seg_slice .stop - 1 ]
277+
278+ # we keep the real segment number
279+ seg_corrected_copy = segment_copy [seg_slice .stop - 1 ]
280+
273281 n_seg = segment [i_seg_n ]
274282
275283 # if segment has splitting
@@ -282,13 +290,15 @@ def correct_close_events(self, nb_days_max=20):
282290 _time [i_seg_n ] - _time [i2_seg_p ] < nb_days_max
283291 ):
284292 my_slice = slice (i_seg_n , seg2_slice .stop )
293+ # correct the factice segment
285294 segment [my_slice ] = seg_corrected
295+ # correct the good segment
296+ segment_copy [my_slice ] = seg_corrected_copy
286297 previous_obs [i_seg_n ] = seg_slice .stop - 1
287298
288299 segments_connexion [seg_corrected ][0 ] = my_slice
289300
290- self .segment [:] = segment
291- self .next_obs [:] = next_obs
301+ self .segment [:] = segment_copy
292302 self .previous_obs [:] = previous_obs
293303
294304 self .sort ()
@@ -1116,7 +1126,7 @@ def extract_with_mask(self, mask):
11161126 logger .warning ("Empty dataset will be created" )
11171127 else :
11181128 logger .info (
1119- f"{ nb_obs } observations will be extract ({ nb_obs * 100. / self .shape [0 ]} % )"
1129+ f"{ nb_obs } observations will be extract ({ nb_obs / self .shape [0 ]:.3% } )"
11201130 )
11211131 for field in self .obs .dtype .descr :
11221132 if field in ("next_obs" , "previous_obs" ):
0 commit comments