aquaduct.geom.smooth module¶
Smooth module defines methods for smoothing of trajectories.
Available methods:
Savitzky-Golay based smoothing. |
|
Defined size window smoothing. |
|
Distance defined size window smoothing. |
|
Active size window smoothing. |
|
Maximal step smoothing. |
|
Window smoothing over maximal step smoothing. |
|
Distance window smoothing over maximal step smoothing. |
|
Active window smoothing over maximal step smoothing. |
-
class
GeneralWindow
(fun=<function mean>, **kwargs)[source]¶ Bases:
object
Base class for window based smoothing methods.
-
static
max_window_at_pos
(pos, size)[source]¶ Method returns maximal possible window at given position of the list with given size of the list. Returned window fits in to the list of given size and is symmetrical.
-
check_bounds_at_max_window_at_pos
(lb, ub, pos, size)[source]¶ Method checks if window fits in to maximal possible window calculated according to
max_window_at_pos()
. If not window is corrected.- Parameters
- Return type
2 element tuple of int
- Returns
Lowest possible bound and highest possible bound of the window corrected to maximal possible window.
-
static
-
class
IntWindow
(window=5, **kwargs)[source]¶ Bases:
aquaduct.geom.smooth.GeneralWindow
Base class for all window smoothing methods that require integer window.
-
class
FloatWindow
(window=5.0, **kwargs)[source]¶ Bases:
aquaduct.geom.smooth.GeneralWindow
Base class for all window smoothing methods that require float window.
-
class
WindowSmooth
(**kwargs)[source]¶ Bases:
aquaduct.geom.smooth.Smooth
,aquaduct.geom.smooth.IntWindow
Defined size window smoothing.
For each coordinate a symmetrical (if possible) window of size defined by
window
is created. In case of coordinates at the edges created window is truncated to the edges. Next, all coordinates within the window are averaged with a function defined byfunction
. Resulting value(s) are the smoothed coordinates.
-
class
DistanceWindowSmooth
(**kwargs)[source]¶ Bases:
aquaduct.geom.smooth.Smooth
,aquaduct.geom.smooth.FloatWindow
Distance defined size window smoothing.
This is modification of
WindowSmooth
method. The difference is in the definition of the window size. Here, it is an average distance between points of input coordinates. Thus, before smoothing average distance between all points is calculated and this value is used to calculate actual window size.Next, for each coordinate a symmetrical (if possible) window of size calculated in the first step is created. In case of coordinates at the edges created window is truncated to the edges. Next, all coordinates within the window are averaged with a function defined by
function
. Resulting value(s) are the smoothed coordinates.
-
class
ActiveWindowSmooth
(**kwargs)[source]¶ Bases:
aquaduct.geom.smooth.Smooth
,aquaduct.geom.smooth.FloatWindow
Active size window smoothing.
Similarly to
DistanceWindowSmooth
method the window size is defined as a distance. The difference is that the actual window size is calculated for each point separately. Thus, for each coordinate the window is calculated by examining the distance differences between points. In this method window is not necessarily symmetrical. Once window is calculated all coordinates within the window are averaged with a function defined byfunction
. Resulting value(s) are the smoothed coordinates.
-
class
MaxStepSmooth
(step=1.0, **kwargs)[source]¶ Bases:
aquaduct.geom.smooth.Smooth
Maximal step smoothing.
This method moves thorough coordinates and calculates distance over the traversed path. If it is then
step
the coordinate is used as a “cardinal point”. The beginning and the end of the path are also added to the list of cardinal points. Next, all cardinal points and points of linear interpolation between cardinal points are returned as smoothed coordinates. Number of interpolated points is in accordance to points skipped between cardinal points.
-
class
SavgolSmooth
(window_length=5, polyorder=2, **kwargs)[source]¶ Bases:
aquaduct.geom.smooth.Smooth
Savitzky-Golay based smoothing.
Method uses 1D filter available in SciPy, see
savgol_filter()
. For each dimension filter is applied separately. Onlywindow_length
andpolyorder
attributes are used.
-
class
WindowOverMaxStepSmooth
(**kwargs)[source]¶ Bases:
aquaduct.geom.smooth.Smooth
Window smoothing over maximal step smoothing.
First,
MaxStepSmooth
is applied, and thenWindowSmooth
.
-
class
ActiveWindowOverMaxStepSmooth
(**kwargs)[source]¶ Bases:
aquaduct.geom.smooth.Smooth
Active window smoothing over maximal step smoothing.
First,
MaxStepSmooth
is applied, and thenActiveWindowSmooth
.
-
class
DistanceWindowOverMaxStepSmooth
(**kwargs)[source]¶ Bases:
aquaduct.geom.smooth.Smooth
Distance window smoothing over maximal step smoothing.
First,
MaxStepSmooth
is applied, and thenDistanceWindowSmooth
.