import%20marimo%0A%0A__generated_with%20%3D%20%220.25.2%22%0Aapp%20%3D%20marimo.App()%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20marimo%20as%20mo%0A%0A%20%20%20%20return%20(mo%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%20Run%20the%20window%20deformation%20algorithm%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20from%20openpiv%20import%20windef%0A%20%20%20%20from%20openpiv%20import%20tools%2C%20scaling%2C%20validation%2C%20filters%2C%20preprocess%0A%20%20%20%20import%20openpiv.pyprocess%20as%20process%0A%20%20%20%20from%20openpiv%20import%20pyprocess%0A%20%20%20%20import%20numpy%20as%20np%0A%20%20%20%20import%20pathlib%0A%20%20%20%20from%20time%20import%20time%0A%20%20%20%20import%20warnings%0A%0A%0A%20%20%20%20import%20matplotlib.pyplot%20as%20plt%0A%20%20%20%20%23%20'%25matplotlib%20inline'%20command%20supported%20automatically%20in%20marimo%0A%20%20%20%20return%20pathlib%2C%20windef%0A%0A%0A%40app.cell%0Adef%20_(pathlib%2C%20windef)%3A%0A%20%20%20%20settings%20%3D%20windef.PIVSettings()%0A%0A%0A%20%20%20%20%23%20'Data%20related%20settings'%0A%20%20%20%20%23%20Folder%20with%20the%20images%20to%20process%0A%20%20%20%20settings.filepath_images%20%3D%20pathlib.Path('..%2Ftest20%2F')%0A%20%20%20%20%23%20Folder%20for%20the%20outputs%0A%20%20%20%20settings.save_path%20%3D%20settings.filepath_images%0A%20%20%20%20%23%20Root%20name%20of%20the%20output%20Folder%20for%20Result%20Files%0A%20%20%20%20settings.save_folder_suffix%20%3D%20'test_20'%0A%20%20%20%20%23%20Format%20and%20Image%20Sequence%0A%20%20%20%20settings.frame_pattern_a%20%3D%20't_23.png'%0A%20%20%20%20settings.frame_pattern_b%20%3D%20't_24.png'%0A%0A%20%20%20%20%23%20'Region%20of%20interest'%0A%20%20%20%20%23%20(50%2C300%2C50%2C300)%20%23Region%20of%20interest%3A%20(xmin%2Cxmax%2Cymin%2Cymax)%20or%20'full'%20for%20full%20image%0A%20%20%20%20settings.ROI%20%3D%20'full'%0A%0A%20%20%20%20%23%20'Image%20preprocessing'%0A%20%20%20%20%23%20'None'%20for%20no%20flaging%2C%20'edges'%20for%20edges%20flaging%2C%20'intensity'%20for%20intensity%20flaging%0A%20%20%20%20%23%20WARNING%3A%20This%20part%20is%20under%20development%20so%20better%20not%20to%20use%20flagS%0A%20%20%20%20settings.dynamic_flaging_method%20%3D%20'None'%0A%20%20%20%20settings.dynamic_flaging_threshold%20%3D%200.005%0A%20%20%20%20settings.dynamic_flaging_filter_size%20%3D%207%0A%0A%20%20%20%20settings.deformation_method%20%3D%20'symmetric'%0A%0A%20%20%20%20%23%20'Processing%20Parameters'%0A%20%20%20%20settings.correlation_method%3D'circular'%20%20%23%20'circular'%20or%20'linear'%0A%20%20%20%20settings.normalized_correlation%3DFalse%0A%0A%20%20%20%20settings.num_iterations%20%3D%203%20%20%23%20select%20the%20number%20of%20PIV%20passes%0A%20%20%20%20%23%20add%20the%20interroagtion%20window%20size%20for%20each%20pass.%20%0A%20%20%20%20%23%20For%20the%20moment%2C%20it%20should%20be%20a%20power%20of%202%20%0A%20%20%20%20settings.windowsizes%20%3D%20(64%2C%2032%2C%2016)%20%23%20if%20longer%20than%20n%20iteration%20the%20rest%20is%20ignored%2C%20rectangular%20windows%20are%20arrange%20as%20%5By%2Cx%5D%0A%20%20%20%20%23%20The%20overlap%20of%20the%20interroagtion%20window%20for%20each%20pass.%0A%20%20%20%20settings.overlap%20%3D%20(34%2C%2016%2C%208)%20%23%20This%20is%2050%25%20overlap%0A%20%20%20%20%23%20Has%20to%20be%20a%20value%20with%20base%20two.%20In%20general%20window%20size%2F2%20is%20a%20good%20choice.%0A%20%20%20%20%23%20methode%20used%20for%20subpixel%20interpolation%3A%20'gaussian'%2C'centroid'%2C'parabolic'%0A%20%20%20%20settings.subpixel_method%20%3D%20'gaussian'%0A%20%20%20%20%23%20use%20vectorized%20sig2noise%20and%20subpixel%20approximation%20functions%20for%20speed%0A%20%20%20%20settings.use_vectorized%20%3D%20False%0A%20%20%20%20%23%20order%20of%20the%20image%20interpolation%20for%20the%20window%20deformation%0A%20%20%20%20settings.interpolation_order%20%3D%203%0A%20%20%20%20settings.scaling_factor%20%3D%201%20%20%23%20scaling%20factor%20pixel%2Fmeter%0A%20%20%20%20settings.dt%20%3D%201%20%20%23%20time%20between%20to%20frames%20(in%20seconds)%0A%20%20%20%20'Signal%20to%20noise%20ratio%20options%20(only%20for%20the%20last%20pass)'%0A%20%20%20%20%23%20It%20is%20possible%20to%20decide%20if%20the%20S%2FN%20should%20be%20computed%20(for%20the%20last%20pass)%20or%20not%0A%20%20%20%20%23%20settings.extract_sig2noise%20%3D%20True%20%20%23%20'True'%20or%20'False'%20(only%20for%20the%20last%20pass)%0A%20%20%20%20%23%20method%20used%20to%20calculate%20the%20signal%20to%20noise%20ratio%20'peak2peak'%20or%20'peak2mean'%0A%20%20%20%20settings.sig2noise_method%20%3D%20'peak2peak'%0A%20%20%20%20%23%20select%20the%20width%20of%20the%20flaged%20to%20flaged%20out%20pixels%20next%20to%20the%20main%20peak%0A%20%20%20%20settings.sig2noise_flag%20%3D%202%0A%20%20%20%20%23%20If%20extract_sig2noise%3D%3DFalse%20the%20values%20in%20the%20signal%20to%20noise%20ratio%0A%20%20%20%20%23%20output%20column%20are%20set%20to%20NaN%0A%0A%20%20%20%20%23%20'vector%20validation%20options'%0A%20%20%20%20%23%20choose%20if%20you%20want%20to%20do%20validation%20of%20the%20first%20pass%3A%20True%20or%20False%0A%20%20%20%20settings.validation_first_pass%20%3D%20True%0A%20%20%20%20%23%20only%20effecting%20the%20first%20pass%20of%20the%20interrogation%20the%20following%20passes%0A%20%20%20%20%23%20in%20the%20multipass%20will%20be%20validated%0A%0A%20%20%20%20%23%20'Validation%20Parameters'%0A%0A%20%20%20%20%23%20The%20validation%20is%20done%20at%20each%20iteration%20based%20on%20three%20filters.%0A%20%20%20%20%23%20The%20first%20filter%20is%20based%20on%20the%20min%2Fmax%20ranges.%20Observe%20that%20these%20values%20are%20defined%20in%0A%20%20%20%20%23%20terms%20of%20minimum%20and%20maximum%20displacement%20in%20pixel%2Fframes.%0A%20%20%20%20settings.MinMax_U_disp%20%3D%20(-30%2C%2030)%0A%20%20%20%20settings.MinMax_V_disp%20%3D%20(-30%2C%2030)%0A%20%20%20%20%23%20The%20second%20filter%20is%20based%20on%20the%20global%20STD%20threshold%0A%20%20%20%20settings.std_threshold%20%3D%207%20%20%23%20threshold%20of%20the%20std%20validation%0A%20%20%20%20%23%20The%20third%20filter%20is%20the%20median%20test%20(not%20normalized%20at%20the%20moment)%0A%20%20%20%20settings.median_threshold%20%3D%203%20%20%23%20threshold%20of%20the%20median%20validation%0A%20%20%20%20%23%20On%20the%20last%20iteration%2C%20an%20additional%20validation%20can%20be%20done%20based%20on%20the%20S%2FN.%0A%20%20%20%20settings.median_size%3D1%20%23defines%20the%20size%20of%20the%20local%20median%0A%0A%20%20%20%20%23%20%20'Validation%20based%20on%20the%20signal%20to%20noise%20ratio'%0A%20%20%20%20%23%20Note%3A%20only%20available%20when%20extract_sig2noise%3D%3DTrue%20and%20only%20for%20the%20last%0A%20%20%20%20%23%20pass%20of%20the%20interrogation%0A%20%20%20%20%23%20Enable%20the%20signal%20to%20noise%20ratio%20validation.%20Options%3A%20True%20or%20False%0A%20%20%20%20%23%20settings.do_sig2noise_validation%20%3D%20False%20%23%20This%20is%20time%20consuming%0A%20%20%20%20%23%20minmum%20signal%20to%20noise%20ratio%20that%20is%20need%20for%20a%20valid%20vector%0A%20%20%20%20settings.sig2noise_threshold%20%3D%201.2%0A%0A%20%20%20%20%23%20'Outlier%20replacement%20or%20Smoothing%20options'%0A%20%20%20%20%23%20Replacment%20options%20for%20vectors%20which%20are%20flaged%20as%20invalid%20by%20the%20validation%0A%20%20%20%20settings.replace_vectors%20%3D%20True%20%23%20Enable%20the%20replacment.%20Chosse%3A%20True%20or%20False%0A%20%20%20%20settings.smoothn%3DTrue%20%23Enables%20smoothing%20of%20the%20displacemenet%20field%0A%20%20%20%20settings.smoothn_p%3D0.5%20%23%20This%20is%20a%20smoothing%20parameter%0A%20%20%20%20%23%20select%20a%20method%20to%20replace%20the%20outliers%3A%20'localmean'%2C%20'disk'%2C%20'distance'%0A%20%20%20%20settings.filter_method%20%3D%20'localmean'%0A%20%20%20%20%23%20maximum%20iterations%20performed%20to%20replace%20the%20outliers%0A%20%20%20%20settings.max_filter_iteration%20%3D%204%0A%20%20%20%20settings.filter_kernel_size%20%3D%202%20%20%23%20kernel%20size%20for%20the%20localmean%20method%0A%0A%20%20%20%20%23%20'Output%20options'%0A%20%20%20%20%23%20Select%20if%20you%20want%20to%20save%20the%20plotted%20vectorfield%3A%20True%20or%20False%0A%20%20%20%20settings.save_plot%20%3D%20False%0A%20%20%20%20settings.show_all_plots%20%3D%20True%0A%20%20%20%20%23%20Choose%20wether%20you%20want%20to%20see%20the%20vectorfield%20or%20not%20%3ATrue%20or%20False%0A%20%20%20%20settings.show_plot%20%3D%20True%0A%20%20%20%20settings.scale_plot%20%3D%2020%20%20%23%20select%20a%20value%20to%20scale%20the%20quiver%20plot%20of%20the%20vectorfield%0A%20%20%20%20%23%20run%20the%20script%20with%20the%20given%20settings%0A%20%20%20%20return%20(settings%2C)%0A%0A%0A%40app.cell%0Adef%20_(settings%2C%20windef)%3A%0A%20%20%20%20windef.piv(settings)%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
4a49ec4ba73a96ef605838210f4ddabc