Skip to content

Commit 05b557a

Browse files
committed
added the option for overlap
1 parent 61e5508 commit 05b557a

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

openpiv/test/test_windef.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,9 @@ def test_multi_pass_lin():
184184

185185
def test_simple_multipass():
186186
""" Test simple multipass """
187-
# windowsizes = (64, 32, 16)
188187
x, y, u, v, s2n = windef.simple_multipass(
189188
frame_a,
190-
frame_b,
191-
#windowsizes
189+
frame_b
192190
)
193191
print("simple multipass\n")
194192
print(u[:2,:2],v[:2,:2])
@@ -200,5 +198,15 @@ def test_simple_multipass():
200198
assert np.allclose(u, shift_u, atol=threshold)
201199
assert np.allclose(v, -shift_v, atol=threshold)
202200

201+
202+
# windowsizes = (64, 32, 16)
203+
x, y, u, v, s2n = windef.simple_multipass(
204+
frame_a,
205+
frame_b,
206+
windows = (32,16)
207+
)
208+
assert np.allclose(u, shift_u, atol=threshold)
209+
assert np.allclose(v, -shift_v, atol=threshold)
210+
203211
# the second condition is to check if the multipass is done.
204212
# It need's a little numerical inaccuracy.

openpiv/windef.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,16 @@
2121
from openpiv import smoothn
2222
from skimage.util import invert
2323

24-
def simple_multipass(frame_a, frame_b, windows = (64, 32, 16)):
24+
def simple_multipass(frame_a, frame_b, windows = None):
2525
""" Simple windows deformation multipass run with
2626
default settings
2727
"""
28-
settings = Settings()
28+
settings = Settings() # default, see below
2929

30-
settings.num_iterations = len(windows)
31-
settings.windowsizes = windows
30+
if windows is not None:
31+
settings.num_iterations = len(windows)
32+
settings.windowsizes = windows
33+
settings.overlap = [int(w/2) for w in windows]
3234

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

46-
u, v = filters.replace_outliers(
47-
u,
48-
v,
49-
method=settings.filter_method,
50-
max_iter=settings.max_filter_iteration,
51-
kernel_size=settings.filter_kernel_size
52-
)
48+
u, v = filters.replace_outliers(u, v)
5349

5450
if settings.smoothn:
55-
u, dummy_u1, dummy_u2, dummy_u3 = smoothn.smoothn(
56-
u, s=settings.smoothn_p
57-
)
58-
v, dummy_v1, dummy_v2, dummy_v3 = smoothn.smoothn(
59-
v, s=settings.smoothn_p
60-
)
51+
u,_,_,_ = smoothn.smoothn(u, s=settings.smoothn_p)
52+
v,_,_,_ = smoothn.smoothn(v, s=settings.smoothn_p)
6153
# multipass
6254
for i in range(1, settings.num_iterations):
6355

0 commit comments

Comments
 (0)