%23%20%2F%2F%2F%20script%0A%23%20requires-python%20%3D%20%22%3E%3D3.11%22%0A%23%20dependencies%20%3D%20%5B%0A%23%20%20%20%20%20%22marimo%22%2C%0A%23%20%20%20%20%20%22openpiv%3D%3D0.26.3%22%2C%0A%23%20%20%20%20%20%22numpy%22%2C%0A%23%20%20%20%20%20%22matplotlib%22%2C%0A%23%20%20%20%20%20%22scipy%22%2C%0A%23%20%20%20%20%20%22scikit-image%22%2C%0A%23%20%5D%0A%23%20%2F%2F%2F%0A%0Aimport%20marimo%0A%0A__generated_with%20%3D%20%220.25.2%22%0Aapp%20%3D%20marimo.App(width%3D%22medium%22)%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20marimo%20as%20mo%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%2002%20%E2%80%94%20Basic%20PIV%20workflow%0A%0A%20%20%20%20This%20lesson%20shows%20the%20minimal%20OpenPIV%20pipeline%20and%20connects%20it%20to%20real%20examples%20in%20this%20repository.%0A%0A%20%20%20%20%23%23%20Steps%0A%20%20%20%201.%20Prepare%20image%20pair%20(A%2C%20B).%0A%20%20%20%202.%20Choose%20**window%20size**%20(e.g.%2032%C3%9732)%2C%20**overlap**%20(e.g.%2016%20px%20%3D%2050%25)%2C%20**search%20area**.%0A%20%20%20%203.%20Run%20cross-correlation%20to%20estimate%20displacement%20%24(u%2Cv)%24%20in%20pixels.%0A%20%20%20%204.%20Convert%20to%20physical%20units%20with%20%24%5CDelta%20t%24%20and%20scaling%20if%20needed.%0A%20%20%20%205.%20Validate%20and%20visualize.%0A%0A%20%20%20%20%23%23%20Learn%20from%20these%20examples%0A%20%20%20%20-%20**%5Btutorial1%5D(marimo_notebooks%2Ftutorial1.html)**%20(%5Binteractive%20.py%5D(marimo_notebooks%2Ftutorial1.py)%2C%20%5Bmolab%5D(https%3A%2F%2Fmolab.marimo.io%2Fgithub%2Fopenpiv%2Fopenpiv-python-examples%2Fblob%2Fmain%2Fmarimo_notebooks%2Ftutorial1.py))%20%E2%80%94%20simplest%20two-image%20workflow%3B%20shows%20loading%2C%20processing%2C%20and%20plotting.%20*Use%20when%3A*%20you%20want%20the%20baseline%20pipeline.%0A%20%20%20%20-%20**%5Btutorial2%5D(marimo_notebooks%2Ftutorial2.html)**%20(%5Binteractive%20.py%5D(marimo_notebooks%2Ftutorial2.py)%2C%20%5Bmolab%5D(https%3A%2F%2Fmolab.marimo.io%2Fgithub%2Fopenpiv%2Fopenpiv-python-examples%2Fblob%2Fmain%2Fmarimo_notebooks%2Ftutorial2.py))%20%E2%80%94%20multiprocessing%20for%20speed.%20*Use%20when%3A*%20processing%20many%20pairs.%0A%20%20%20%20-%20**%5Btest1%20case%5D(marimo_cases%2Ftest1.html)**%20(%5Binteractive%20.py%5D(marimo_cases%2Ftest1.py))%20%E2%80%94%20classic%20small%20image%20pair%20(%60exp1_001_a%2Fb.bmp%60).%20*Use%20when%3A*%20verifying%20your%20setup%20on%20a%20known%20case.%0A%20%20%20%20-%20**%5Btest2%20case%5D(marimo_cases%2Ftest2.html)**%20(%5Binteractive%20.py%5D(marimo_cases%2Ftest2.py))%20%E2%80%94%20sequence%20of%20frames%3B%20*use%20when%3A*%20learning%20frame-to-frame%20processing.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%20(mo%2C)%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20numpy%20as%20np%0A%20%20%20%20from%20openpiv.tools%20import%20synimage%0A%20%20%20%20img_a%2C%20img_b%20%3D%20synimage.synimagegen(128%2C%20dt%3D0.1)%0A%20%20%20%20return%20img_a%2C%20img_b%2C%20np%0A%0A%0A%40app.cell%0Adef%20_(img_a%2C%20img_b%2C%20np)%3A%0A%20%20%20%20from%20openpiv%20import%20pyprocess%0A%20%20%20%20u%2C%20v%2C%20s2n%20%3D%20pyprocess.extended_search_area_piv(%0A%20%20%20%20%20%20%20%20img_a.astype(np.int32)%2C%20img_b.astype(np.int32)%2C%0A%20%20%20%20%20%20%20%20window_size%3D32%2C%20overlap%3D16%2C%20dt%3D0.1%2C%20search_area_size%3D64%2C%0A%20%20%20%20%20%20%20%20sig2noise_method%3D'peak2peak'%0A%20%20%20%20)%0A%20%20%20%20print(%22u%20shape%3A%22%2C%20u.shape%2C%20%22finite%20vectors%3A%22%2C%20np.isfinite(u).sum())%0A%20%20%20%20return%20s2n%2C%20u%2C%20v%0A%0A%0A%40app.cell%0Adef%20_(u%2C%20v)%3A%0A%20%20%20%20import%20matplotlib.pyplot%20as%20plt1%0A%20%20%20%20fig1%2C%20ax1%20%3D%20plt1.subplots()%0A%20%20%20%20ax1.quiver(u%2C%20v)%0A%20%20%20%20ax1.invert_yaxis()%0A%20%20%20%20ax1.set_title(%22Velocity%20vectors%20(image%20coordinates)%22)%0A%20%20%20%20fig1%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(s2n)%3A%0A%20%20%20%20import%20matplotlib.pyplot%20as%20plt2%0A%20%20%20%20fig2%2C%20ax2%20%3D%20plt2.subplots()%0A%20%20%20%20im%20%3D%20ax2.imshow(s2n%2C%20cmap%3D'viridis')%0A%20%20%20%20ax2.set_title('Signal-to-noise%20ratio%20(peak2peak)')%0A%20%20%20%20fig2.colorbar(im%2C%20ax%3Dax2)%0A%20%20%20%20fig2%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20How%20to%20read%20this%0A%20%20%20%20-%20**u%2C%20v**%3A%20displacement%2Fvelocity%20components%20per%20interrogation%20window.%0A%20%20%20%20-%20**s2n**%3A%20confidence%20indicator%20%E2%80%94%20higher%20usually%20means%20a%20clearer%20correlation%20peak.%0A%20%20%20%20-%20**Inverted%20y-axis**%3A%20image%20origin%20is%20often%20top-left%3B%20plotting%20conventions%20matter.%0A%0A%20%20%20%20%23%23%20Practical%20tips%0A%20%20%20%20-%20If%20vectors%20look%20random%3A%20try%20larger%20window%20or%20check%20%24%5CDelta%20t%24%2Fseeding.%0A%20%20%20%20-%20If%20field%20is%20too%20coarse%3A%20reduce%20window%20size%20or%20use%20multi-pass%20(next%20lesson).%0A%20%20%20%20-%20Always%20inspect%20s2n%20before%20trusting%20results.%0A%0A%20%20%20%20Next%3A%20%5B03%20%E2%80%94%20Multi-pass%20%26%20window%20deformation%5D(03_multipass_and_deformation.html)%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
4898eb8c73d22aab6f17d4e7884aea57