Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
00180eb
Update PIV_3D_example.md, PIV_3D_example.py, and 10 more files...
alexlib Nov 9, 2020
f4c47e6
remove progressbar
alexlib Nov 9, 2020
dfd6c40
Update process.pyx, pyprocess.py, and windef.py
alexlib Nov 9, 2020
635a767
pyprocess.py now has the correlate_strided_images and normalize_inten…
alexlib Nov 9, 2020
69da506
get_field_shape is now only in pyprocess, taken from pyproces
alexlib Nov 9, 2020
70fc67f
Update test_windef.ipynb and pyprocess.py
alexlib Nov 9, 2020
1048163
Update pyprocess.py, pyprocess3D.py, and windef.py
alexlib Nov 10, 2020
f55f6ba
Update compare_correlations.ipynb, pyprocess_test.ipynb, and 2 more f…
alexlib Nov 11, 2020
a49c905
Update installation_instruction.rst, extended_search_area_vectorized.…
alexlib Nov 13, 2020
2daa37b
get_field_shape is now using only the largest size, the search_area_size
alexlib Nov 13, 2020
2b3d00d
new test_tools test with display_vector and matplotlib.testing.compar…
alexlib Nov 13, 2020
3b26535
process.pyx -> widim.pyx
alexlib Nov 13, 2020
70d4c98
Update process.pyx, pyprocess.py, and 4 more files...
alexlib Nov 13, 2020
bb6f23a
Update pyprocess.py, test_process.py, and 4 more files...
alexlib Nov 13, 2020
891262e
Update test_process.py, test_windef.py, and windef.py
alexlib Nov 13, 2020
82e57e4
Update test_windef.ipynb and windef.py
alexlib Nov 13, 2020
0b41785
Update test_windef.ipynb, test_windef.py, and windef.py
alexlib Nov 13, 2020
96bf22a
Update PIV_3D_plotting.py, __init__.py, and 16 more files...
alexlib Nov 13, 2020
4635bca
Update masking_tutorial.ipynb, tutorial1.ipynb, and 2 more files...
alexlib Nov 13, 2020
3c7f172
frame_interpolation is now deform_windows, see github comments on the…
alexlib Nov 15, 2020
8f21391
Merge branch 'master'
alexlib Nov 15, 2020
3042c90
Merge branch 'master'
alexlib Nov 15, 2020
6d859e7
Merge branch 'master'
alexlib Nov 16, 2020
134d915
most of the examples work in notebooks, except for 3D
alexlib Nov 16, 2020
f6d9500
Update WiDIM.py, masking_tutorial.py, and 2 more files...
alexlib Nov 16, 2020
d586e8a
Update all_test_cases_sample.ipynb, window_deformation_comparison.ipy…
alexlib Nov 17, 2020
807f3c4
Update .gitignore and all_test_cases_sample.ipynb also test 9 and 10 …
alexlib Nov 17, 2020
94cd8e8
@ErichZimmer found this test to be a corner case of the subpixel_sear…
alexlib Nov 17, 2020
e42849a
removed obsolete and too specific lines
alexlib Nov 17, 2020
d542287
fixed bug in find_subpixel_position (see @ErichZimmer comment) when l…
alexlib Nov 17, 2020
a86a602
Added new window deformation method
TKaeufer Nov 17, 2020
fa1ccb3
Update case_B_windef_small_window.ipynb and window_deformation_compar…
alexlib Nov 17, 2020
45bc1c4
Update A001_1.tif, A001_2.tif, and readmeA.txt
alexlib Nov 18, 2020
08200a7
Update piv.py
alexlib Nov 18, 2020
a0ec57c
renamed piv to piv_example
alexlib Nov 18, 2020
92bc053
there is now both piv.example_piv() and piv.simple_piv(im1, im2)
alexlib Nov 18, 2020
04c4c71
Update analyse_movie.ipynb, videoplayback.mp4, and piv.py
alexlib Nov 18, 2020
099e6a5
Update widim.c and setup.py
alexlib Nov 18, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 3 additions & 31 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,40 +1,11 @@
openpiv/docs/sphinx-docs/downloads/tutorial-part1
*.m
openpiv/src/process.c
openpiv/src/lib.c
*.jvc
*.pyc
build/
*.txt
/setup.cfg
openpiv/lib.so
openpiv/process.so
mark_data/Camera 1-120.tif
mark_data/Camera 1-120.tif.png
mark_data/Camera 1-121.tif
mark_data/Camera 1-122.tif
mark_data/Camera 1-123.tif
mark_data/Camera 1-124.tif
mark_data/Camera 1-125.tif
mark_data/Camera 1-126.tif
mark_data/Camera 1-127.tif
mark_data/Camera 1-128.tif
mark_data/Camera 1-129.tif
mark_data/Camera 1-130.tif
mark_data/neg.tif
mark_data/tutorial-part1.py
mark_result/Camera 1-120.tif.png
mark_result/Camera 1-121.tif.png
mark_result/Camera 1-122.tif.png
mark_result/Camera 1-123.tif.png
mark_result/Camera 1-124.tif.png
mark_result/Camera 1-125.tif.png
mark_result/Camera 1-126.tif.png
mark_result/Camera 1-127.tif.png
mark_result/Camera 1-128.tif.png
openpiv-python-mark-data-checkpoint.ipynb
openpiv-python-tutorial-part1-checkpoint.ipynb
dist

dist/*
masking_tutorial/.ipynb_checkpoints
openpiv/masking_tutorial/.ipynb_checkpoints
.eggs
Expand All @@ -43,3 +14,4 @@ OpenPIV.egg-info
*.ipynb_checkpoints*
.vscode/settings.json
*.so

1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ v0.17, July 1, 2014 -- Fixed the bug in lib.pyx of different casting of np.int3
v0.18 Aug. 8, 2014 -- small updates to the tutorial-part1, MANIFEST.IN, readme and install files
...
v0.22.3 Sep. 22, 2020 -- @erfan-mtr added two-phase extension, see phase_separation.ipynb for the demo
v0.22.4 Nov, 2020 -- windef refactoring : no more process.pyx, everything in pyprocess.py, numpy vectorized correlation version from windef moved to pyprocess, get_field_shape has less arguments (it's a backward compatability problem, it breaks stuff), new tests, new documentation settings with Jupyter notebook and markdown inserts, tools.save requires also sig2noise column, as in windef, frame_interpolation is now deform_windows with optionaly kx,ky,
32 changes: 0 additions & 32 deletions TODO

This file was deleted.

112 changes: 80 additions & 32 deletions openpiv/PIV_3D_plotting.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'''
"""
functions to plot 3D-deformation fields and simple 3D-structures
'''
"""


import matplotlib
Expand All @@ -11,8 +11,8 @@


def set_axes_equal(ax):
'''

"""
Following https://stackoverflow.com/questions/13685386/matplotlib-equal-unit-length-with-equal-aspect-ratio-z-axis-is-not-equal-to
Make axes of 3D plot have equal scale so that spheres appear as spheres,
cubes as cubes, etc.. This is one possible solution to Matplotlib's
Expand All @@ -23,7 +23,7 @@ def set_axes_equal(ax):
ax: matplotlib.axes object


'''
"""

x_limits = ax.get_xlim3d()
y_limits = ax.get_ylim3d()
Expand All @@ -38,17 +38,17 @@ def set_axes_equal(ax):

# The plot bounding box is a sphere in the sense of the infinity
# norm, hence I call half the max range the plot radius.
plot_radius = 0.5*max([x_range, y_range, z_range])
plot_radius = 0.5 * max([x_range, y_range, z_range])

ax.set_xlim3d([x_middle - plot_radius, x_middle + plot_radius])
ax.set_ylim3d([y_middle - plot_radius, y_middle + plot_radius])
ax.set_zlim3d([z_middle - plot_radius, z_middle + plot_radius])


def scatter_3D(a, cmap="jet", sca_args=None, control="color", size=60):

# default arguments for the quiver plot. can be overwritten by quiv_args
if not isinstance(sca_args,dict):
if not isinstance(sca_args, dict):
sca_args = {}
scatter_args = {"alpha": 1}
scatter_args.update(sca_args)
Expand All @@ -59,21 +59,30 @@ def scatter_3D(a, cmap="jet", sca_args=None, control="color", size=60):
z = z.flatten()

fig = plt.figure()
ax = fig.gca(projection='3d', rasterized=True)
ax = fig.gca(projection="3d", rasterized=True)

if control == "color":
# make cmap
cbound = [np.nanmin(a), np.nanmax(a)]
# create normalized color map for arrows
norm = matplotlib.colors.Normalize(vmin=cbound[0], vmax=cbound[1]) # 10 ) #cbound[1] ) #)
norm = matplotlib.colors.Normalize(
vmin=cbound[0], vmax=cbound[1]
) # 10 ) #cbound[1] ) #)
sm = matplotlib.cm.ScalarMappable(cmap=cmap, norm=norm)
sm.set_array([])
# different option
cm = matplotlib.cm.get_cmap(cmap)
colors = cm(norm(a)).reshape(a.shape[0] * a.shape[1] * a.shape[2], 4) #
# plotting
nan_filter = ~np.isnan(a.flatten())
ax.scatter(x[nan_filter], y[nan_filter], z[nan_filter], c=colors[nan_filter], s=size, **scatter_args)
ax.scatter(
x[nan_filter],
y[nan_filter],
z[nan_filter],
c=colors[nan_filter],
s=size,
**scatter_args
)
plt.colorbar(sm)

if control == "alpha":
Expand All @@ -88,13 +97,25 @@ def scatter_3D(a, cmap="jet", sca_args=None, control="color", size=60):
ax_scale = plt.axes([0.88, 0.1, 0.05, 0.7])
# ax_scale.set_ylim((0.1,1.2))
nm = 5
ax_scale.scatter([0] * nm, np.linspace(a.min(), a.max(), nm), s=sizes.max() * np.linspace(0, 1, nm))
ax_scale.scatter(
[0] * nm,
np.linspace(a.min(), a.max(), nm),
s=sizes.max() * np.linspace(0, 1, nm),
)
ax_scale.spines["left"].set_visible(False)
ax_scale.spines["right"].set_visible(True)
ax_scale.spines["bottom"].set_visible(False)
ax_scale.spines["top"].set_visible(False)
ax_scale.tick_params(axis="both", which="both", labelbottom=False, labelleft=False, labelright=True,
bottom=False, left=False, right=True)
ax_scale.tick_params(
axis="both",
which="both",
labelbottom=False,
labelleft=False,
labelright=True,
bottom=False,
left=False,
right=True,
)

ax.set_xlim(0, a.shape[0])
ax.set_ylim(0, a.shape[1])
Expand Down Expand Up @@ -130,7 +151,9 @@ def plot_3D_alpha(data):

data_fil = data.copy()
data_fil[(data == np.inf)] = np.nanmax(data[~(data == np.inf)])
data_fil = (data_fil - np.nanmin(data_fil)) / (np.nanmax(data_fil) - np.nanmin(data_fil))
data_fil = (data_fil - np.nanmin(data_fil)) / (
np.nanmax(data_fil) - np.nanmin(data_fil)
)
data_fil[np.isnan(data_fil)] = 0

col[:, :, :, 2] = 1
Expand All @@ -149,16 +172,31 @@ def plot_3D_alpha(data):
z[:, :, 1::2] += 0.95

fig = plt.figure()
ax = fig.gca(projection='3d')
ax = fig.gca(projection="3d")
ax.voxels(x, y, z, fill, facecolors=col_exp, edgecolors=col_exp)
ax.set_xlabel("x")
ax.set_ylabel("y")
ax.set_zlabel("z")
plt.show()


def quiver_3D(u, v, w, x=None, y=None, z=None, mask_filtered=None, filter_def=0, filter_reg=(1, 1, 1),
cmap="jet", quiv_args=None, vmin=None, vmax=None, arrow_scale=0.15, equal_ax=True):
def quiver_3D(
u,
v,
w,
x=None,
y=None,
z=None,
mask_filtered=None,
filter_def=0,
filter_reg=(1, 1, 1),
cmap="jet",
quiv_args=None,
vmin=None,
vmax=None,
arrow_scale=0.15,
equal_ax=True,
):
"""
Displaying 3D deformation fields vector arrows

Expand Down Expand Up @@ -212,15 +250,21 @@ def quiver_3D(u, v, w, x=None, y=None, z=None, mask_filtered=None, filter_def=0,
"""

# default arguments for the quiver plot. can be overwritten by quiv_args
quiver_args = {"normalize":False, "alpha":0.8, "pivot":'tail', "linewidth":1, "length":1}
quiver_args = {
"normalize": False,
"alpha": 0.8,
"pivot": "tail",
"linewidth": 1,
"length": 1,
}
if isinstance(quiv_args, dict):
quiver_args.update(quiv_args)
# overwriting length if an arrow scale and a "length" argument in quiv_args
# overwriting length if an arrow scale and a "length" argument in quiv_args
# is provided at the same
if arrow_scale is not None:
quiver_args["length"] = 1
# convert filter ot list if proveided as int

# convert filter ot list if proveided as int
if not isinstance(filter_reg, (tuple, list)):
filter_reg = [filter_reg] * 3

Expand All @@ -234,8 +278,9 @@ def quiver_3D(u, v, w, x=None, y=None, z=None, mask_filtered=None, filter_def=0,
x, y, z = np.indices(u.shape)
else:
raise ValueError(
"displacement data has wrong number of dimensions (%s). Use 1d array, list, or 3d array." % str(
len(u.shape)))
"displacement data has wrong number of dimensions (%s). Use 1d array, list, or 3d array."
% str(len(u.shape))
)

# conversion to array
x, y, z = np.array([x, y, z])
Expand All @@ -246,7 +291,7 @@ def quiver_3D(u, v, w, x=None, y=None, z=None, mask_filtered=None, filter_def=0,
if isinstance(filter_reg, list):
show_only = np.zeros(u.shape).astype(bool)
# filtering out every x-th
show_only[::filter_reg[0], ::filter_reg[1], ::filter_reg[2]] = True
show_only[:: filter_reg[0], :: filter_reg[1], :: filter_reg[2]] = True
mask_filtered = np.logical_and(mask_filtered, show_only)

xf = x[mask_filtered]
Expand All @@ -265,28 +310,32 @@ def quiver_3D(u, v, w, x=None, y=None, z=None, mask_filtered=None, filter_def=0,
# different option
colors = matplotlib.cm.jet(norm(df)) #

colors = [c for c, d in zip(colors, df) if d > 0] + list(chain(*[[c, c] for c, d in zip(colors, df) if d > 0]))
colors = [c for c, d in zip(colors, df) if d > 0] + list(
chain(*[[c, c] for c, d in zip(colors, df) if d > 0])
)
# colors in ax.quiver 3d is really fucked up/ will probably change with updates:
# requires list with: first len(u) entries define the colors of the shaft, then the next len(u)*2 entries define
# the color ofleft and right arrow head side in alternating order. Try for example:
# colors = ["red" for i in range(len(cf))] + list(chain(*[["blue", "yellow"] for i in range(len(cf))]))
# to see this effect.
# BUT WAIT THERS MORE: zeor length arrows are apparently filtered out in the matplolib with out filtering
# BUT WAIT THERS MORE: zeor length arrows are apparently filtered out in the matplolib with out filtering
# the color list appropriately so we have to do this our selfs as well

# scale arrows to axis dimensions:
ax_dims = [(x.min(), x.max()), (y.min(), y.max()), (z.min(), z.max())]
if arrow_scale is not None:
max_length = df.max()
max_dim_length= np.max([(d[1] - d[0] + 1) for d in ax_dims] )
max_dim_length = np.max([(d[1] - d[0] + 1) for d in ax_dims])
scale = max_dim_length * arrow_scale / max_length
else:
scale = 1

# plotting
fig = plt.figure()
ax = fig.gca(projection='3d', rasterized=True)
ax.quiver(xf, yf, zf, vf*scale, uf*scale, wf*scale, colors=colors, **quiver_args)
ax = fig.gca(projection="3d", rasterized=True)
ax.quiver(
xf, yf, zf, vf * scale, uf * scale, wf * scale, colors=colors, **quiver_args
)
plt.colorbar(sm)

ax.set_xlim(ax_dims[0])
Expand All @@ -302,6 +351,5 @@ def quiver_3D(u, v, w, x=None, y=None, z=None, mask_filtered=None, filter_def=0,
ax.w_xaxis.set_pane_color((0.2, 0.2, 0.2, 1.0))
ax.w_yaxis.set_pane_color((0.2, 0.2, 0.2, 1.0))
ax.w_zaxis.set_pane_color((0.2, 0.2, 0.2, 1.0))

return fig

return fig
1 change: 1 addition & 0 deletions openpiv/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
def test():
import pytest

pytest.main()
11 changes: 0 additions & 11 deletions openpiv/docs/src/installation_instruction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,6 @@ Or use `pip` ::
pip install numpy cython
pip install openpiv --pre


In Python 3 the project changed name to `progressbar2` package. Install it separately using `pip`

pip install progressbar2

Or using Conda:

conda install progressbar2

We will remove this requirement in the future, so don't be surprised it if just works without progressbar.

Get OpenPIV source code!
========================

Expand Down
Loading