In this Notebook a number of test cases using the PIV sythetic image generator will be presented.
The three examples shown are:
In each of these cases the pattern to recieving the synthetic images is the same. The part that mostly varies is the data passed.
In [1]:
import synimagegen
import matplotlib.pyplot as plt
import numpy as np
import os
%matplotlib inline
In this case no data is passed to the function, so a random equation is invoked from the cff module. (line 46,52 in synimagegen.py)
This equation defines the velocities U,V for each point in the X,Y plane.
This equation is ment to be changed to suit the testing needs of each users system.
In [2]:
ground_truth,cv,x_1,y_1,U_par,V_par,par_diam1,par_int1,x_2,y_2,par_diam2,par_int2 = synimagegen.create_synimage_parameters(None,[0,1],[0,1],[256,256],dt=0.0025)
In [3]:
frame_a = synimagegen.generate_particle_image(256, 256, x_1, y_1, par_diam1, par_int1,16)
frame_b = synimagegen.generate_particle_image(256, 256, x_2, y_2, par_diam2, par_int2,16)
In [4]:
fig = plt.figure(figsize=(20,10))
a = fig.add_subplot(1, 2, 1,)
imgplot = plt.imshow(frame_a, cmap='gray')
a.set_title('frame_a')
a = fig.add_subplot(1, 2, 2)
imgplot = plt.imshow(frame_b, cmap='gray')
a.set_title('frame_b')
Out[4]:
In [5]:
data = np.load('PIV_experiment_data.npz')
In [6]:
data = np.stack([data['X'], data['Y'],data['U'] ,data['V']], axis=2)
In [7]:
ground_truth,cv,x_1,y_1,U_par,V_par,par_diam1,par_int1,x_2,y_2,par_diam2,par_int2 = synimagegen.create_synimage_parameters(data,[0,1],[0,1],[256,256],inter=True,dt=0.0025)
In [8]:
frame_a = synimagegen.generate_particle_image(256, 256, x_1, y_1, par_diam1, par_int1,16)
frame_b = synimagegen.generate_particle_image(256, 256, x_2, y_2, par_diam2, par_int2,16)
In [9]:
fig = plt.figure(figsize=(20,10))
a = fig.add_subplot(1, 2, 1)
imgplot = plt.imshow(frame_a, cmap='gray')
a.set_title('frame_a')
a = fig.add_subplot(1, 2, 2)
imgplot = plt.imshow(frame_b, cmap='gray')
a.set_title('frame_b')
Out[9]:
In [10]:
path_to_file = os.getcwd() + '/velocity_report.txt'
ground_truth,cv,x_1,y_1,U_par,V_par,par_diam1,par_int1,x_2,y_2,par_diam2,par_int2 = synimagegen.create_synimage_parameters(None,[0,1],[0,1],[256,256],path=path_to_file,inter=True,dt=0.0025)
In [11]:
frame_a = synimagegen.generate_particle_image(256, 256, x_1, y_1, par_diam1, par_int1,16)
frame_b = synimagegen.generate_particle_image(256, 256, x_2, y_2, par_diam2, par_int2,16)
In [12]:
fig = plt.figure(figsize=(20,10))
a = fig.add_subplot(1, 2, 1)
imgplot = plt.imshow(frame_a, cmap='gray')
a.set_title('frame_a')
a = fig.add_subplot(1, 2, 2)
imgplot = plt.imshow(frame_b, cmap='gray')
a.set_title('frame_b')
Out[12]: