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%20compare%20the%20OpenPIV%20Python%20with%20PIVLab%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0Aapp._unparsable_cell(%0A%20%20%20%20r%22%22%22%0A%20%20%20%20Analysis%20of%20the%20Karman%20images%0A%20%20%20%20final%20int%20area%206%20pixels%20and%2050%25%20overlap%2C%20%0A%20%20%20%20vector%20validation%20is%20allowed%2C%20but%20no%20smoothing%20after%20the%20last%20correlation.%20%0A%20%20%20%20Only%20the%20circle%20in%20the%20middle%20must%20be%20masked%2C%20not%20the%20shadows.%0A%0A%20%20%20%20Then%20we%20can%20compare%20the%20vorticity%20maps%20(color%20bar%20scale%20of%20uncalibrated%20data%20-0.3%201%2Fframe%20until%20%2B0.3%201%2Fframe%2C%20%0A%20%20%20%20color%20map%20preferably%20%22parula%22%2C%20but%20%22jet%22%20is%20also%20ok).%20That%20might%20give%20an%20idea%20about%20the%20%22quality%22...%3F%0A%20%20%20%20%22%22%22%2C%0A%20%20%20%20name%3D%22_%22%0A)%0A%0A%0Aapp._unparsable_cell(%0A%20%20%20%20r%22%22%22%0A%20%20%20%20FFT%20window%20deformation%0A%20%20%20%20Pass1%3A%2064x64%20px%20with%2050%25%20overlap%0A%20%20%20%20Pass2%3A%2032x32%20px%20with%2050%25%20overlap%0A%20%20%20%20Pass3%3A%2016x16%20px%20with%2050%25%20overlap%0A%20%20%20%20Pass4%3A%206x6%20px%20with%2050%25%20overlap%0A%20%20%20%20Gauss2x3-point%20subpixel%20estimator%0A%20%20%20%20Correlation%20quality%3A%20Extreme%0A%20%20%20%20%22%22%22%2C%0A%20%20%20%20name%3D%22_%22%0A)%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20%23%20magic%20command%20not%20supported%20in%20marimo%3B%20please%20file%20an%20issue%20to%20add%20support%0A%20%20%20%20%23%20%25reload_ext%20watermark%0A%20%20%20%20%23%20magic%20command%20not%20supported%20in%20marimo%3B%20please%20file%20an%20issue%20to%20add%20support%0A%20%20%20%20%23%20%25watermark%20-v%20-m%20-p%20numpy%2Copenpiv%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20from%20openpiv%20import%20windef%0A%0A%20%20%20%20import%20numpy%20as%20np%0A%20%20%20%20import%20os%0A%20%20%20%20from%20time%20import%20time%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%0A%20%20%20%20import%20matplotlib%0A%20%20%20%20matplotlib.rcParams%5B'figure.figsize'%5D%20%3D%20(8.0%2C%206.0)%0A%20%20%20%20return%20(windef%2C)%0A%0A%0A%40app.cell%0Adef%20_(windef)%3A%0A%20%20%20%20settings%20%3D%20windef.PIVSettings()%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%20'..%2Ftest9%2F'%0A%20%20%20%20%23%20Folder%20for%20the%20outputs%0A%20%20%20%20settings.save_path%20%3D%20'..%2Ftest9%2Fresults%2F'%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_1'%0A%20%20%20%20%23%20Format%20and%20Image%20Sequence%0A%20%20%20%20settings.frame_pattern_a%20%3D%20'karman_16Hz_000_A.jpg'%0A%20%20%20%20settings.frame_pattern_b%20%3D%20'karman_16Hz_000_B.jpg'%0A%0A%20%20%20%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%20%20%20%20%23%20settings.ROI%20%3D%20(200%2C400%2C500%2C900)%0A%0A%20%20%20%20%23%20settings.deformation_method%20%3D%20'symmetric'%20%0A%20%20%20%20settings.deformation_method%20%3D%20'second%20image'%0A%0A%0A%20%20%20%20settings.num_iterations%20%3D%204%20%20%23%20select%20the%20number%20of%20PIV%20passes%0A%0A%20%20%20%20%23%20add%20the%20interrogation%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%3D(64%2C%2032%2C%2016%2C%206)%0A%20%20%20%20settings.overlap%3D(32%2C%2016%2C%208%2C%203)%0A%0A%20%20%20%20%23%20settings.windowsizes%20%3D%20(128%2C%2064%2C%2032%2C%2016%2C%208)%20%23%20if%20longer%20than%20n%20iteration%20the%20rest%20is%20ignored%0A%20%20%20%20%23%20The%20overlap%20of%20the%20interroagtion%20window%20for%20each%20pass.%0A%20%20%20%20%23%20settings.overlap%20%3D%20(64%2C%2032%2C%2016%2C%208%2C%204)%20%23%20This%20is%2050%25%20overlap%0A%0A%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%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%0A%20%20%20%20%23%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%20settings.sig2noise_threshold%20%3D%201.25%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%20masked%20to%20masked%20out%20pixels%20next%20to%20the%20main%20peak%0A%20%20%20%20settings.sig2noise_mask%20%3D%202%0A%20%20%20%20settings.sig2noise_validate%20%3D%20False%0A%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%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'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%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%20100%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%0A%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%20%3D%20False%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%0A%0A%20%20%20%20settings.filter_method%20%3D%20'localmean'%0A%0A%0A%20%20%20%20settings.replace_vectors%20%3D%20True%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%0A%0A%20%20%20%20settings.MinMax_U_disp%20%3D%20(-10%2C%2010)%0A%20%20%20%20settings.MinMax_V_disp%20%3D%20(-10%2C%2010)%0A%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%205%20%20%23%20threshold%20of%20the%20std%20validation%0A%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%20%3D%202%20%23%20defines%20the%20size%20of%20the%20local%20median%2C%20it'll%20be%203%20x%203%0A%0A%20%20%20%20%23%20Image%20mask%20properties%0A%20%20%20%20settings.dynamic_masking_method%20%3D%20'intensity'%0A%20%20%20%20settings.dynamic_masking_threshold%20%3D%200.1%0A%20%20%20%20settings.dynamic_masking_filter_size%20%3D%2021%0A%0A%0A%0A%20%20%20%20%23%20Smoothing%20after%20the%20first%20pass%0A%20%20%20%20settings.smoothn%20%3D%20False%20%23Enables%20smoothing%20of%20the%20displacemenet%20field%0A%20%20%20%20settings.smoothn_p%20%3D%200.5%20%23%20This%20is%20a%20smoothing%20parameter%0A%0A%0A%20%20%20%20settings.show_all_plots%20%3D%20True%0A%20%20%20%20return%20(settings%2C)%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20glob%0A%20%20%20%20file_list%20%3D%20sorted(glob.glob('..%2Fdata%2Fkarman_16Hz_*.jpg'))%0A%20%20%20%20file_list%20%3D%20file_list%5B-2%3A%5D%0A%20%20%20%20file_list%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(settings%2C%20windef)%3A%0A%20%20%20%20%23%20magic%20command%20not%20supported%20in%20marimo%3B%20please%20file%20an%20issue%20to%20add%20support%0A%20%20%20%20%23%20%25time%20%0A%20%20%20%20windef.piv(settings)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20%23%20magic%20command%20not%20supported%20in%20marimo%3B%20please%20file%20an%20issue%20to%20add%20support%0A%20%20%20%20%23%20%25debug%20%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20%23%20!pip%20install%20git%2Bhttps%3A%2F%2Fgithub.com%2Falexlib%2Fpivpy%0A%20%20%20%20from%20pivpy%20import%20io%2C%20pivpy%2C%20graphics%0A%0A%20%20%20%20return%20(io%2C)%0A%0A%0A%40app.cell%0Adef%20_(io)%3A%0A%20%20%20%20data%20%3D%20io.load_openpiv_txt('..%2Ftest9%2Fresults%2FOpenPIV_results_6_Test_1%2Ffield_A0000.txt')%0A%20%20%20%20data.piv.vorticity()%0A%20%20%20%20data.piv.quiver()%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
5702f6ab03a0fdd8989328da251033c0