Skip to content

Commit

Permalink
added the option for overlap
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlib committed Jul 23, 2022
1 parent 61e5508 commit 05b557a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
14 changes: 11 additions & 3 deletions openpiv/test/test_windef.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,9 @@ def test_multi_pass_lin():

def test_simple_multipass():
""" Test simple multipass """
# windowsizes = (64, 32, 16)
x, y, u, v, s2n = windef.simple_multipass(
frame_a,
frame_b,
#windowsizes
frame_b
)
print("simple multipass\n")
print(u[:2,:2],v[:2,:2])
Expand All @@ -200,5 +198,15 @@ def test_simple_multipass():
assert np.allclose(u, shift_u, atol=threshold)
assert np.allclose(v, -shift_v, atol=threshold)


# windowsizes = (64, 32, 16)
x, y, u, v, s2n = windef.simple_multipass(
frame_a,
frame_b,
windows = (32,16)
)
assert np.allclose(u, shift_u, atol=threshold)
assert np.allclose(v, -shift_v, atol=threshold)

# the second condition is to check if the multipass is done.
# It need's a little numerical inaccuracy.
26 changes: 9 additions & 17 deletions openpiv/windef.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@
from openpiv import smoothn
from skimage.util import invert

def simple_multipass(frame_a, frame_b, windows = (64, 32, 16)):
def simple_multipass(frame_a, frame_b, windows = None):
""" Simple windows deformation multipass run with
default settings
"""
settings = Settings()
settings = Settings() # default, see below

settings.num_iterations = len(windows)
settings.windowsizes = windows
if windows is not None:
settings.num_iterations = len(windows)
settings.windowsizes = windows
settings.overlap = [int(w/2) for w in windows]

x, y, u, v, s2n = first_pass(
frame_a,
Expand All @@ -43,21 +45,11 @@ def simple_multipass(frame_a, frame_b, windows = (64, 32, 16)):
if settings.validation_first_pass:
u, v, mask = validation.typical_validation(u, v, s2n, settings)

u, v = filters.replace_outliers(
u,
v,
method=settings.filter_method,
max_iter=settings.max_filter_iteration,
kernel_size=settings.filter_kernel_size
)
u, v = filters.replace_outliers(u, v)

if settings.smoothn:
u, dummy_u1, dummy_u2, dummy_u3 = smoothn.smoothn(
u, s=settings.smoothn_p
)
v, dummy_v1, dummy_v2, dummy_v3 = smoothn.smoothn(
v, s=settings.smoothn_p
)
u,_,_,_ = smoothn.smoothn(u, s=settings.smoothn_p)
v,_,_,_ = smoothn.smoothn(v, s=settings.smoothn_p)
# multipass
for i in range(1, settings.num_iterations):

Expand Down

0 comments on commit 05b557a

Please sign in to comment.