@@ -234,12 +234,11 @@ def extract_with_length(self, bounds):
234
234
raise Exception ("One bounds must be positiv" )
235
235
return self .__extract_with_mask (track_mask .repeat (self .nb_obs_by_track ))
236
236
237
- def loess_filter (self , window , xfield , yfield , inplace = True ):
237
+ def loess_filter (self , half_window , xfield , yfield , inplace = True ):
238
238
track = self .obs ["track" ]
239
239
x = self .obs [xfield ]
240
240
y = self .obs [yfield ]
241
- window = window
242
- result = track_loess_filter (window , x , y , track )
241
+ result = track_loess_filter (half_window , x , y , track )
243
242
if inplace :
244
243
self .obs [yfield ] = result
245
244
@@ -312,7 +311,7 @@ def compute_mask_from_id(tracks, first_index, number_of_obs, mask):
312
311
313
312
314
313
@njit (cache = True )
315
- def track_loess_filter (window , x , y , track ):
314
+ def track_loess_filter (half_window , x , y , track ):
316
315
"""
317
316
Apply a loess filter on y field
318
317
Args:
@@ -334,17 +333,17 @@ def track_loess_filter(window, x, y, track):
334
333
if i != 0 :
335
334
i_previous = i - 1
336
335
dx = x [i ] - x [i_previous ]
337
- while dx < window and i_previous != 0 and cur_track == track [i_previous ]:
338
- w = (1 - (dx / window ) ** 3 ) ** 3
336
+ while dx < half_window and i_previous != 0 and cur_track == track [i_previous ]:
337
+ w = (1 - (dx / half_window ) ** 3 ) ** 3
339
338
y_sum += y [i_previous ] * w
340
339
w_sum += w
341
340
i_previous -= 1
342
341
dx = x [i ] - x [i_previous ]
343
342
if i != last :
344
343
i_next = i + 1
345
344
dx = x [i_next ] - x [i ]
346
- while dx < window and i_next != last and cur_track == track [i_next ]:
347
- w = (1 - (dx / window ) ** 3 ) ** 3
345
+ while dx < half_window and i_next != last and cur_track == track [i_next ]:
346
+ w = (1 - (dx / half_window ) ** 3 ) ** 3
348
347
y_sum += y [i_next ] * w
349
348
w_sum += w
350
349
i_next += 1
0 commit comments