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.
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.
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)
Requested pair loss: 10 Actual pair loss: 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)
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')
Text(0.5, 1.0, 'frame_b')
In this case experiment data is passed to the function, and the interpolation flag is enabled. Thus using the data to create a continous flow field by interpolation and then using the field to create the paramters.
data = np.load('PIV_experiment_data.npz')
data = np.stack([data['X'], data['Y'],data['U'] ,data['V']], axis=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(data,[0,1],[0,1],[256,256],inter=True,dt=0.0025)
Requested pair loss: 10 Actual pair loss: 11
/home/user/miniconda3/envs/openpiv/lib/python3.7/site-packages/scipy/interpolate/_fitpack_impl.py:976: RuntimeWarning: No more knots can be added because the additional knot would coincide with an old one. Probable cause: s too small or too large a weight to an inaccurate data point. (fp>s) kx,ky=1,1 nx,ny=4,4 m=256 fp=67208.139125 s=0.000000 warnings.warn(RuntimeWarning(_iermess2[ierm][0] + _mess)) /home/user/miniconda3/envs/openpiv/lib/python3.7/site-packages/scipy/interpolate/_fitpack_impl.py:976: RuntimeWarning: No more knots can be added because the additional knot would coincide with an old one. Probable cause: s too small or too large a weight to an inaccurate data point. (fp>s) kx,ky=1,1 nx,ny=4,4 m=256 fp=120693.580633 s=0.000000 warnings.warn(RuntimeWarning(_iermess2[ierm][0] + _mess))
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)
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')
Text(0.5, 1.0, 'frame_b')
In this case flow simulation results are passed to the function, in the form of a tab-delimited text file. The file is parsed and the data is used in order to continous flow field by interpolation.
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)
/home/user/miniconda3/envs/openpiv/lib/python3.7/site-packages/scipy/interpolate/_fitpack_impl.py:976: RuntimeWarning: No more knots can be added because the number of B-spline coefficients already exceeds the number of data points m. Probable causes: either s or m too small. (fp>s) kx,ky=1,1 nx,ny=81,67 m=5106 fp=0.183584 s=0.000000 warnings.warn(RuntimeWarning(_iermess2[ierm][0] + _mess))
Requested pair loss: 10 Actual pair loss: 10
/home/user/miniconda3/envs/openpiv/lib/python3.7/site-packages/scipy/interpolate/_fitpack_impl.py:976: RuntimeWarning: No more knots can be added because the number of B-spline coefficients already exceeds the number of data points m. Probable causes: either s or m too small. (fp>s) kx,ky=1,1 nx,ny=49,112 m=5106 fp=1.616903 s=0.000000 warnings.warn(RuntimeWarning(_iermess2[ierm][0] + _mess))
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)
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')
Text(0.5, 1.0, 'frame_b')