Skip to content

Commit f5a4f3b

Browse files
committed
added options for file sequence and test in the test_tools.ipynb notebook
1 parent 79c9e8e commit f5a4f3b

4 files changed

Lines changed: 232 additions & 95 deletions

File tree

openpiv/docs/src/windef.ipynb

Lines changed: 63 additions & 28 deletions
Large diffs are not rendered by default.

openpiv/test/test_tools.ipynb

Lines changed: 121 additions & 62 deletions
Large diffs are not rendered by default.

openpiv/test/test_tools.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,21 @@ def test_display_vector_field(file_a=_file_a, file_b=_file_b, test_file=_test_fi
4545
fig.savefig('./tmp.png')
4646
res = compare.compare_images('./tmp.png', test_file, 0.001)
4747
assert res is None
48+
49+
def test_file_patterns():
50+
"""
51+
tools.Multiprocesser() class has a couple of options to process
52+
pairs of images or create pairs from sequential list of files
53+
54+
# Format and Image Sequence
55+
settings.frame_pattern_a = 'exp1_001_a.bmp'
56+
settings.frame_pattern_b = 'exp1_001_b.bmp'
57+
58+
# or if you have a sequence:
59+
# settings.frame_pattern_a = '000*.tif'
60+
# settings.frame_pattern_b = '(1+2),(2+3)'
61+
# settings.frame_pattern_b = '(1+3),(2+4)'
62+
# settings.frame_pattern_b = '(1+2),(3+4)'
63+
"""
64+
65+

openpiv/tools.py

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -424,12 +424,28 @@ def __init__(self, data_dir, pattern_a, pattern_b=None):
424424
the path where image files are located
425425
426426
pattern_a : str
427-
a shell glob patter to match the first
428-
frames.
427+
a shell glob pattern to match the first (A) frames.
429428
430429
pattern_b : str
431-
a shell glob patter to match the second
432-
frames. if None, then the list is sequential, 001.tif, 002.tif
430+
a shell glob pattern to match the second (B) frames.
431+
432+
Options:
433+
pattern_a = 'image_*_a.bmp'
434+
pattern_b = 'image_*_b.bmp'
435+
436+
or
437+
pattern_a = '000*.tif'
438+
pattern_b = '(1+2),(2+3)'
439+
will create PIV of these pairs: 0001.tif+0002.tif, 0002.tif+0003.tif ...
440+
or
441+
pattern_a = '000*.tif'
442+
pattern_b = '(1+3),(2+4)'
443+
will create PIV of these pairs: 0001.tif+0003.tif, 0002.tif+0004.tif ...
444+
or
445+
pattern_a = '000*.tif'
446+
pattern_b = '(1+2),(3+4)'
447+
will create PIV of these pairs: 0001.tif+0002.tif, 0003.tif+0004.tif ...
448+
433449
434450
Examples
435451
--------
@@ -442,9 +458,15 @@ def __init__(self, data_dir, pattern_a, pattern_b=None):
442458
glob.glob(os.path.join(os.path.abspath(data_dir), pattern_a))
443459
)
444460

445-
if pattern_b is None:
461+
if pattern_b == '(1+2),(2+3)':
446462
self.files_b = self.files_a[1:]
447463
self.files_a = self.files_a[:-1]
464+
elif pattern_b == '(1+3),(2+4)':
465+
self.files_b = self.files_a[2:]
466+
self.files_a = self.files_a[:-2]
467+
elif pattern_b == '(1+2),(3+4)':
468+
self.files_b = self.files_a[1::2]
469+
self.files_a = self.files_a[0::2]
448470
else:
449471
self.files_b = sorted(
450472
glob.glob(os.path.join(os.path.abspath(data_dir), pattern_b))
@@ -455,6 +477,9 @@ def __init__(self, data_dir, pattern_a, pattern_b=None):
455477

456478
# check if everything was fine
457479
if not len(self.files_a) == len(self.files_b):
480+
print(self.files_a)
481+
print(self.files_b)
482+
458483
raise ValueError(
459484
'Something failed loading the image file. There should be an equal number of "a" and "b" files.'
460485
)

0 commit comments

Comments
 (0)