{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "scrolled": true }, "outputs": [], "source": [ "#Run the new window deformation" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "new_windef = True" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "if new_windef:\n", " from openpiv import windef\n", "else:\n", " from openpiv import original_windef as windef\n", " \n", "from openpiv import tools, scaling, validation, filters, preprocess\n", "import openpiv.pyprocess as process\n", "from openpiv import pyprocess\n", "from openpiv import widim\n", "import numpy as np\n", "import os\n", "from time import time\n", "import warnings\n", "\n", "\n", "import matplotlib.pyplot as plt\n", "%matplotlib inline\n", "\n", "import matplotlib\n", "matplotlib.rcParams['figure.figsize'] = (8.0, 8.0)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "settings = windef.Settings()\n", "\n", "\n", "'Data related settings'\n", "# Folder with the images to process\n", "settings.filepath_images = '../test10/'\n", "# Folder for the outputs\n", "settings.save_path = '../test1/'\n", "# Root name of the output Folder for Result Files\n", "settings.save_folder_suffix = 'Test_1'\n", "# Format and Image Sequence\n", "settings.frame_pattern_a = 'B001_1.tif'\n", "settings.frame_pattern_b = 'B001_2.tif'\n", "\n", "'Region of interest'\n", "# (50,300,50,300) #Region of interest: (xmin,xmax,ymin,ymax) or 'full' for full image\n", "settings.ROI = 'full'\n", "\n", "'Image preprocessing'\n", "# 'None' for no masking, 'edges' for edges masking, 'intensity' for intensity masking\n", "# WARNING: This part is under development so better not to use MASKS\n", "settings.dynamic_masking_method = 'edges'\n", "settings.dynamic_masking_threshold = 0.005\n", "settings.dynamic_masking_filter_size = 7\n", "\n", "# settings.deformation_method = 'symmetric' #'second image' #'symmetric' # or 'second image'\n", "\n", "'Processing Parameters'\n", "settings.correlation_method='linear' #'circular' or 'linear'\n", "settings.normalized_correlation = True\n", "\n", "\n", "settings.num_iterations = 4 # 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", "settings.windowsizes=(64, 32, 24, 8)\n", "settings.overlap=(32, 16, 12, 4)\n", "\n", "# settings.windowsizes = (128, 64, 32, 16, 8) # if longer than n iteration the rest is ignored\n", "# The overlap of the interroagtion window for each pass.\n", "# settings.overlap = (64, 32, 16, 8, 4) # This is 50% overlap\n", "\n", "\n", "\n", "# Has to be a value with base two. In general window size/2 is a good choice.\n", "# methode used for subpixel interpolation: 'gaussian','centroid','parabolic'\n", "settings.subpixel_method = 'gaussian'\n", "# order of the image interpolation for the window deformation\n", "settings.interpolation_order = 3\n", "settings.scaling_factor = 1 # scaling factor pixel/meter\n", "settings.dt = 1 # time between to frames (in seconds)\n", "'Signal to noise ratio options (only for the last pass)'\n", "# It is possible to decide if the S/N should be computed (for the last pass) or not\n", "if not new_windef:\n", " settings.extract_sig2noise = True # 'True' or 'False' (only for the last pass)\n", " \n", "# method used to calculate the signal to noise ratio 'peak2peak' or 'peak2mean'\n", "settings.sig2noise_method = 'peak2mean'\n", "# select the width of the masked to masked out pixels next to the main peak\n", "settings.sig2noise_mask = 2\n", "# If extract_sig2noise==False the values in the signal to noise ratio\n", "# output column are set to NaN\n", "'vector validation options'\n", "# choose if you want to do validation of the first pass: True or False\n", "settings.validation_first_pass = True\n", "# only effecting the first pass of the interrogation the following passes\n", "# in the multipass will be validated\n", "'Validation Parameters'\n", "# The validation is done at each iteration based on three filters.\n", "# The first filter is based on the min/max ranges. Observe that these values are defined in\n", "# terms of minimum and maximum displacement in pixel/frames.\n", "settings.MinMax_U_disp = (-30, 30)\n", "settings.MinMax_V_disp = (-30, 30)\n", "# The second filter is based on the global STD threshold\n", "settings.std_threshold = 4 # threshold of the std validation\n", "# The third filter is the median test (not normalized at the moment)\n", "settings.median_threshold = 3 # threshold of the median validation\n", "# On the last iteration, an additional validation can be done based on the S/N.\n", "settings.median_size = 3 #defines the size of the local median\n", "'Validation based on the signal to noise ratio'\n", "# Note: only available when extract_sig2noise==True and only for the last\n", "# pass of the interrogation\n", "# Enable the signal to noise ratio validation. Options: True or False\n", "# settings.do_sig2noise_validation = False # This is time consuming\n", "# minmum signal to noise ratio that is need for a valid vector\n", "settings.sig2noise_threshold = 1.5\n", "'Outlier replacement or Smoothing options'\n", "# Replacment options for vectors which are masked as invalid by the validation\n", "settings.replace_vectors = True # Enable the replacment. Chosse: True or False\n", "settings.smoothn = False #Enables smoothing of the displacemenet field\n", "settings.smoothn_p = 0.5 # This is a smoothing parameter\n", "# select a method to replace the outliers: 'localmean', 'disk', 'distance'\n", "settings.filter_method = 'localmean'\n", "# maximum iterations performed to replace the outliers\n", "settings.max_filter_iteration = 4\n", "settings.filter_kernel_size = 2 # kernel size for the localmean method\n", "'Output options'\n", "# Select if you want to save the plotted vectorfield: True or False\n", "settings.save_plot = False\n", "# Choose wether you want to see the vectorfield or not :True or False\n", "settings.show_plot = True\n", "settings.scale_plot = 200 # select a value to scale the quiver plot of the vectorfield\n", "# run the script with the given settings\n", "\n", "settings.show_all_plots = False" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "global filter invalidated 0.0 vectors\n", "std filter invalidated 2.0 vectors\n", "median filter invalidated 3 vectors\n", "s2n filter invalidated 0.0 vectors\n", "show all plots is False\n", "global filter invalidated 0.0 vectors\n", "median filter invalidated 11 vectors\n", "s2n filter invalidated 0.0 vectors\n", "show all plots is False\n", "global filter invalidated 0.0 vectors\n", "median filter invalidated 15 vectors\n", "s2n filter invalidated 0.0 vectors\n", "show all plots is False\n", "global filter invalidated 0.0 vectors\n", "median filter invalidated 26 vectors\n", "s2n filter invalidated 0.0 vectors\n", "Image Pair 1\n" ] } ], "source": [ "windef.piv(settings)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "#Run the extended search area PIV" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "global filter invalidated 0.0 vectors\n", "std filter invalidated 3.0 vectors\n", "median filter invalidated 5 vectors\n", "s2n filter invalidated 0.0 vectors\n", "show all plots is False\n", "global filter invalidated 0.0 vectors\n", "median filter invalidated 15 vectors\n", "s2n filter invalidated 0.0 vectors\n", "show all plots is False\n", "global filter invalidated 0.0 vectors\n", "median filter invalidated 19 vectors\n", "s2n filter invalidated 0.0 vectors\n", "show all plots is False\n", "global filter invalidated 0.0 vectors\n", "median filter invalidated 18 vectors\n", "s2n filter invalidated 0.0 vectors\n", "Image Pair 1\n" ] } ], "source": [ "settings.frame_pattern_a = 'B002_1.tif'\n", "settings.frame_pattern_b = 'B002_2.tif'\n", "windef.piv(settings)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "global filter invalidated 0.0 vectors\n", "std filter invalidated 3.0 vectors\n", "median filter invalidated 3 vectors\n", "s2n filter invalidated 0.0 vectors\n", "show all plots is False\n", "global filter invalidated 0.0 vectors\n", "median filter invalidated 11 vectors\n", "s2n filter invalidated 0.0 vectors\n", "show all plots is False\n", "global filter invalidated 0.0 vectors\n", "median filter invalidated 21 vectors\n", "s2n filter invalidated 0.0 vectors\n", "show all plots is False\n", "global filter invalidated 0.0 vectors\n", "median filter invalidated 17 vectors\n", "s2n filter invalidated 0.0 vectors\n", "Image Pair 1\n" ] } ], "source": [ "settings.frame_pattern_a = 'B003_1.tif'\n", "settings.frame_pattern_b = 'B003_2.tif'\n", "windef.piv(settings)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "global filter invalidated 0.0 vectors\n", "std filter invalidated 4.0 vectors\n", "median filter invalidated 3 vectors\n", "s2n filter invalidated 0.0 vectors\n", "show all plots is False\n", "global filter invalidated 0.0 vectors\n", "median filter invalidated 19 vectors\n", "s2n filter invalidated 0.0 vectors\n", "show all plots is False\n", "global filter invalidated 0.0 vectors\n", "median filter invalidated 27 vectors\n", "s2n filter invalidated 0.0 vectors\n", "show all plots is False\n", "global filter invalidated 0.0 vectors\n", "median filter invalidated 19 vectors\n", "s2n filter invalidated 74.0 vectors\n", "Image Pair 1\n" ] } ], "source": [ "settings.frame_pattern_a = 'B004_1.tif'\n", "settings.frame_pattern_b = 'B004_2.tif'\n", "windef.piv(settings)" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "global filter invalidated 0.0 vectors\n", "std filter invalidated 2.0 vectors\n", "median filter invalidated 5 vectors\n", "s2n filter invalidated 0.0 vectors\n", "show all plots is False\n", "global filter invalidated 0.0 vectors\n", "median filter invalidated 19 vectors\n", "s2n filter invalidated 0.0 vectors\n", "show all plots is False\n", "global filter invalidated 0.0 vectors\n", "median filter invalidated 32 vectors\n", "s2n filter invalidated 0.0 vectors\n", "show all plots is False\n", "global filter invalidated 0.0 vectors\n", "median filter invalidated 14 vectors\n", "s2n filter invalidated 772.0 vectors\n", "Image Pair 1\n" ] } ], "source": [ "settings.frame_pattern_a = 'B005_1.tif'\n", "settings.frame_pattern_b = 'B005_2.tif'\n", "windef.piv(settings)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "global filter invalidated 0.0 vectors\n", "std filter invalidated 3.0 vectors\n", "median filter invalidated 5 vectors\n", "s2n filter invalidated 0.0 vectors\n", "show all plots is False\n", "global filter invalidated 0.0 vectors\n", "median filter invalidated 17 vectors\n", "s2n filter invalidated 0.0 vectors\n", "show all plots is False\n", "global filter invalidated 0.0 vectors\n", "median filter invalidated 37 vectors\n", "s2n filter invalidated 3.0 vectors\n", "show all plots is False\n", "global filter invalidated 0.0 vectors\n", "median filter invalidated 5 vectors\n", "s2n filter invalidated 4439.0 vectors\n", "Image Pair 1\n" ] } ], "source": [ "settings.frame_pattern_a = 'B006_1.tif'\n", "settings.frame_pattern_b = 'B006_2.tif'\n", "windef.piv(settings)" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "from openpiv.pyprocess import extended_search_area_piv as piv\n", "from openpiv.piv import simple_piv\n", "from openpiv.pyprocess import get_coordinates\n", "from openpiv.tools import display_vector_field\n" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "import glob\n", "files = sorted(glob.glob(settings.filepath_images + '/*.tif'))\n", "simple_piv(files[0], files[1]);" ] } ], "metadata": { "jupytext": { "formats": "ipynb,py:percent" }, "kernelspec": { "display_name": "Python [conda env:openpiv] *", "language": "python", "name": "conda-env-openpiv-py" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.5" } }, "nbformat": 4, "nbformat_minor": 4 }