openpiv.filters.replace_outliers

openpiv.filters.replace_outliers(u: numpy.ndarray, v: numpy.ndarray, flags: numpy.ndarray, w: Optional[numpy.ndarray] = None, method: str = 'localmean', max_iter: int = 5, tol: float = 0.001, kernel_size: int = 1) → Tuple[numpy.ndarray, ...][source]
Replace invalid vectors in an velocity field using an iterative image
inpainting algorithm.

The algorithm is the following:

  1. For each element in the arrays of the u and v components, replace it by a weighted average of the neighbouring elements which are not invalid themselves. The weights depends of the method type. If method=localmean weight are equal to 1/( (2*kernel_size+1)**2 -1 )
  2. Several iterations are needed if there are adjacent invalid elements. If this is the case, inforation is “spread” from the edges of the missing regions iteratively, until the variation is below a certain threshold.
Parameters:
  • u (2d or 3d np.ndarray) – the u velocity component field
  • v (2d or 3d np.ndarray) – the v velocity component field
  • w (2d or 3d np.ndarray) – the w velocity component field
  • flags (2d array of positions with invalid vectors) –
  • grid_mask (2d array of positions masked by the user) –
  • max_iter (int) – the number of iterations
  • kernel_size (int) – the size of the kernel, default is 1
  • method (str) – the type of kernel used for repairing missing vectors
Returns:

  • uf (2d or 3d np.ndarray) – the smoothed u velocity component field, where invalid vectors have been replaced
  • vf (2d or 3d np.ndarray) – the smoothed v velocity component field, where invalid vectors have been replaced
  • wf (2d or 3d np.ndarray) – the smoothed w velocity component field, where invalid vectors have been replaced