Skip to content

Commit

Permalink
Merge pull request #176 from OpenPIV/windef_with_mask
Browse files Browse the repository at this point in the history
Windef with mask
  • Loading branch information
alexlib authored Dec 13, 2020
2 parents e5b0d3f + e8545fe commit 3235324
Show file tree
Hide file tree
Showing 10 changed files with 186 additions and 709 deletions.
16 changes: 16 additions & 0 deletions openpiv/docs/src/developers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,19 @@ Things OpenPIV currently needs, (in order of importance)
* Cython wrappers for C/C++ codes.
* A good graphical user interface (in progress)


How to test all the notebooks
-----------------------------

conda install ipykernel
python -m ipykernel install --user --name openpiv --display-name="openpiv"
jupyter nbconvert --to html --ExecutePreprocessor.kernel_name=openpiv --execute *.ipynb
Then open the `openpiv/examples/notebooks` and check the HTML files. If one of those will fail, the error message will be in the command shell

If you need to install cv2
--------------------------

conda install -c conda-forge opencv


69 changes: 54 additions & 15 deletions openpiv/examples/notebooks/PIV_3D_example.ipynb

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions openpiv/examples/notebooks/all_test_cases_sample.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@
"name": "stdout",
"output_type": "stream",
"text": [
"CPython 3.8.5\n",
"CPython 3.8.3\n",
"IPython 7.19.0\n",
"\n",
"numpy 1.19.4\n",
"openpiv 0.23.1a0\n",
"openpiv 0.23.2rc1\n",
"\n",
"compiler : GCC 7.3.0\n",
"compiler : GCC 7.5.0\n",
"system : Linux\n",
"release : 5.4.0-54-generic\n",
"release : 5.4.0-56-generic\n",
"machine : x86_64\n",
"processor : x86_64\n",
"CPU cores : 8\n",
"interpreter: 64bit\n",
"Git hash : 6edda3f747a61489b040b4d59a7a6d0442e8e341\n",
"Git branch : sig2noise_validation\n"
"Git hash : b750f179dc14baecdad6dbf0bb96622bcc199fd4\n",
"Git branch : windef_with_mask\n"
]
}
],
Expand Down Expand Up @@ -304,7 +304,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.8.3"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions openpiv/examples/notebooks/case_B_windef_small_window.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"'Processing Parameters'\n",
"settings.correlation_method='circular' # 'circular' or 'linear'\n",
"settings.normalized_correlation = True\n",
"settings.iterations = 3 # select the number of PIV passes\n",
"settings.num_iterations = 3 # select the number of PIV passes\n",
"# add the interrogation window size for each pass. \n",
"# For the moment, it should be a power of 2 \n",
"\n",
Expand Down Expand Up @@ -366,7 +366,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.8.3"
}
},
"nbformat": 4,
Expand Down
16 changes: 8 additions & 8 deletions openpiv/examples/notebooks/vonKarman_pivlab_with_openpiv.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"settings.deformation_method = 'symmetric' # or 'second image'\n",
"\n",
"\n",
"settings.iterations = 4 # select the number of PIV passes\n",
"settings.num_iterations = 4 # select the number of PIV passes\n",
"\n",
"# add the interrogation window size for each pass. \n",
"# For the moment, it should be a power of 2 \n",
Expand Down Expand Up @@ -415,7 +415,7 @@
" frame_b,\n",
" settings.windowsizes[0],\n",
" settings.overlap[0],\n",
" settings.iterations,\n",
" settings.num_iterations,\n",
" correlation_method=settings.correlation_method,\n",
" subpixel_method=settings.subpixel_method,\n",
" do_sig2noise=settings.extract_sig2noise,\n",
Expand Down Expand Up @@ -989,7 +989,7 @@
"outputs": [],
"source": [
"# \"filter to replace the values that where marked by the validation\"\n",
"# if settings.iterations > 1:\n",
"# if settings.num_iterations > 1:\n",
"\n",
"\n",
"u, v = filters.replace_outliers(\n",
Expand Down Expand Up @@ -1272,13 +1272,13 @@
}
],
"source": [
"for i in range(1, settings.iterations): ## all other passes\n",
"for i in range(1, settings.num_iterations): ## all other passes\n",
" x, y, u, v, sig2noise_ratio = windef.multipass_img_deform(\n",
" frame_a,\n",
" frame_b,\n",
" settings.windowsizes[i],\n",
" settings.overlap[i],\n",
" settings.iterations,\n",
" settings.num_iterations,\n",
" i,\n",
" x,\n",
" y,\n",
Expand All @@ -1304,8 +1304,8 @@
" \n",
" if (\n",
" settings.extract_sig2noise is True\n",
" and i == settings.iterations\n",
" and settings.iterations != 1\n",
" and i == settings.num_iterations\n",
" and settings.num_iterations != 1\n",
" and settings.do_sig2noise_validation is True\n",
" ):\n",
" u, v, mask_s2n = validation.sig2noise_val(\n",
Expand Down Expand Up @@ -1340,7 +1340,7 @@
" kernel_size=settings.filter_kernel_size,\n",
" )\n",
" \n",
" if (i != settings.iterations) and (settings.smoothn is True):\n",
" if (i != settings.num_iterations) and (settings.smoothn is True):\n",
" u, _, _, _ = smoothn.smoothn(\n",
" u, s=settings.smoothn_p )\n",
" v, _, _, _ = smoothn.smoothn(\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"settings.correlation_method='circular' # 'circular' or 'linear'\n",
"settings.normalized_correlation=False\n",
"\n",
"settings.iterations = 2 # select the number of PIV passes\n",
"settings.num_iterations = 2 # select the number of PIV passes\n",
"# add the interroagtion window size for each pass. \n",
"# For the moment, it should be a power of 2 \n",
"settings.windowsizes = (64, 32, 16) # if longer than n iteration the rest is ignored\n",
Expand Down
611 changes: 0 additions & 611 deletions openpiv/test/test_windef.ipynb

This file was deleted.

6 changes: 3 additions & 3 deletions openpiv/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def global_std(u, v, std_threshold=3):
return u, v, mask


def sig2noise_val(u, v, sig2noise, w=None, threshold=1.05):
def sig2noise_val(u, v, s2n, w=None, threshold=1.05):
"""Eliminate spurious vectors from cross-correlation signal to noise ratio.
Replace spurious vectors with zero if signal to noise ratio
Expand All @@ -145,7 +145,7 @@ def sig2noise_val(u, v, sig2noise, w=None, threshold=1.05):
v : 2d or 3d np.ndarray
a two or three dimensional array containing the v velocity component.
sig2noise : 2d np.ndarray
s2n : 2d np.ndarray
a two or three dimensional array containing the value of the signal to
noise ratio from cross-correlation function.
w : 2d or 3d np.ndarray
Expand Down Expand Up @@ -180,7 +180,7 @@ def sig2noise_val(u, v, sig2noise, w=None, threshold=1.05):
"""

ind = sig2noise < threshold
ind = s2n < threshold

u[ind] = np.nan
v[ind] = np.nan
Expand Down
Loading

0 comments on commit 3235324

Please sign in to comment.