def test_oseen(coreR, gamma, dist,xdrift,ydrift):
     print('|*|coreR:',coreR,'Gamma',gamma,'xdrift',xdrift,'ydrift',ydrift,'|*|')
     model = [[],[],[],[],[],[]]
     model[0] = coreR
     model[1] = gamma
     coreRori = model[0]
     gammaori = model[1]
     X = np.linspace(-1,1,dist)
     Y = np.linspace(-1,1,dist)
     X, Y = np.meshgrid(X,Y)
     fxCenter = 0.0
     fyCenter = 0.0
     u_conv = 0.0 #flipped with v, fix later
     v_conv = 0.0
     Uw, Vw = fitting.velocity_model(coreR, gamma, fxCenter, fyCenter, u_conv, v_conv, X+xdrift, Y+ydrift)
     Uw = Uw + u_conv
     Vw = Vw + v_conv
     # NOISE
     Uw = np.random.normal(Uw,0.3)
     Vw = np.random.normal(Vw,0.3)
     model = fitting.fit(coreR, gamma, X, Y, fxCenter, fyCenter, Uw, Vw, u_conv, v_conv)
     print('coreR:',model[0],'error(%):',(1-(model[0])/coreRori)*100)
     print('gamma:',model[1],'error(%):',(1-(model[1])/gammaori)*100)
     print('fxCenter:',model[2])
     print('fyCenter:',model[3])
     #print('u_conv:',model[4])
     #print('v_conv:',model[5])
     #print('xCenter:', fxCenter)
     #print('yCenter:',fyCenter)
     uMod, vMod = fitting.velocity_model(model[0], model[1], model[2], model[3],u_conv,v_conv, X, Y)#, model[4], model[5])
     corr = fitting.correlation_coef(Uw,Vw,uMod,vMod)
     print('correlation:',corr)
     print('---')
     plot.plot_corr(X, Y, Uw, Vw, uMod, vMod, model[0], corr)
Exemple #2
0
 def test_oseen(coreR, gamma, dist,xdrift,ydrift,u_conv,v_conv):
     print('coreR:',coreR,'Gamma',gamma,'xdrift',xdrift,
           'ydrift',ydrift,'u_conv',u_conv,'v_conv',v_conv)
     model = [[],[],[],[],[],[]]
     model[0] = coreR
     model[1] = gamma
     coreRori = model[0]
     gammaori = model[1]
     x_index = np.linspace(-1,1,dist)
     y_index = np.linspace(-1,1,dist)
     x_index, y_index = np.meshgrid(x_index, y_index)
     x_real = 0.0
     y_real = 0.0
     model[4] = u_conv
     model[5] = v_conv
     u_data, v_data = fitting.velocity_model(coreR, gamma, x_real, y_real,
                                             u_conv, v_conv, x_index+xdrift, y_index+ydrift)
     u_data = u_data + u_conv
     v_data = v_data + v_conv
     # NOISE
     u_data = np.random.normal(u_data,0.3)
     v_data = np.random.normal(v_data,0.3)
     model = fitting.fit(coreR, gamma, x_index, y_index, x_real, y_real, u_data, v_data, u_conv, v_conv,0)
     print('coreR:',model[0],'error(%):',(1-(model[0])/coreRori)*100)
     print('gamma:',model[1],'error(%):',(1-(model[1])/gammaori)*100)
     print('x_real:',model[2])
     print('y_real:',model[3])
     u_model, v_model = fitting.velocity_model(model[0], model[1], model[2], model[3],
                                               model[4],model[5], x_index, y_index)
     corr = fitting.correlation_coef(u_data,v_data,u_model,v_model)
     print('correlation:',corr)
     print('---')
     plot.plot_fit_test(x_index, y_index, u_data, v_data, u_model, v_model, model[2], model[3], model[0], model[1], model[4],model[5], corr)
Exemple #3
0
def plot_vortex(a, vortices):
    outfile = open('../results/vortices.dat', 'w')
    outfile.write('radius gamma x_index y_index u_c v_c dist corr\n')
    for i, line in enumerate(vortices):
        #print(line)
        outfile.write("{0} {1} {2} {3} {4} {5} {6} {7} \n".format(
            line[0], line[1], line[2], line[3], line[4], line[5], line[6],
            line[7]))
        print('r:', line[0], 'gamma:', line[1], 'x:', line[2], 'y', line[3],
              'dist', line[6], 'corr', line[7])
        dx = a.dx[5] - a.dx[4]
        dy = a.dy[5] - a.dy[4]
        x_index, y_index, u_data, v_data = tools.window(
            a, round(line[2] / dx, 0), round(line[3] / dy, 0), line[6])
        u_model, v_model = fitting.velocity_model(line[0], line[1], line[2],
                                                  line[3], line[4], line[5],
                                                  x_index, y_index)
        corr = fitting.correlation_coef(u_data, v_data, u_model, v_model)
        plot_fit(x_index, y_index, u_data, v_data, u_model, v_model, line[2],
                 line[3], line[0], line[1], line[4], line[5], corr, i, 1)
        corr = fitting.correlation_coef(u_data - line[4], v_data - line[5],
                                        u_model - line[4], v_model - line[5])
        plot_fit(x_index, y_index, u_data - line[4], v_data - line[5],
                 u_model - line[4], v_model - line[5], line[2], line[3],
                 line[0], line[1], line[4], line[5], corr, i, 2)
Exemple #4
0
 def test_oseen(core_radius, gamma, dist, xdrift, ydrift, u_advection,
                v_advection):
     print('core_radius:', core_radius, 'Gamma', gamma, 'xdrift', xdrift,
           'ydrift', ydrift, 'u_advection', u_advection, 'v_advection',
           v_advection)
     model = [[], [], [], [], [], []]
     model[0] = core_radius
     model[1] = gamma
     core_radius_ori = model[0]
     gamma_ori = model[1]
     x_index = np.linspace(-1, 1, dist)
     y_index = np.linspace(-1, 1, dist)
     x_index, y_index = np.meshgrid(x_index, y_index)
     x_real = 0.0
     y_real = 0.0
     model[4] = u_advection
     model[5] = v_advection
     u_data, v_data = fitting.velocity_model(core_radius, gamma, x_real,
                                             y_real, u_advection,
                                             v_advection, x_index + xdrift,
                                             y_index + ydrift)
     u_data = u_data + u_advection
     v_data = v_data + v_advection
     # NOISE
     u_data = np.random.normal(u_data, 0.3)
     v_data = np.random.normal(v_data, 0.3)
     model = fitting.fit(core_radius, gamma, x_index, y_index, x_real,
                         y_real, u_data, v_data, u_advection, v_advection,
                         0)
     print('core_radius:', model[0], 'error(%):',
           (1 - (model[0]) / core_radius_ori) * 100)
     print('gamma:', model[1], 'error(%):',
           (1 - (model[1]) / gamma_ori) * 100)
     print('x_real:', model[2])
     print('y_real:', model[3])
     u_model, v_model = fitting.velocity_model(model[0], model[1], model[2],
                                               model[3], model[4], model[5],
                                               x_index, y_index)
     corr = fitting.correlation_coef(u_data, v_data, u_model, v_model)
     print('correlation:', corr)
     print('---')
     fitting.plot_fit(x_index, y_index, u_data, v_data, u_model, v_model,
                      model[2], model[3], model[0], model[1], model[4],
                      model[5], corr, 0, 0, '.', 0, 'png')
# data
velocity_x[:] = np.random.random((1, ndim, ndim)) / 10
velocity_y[:] = np.random.random((1, ndim, ndim)) / 10
velocity_z[:] = np.random.random((1, ndim, ndim)) / 10

# grid
x_grid = np.linspace(0, ndim, ndim)
y_grid = np.linspace(0, ndim, ndim)

x_matrix, y_matrix = np.meshgrid(x_grid, y_grid)
core_radius = 5.0
gamma = 30
x_center = 64
y_center = 192
u_advection = 0.0
v_advection = 0.3
u_data, v_data = fitting.velocity_model(core_radius, gamma, x_center, y_center,
                                        u_advection, v_advection, x_matrix,
                                        y_matrix)
u_data = u_data + u_advection
v_data = v_data + v_advection

velocity_x[0, :, :] += u_data[:, :]
velocity_y[0, :, :] += v_data[:, :]
s = 4  # sampling factor for quiver plot
plt.quiver(x_matrix[::s, ::s], y_matrix[::s, ::s], velocity_x[0, ::s, ::s],
           velocity_y[0, ::s, ::s])

plt.show()
datafile_write.close()
Exemple #6
0
            swirlingw = swirling[xCenter - dist:xCenter + dist, yCenter -
                                 dist:yCenter + dist]  #reuse window function?
            if (xCenter > dist) and (yCenter > dist):
                print('x1:', xCenter, 'x2:', yCenter, 'swirl:', peaks[2][i])
                plot.plot_quiver(X, Y, Uw, Vw, swirlingw)
    elif args.plot_x == 'quiver':
        for i in range(len(vortices)):
            swirlingw = swirling[vortices[i][0] -
                                 vortices[i][5]:vortices[i][0] +
                                 vortices[i][5], vortices[i][1] -
                                 vortices[i][5]:vortices[i][1] +
                                 vortices[i][5]]
            X, Y, Uw, Vw = tools.window(a, vortices[i][0], vortices[i][1],
                                        vortices[i][5])
            uMod, vMod = fitting.velocity_model(vortices[i][3], vortices[i][2],
                                                vortices[i][6], vortices[i][7],
                                                vortices[i][8], vortices[i][9],
                                                X, Y)
            plot.plot_quiver(X, Y, Uw, Vw, swirlingw)

    elif args.plot_x == 'fit':
        for i in range(len(vortices)):
            print('xC:', vortices[i][0], 'yC:', vortices[i][1], 'vort:',
                  vortices[i][2], 'mesh', vortices[i][5], 'corr',
                  vortices[i][4], 'coreR', vortices[i][3])
            X, Y, Uw, Vw = tools.window(a, vortices[i][0], vortices[i][1],
                                        vortices[i][5])
            uMod, vMod = fitting.velocity_model(vortices[i][3], vortices[i][2],
                                                vortices[i][6], vortices[i][7],
                                                vortices[i][8], vortices[i][9],
                                                X, Y)
            corr = fitting.correlation_coef(Uw, Vw, uMod, vMod)
Exemple #7
0
# grid
x = np.linspace(0, ndim, ndim)
y = np.linspace(0, ndim, ndim)

#dist = 40
#X = np.linspace(-1,1,dist)
#Y = np.linspace(-1,1,dist)
xx, yy = np.meshgrid(x, y)
coreR = 1.0
gamma = 50
fxCenter = 64
fyCenter = 192
u_conv = 0.0
v_conv = 0.0
Uw, Vw = fitting.velocity_model(coreR, gamma, fxCenter, fyCenter, u_conv,
                                v_conv, xx, yy)
Uw = Uw + u_conv
Vw = Vw + v_conv
#xCenter = 200 #where to move the vortex
#yCenter = 100
#print(Uw)
#print(Vw)
#for i in range(dist):
#    for j in range(dist):
#        velocity_x[0,i+xCenter,j+yCenter] = Uw[i,j]
#        velocity_y[0,i+xCenter,j+yCenter] = Vw[i,j]
#x = np.linspace(0,ndim,ndim)
#y = np.linspace(0,ndim,ndim)
#xx, yy = np.meshgrid(x,y)
#velx = velocity_x[0]
#vely = velocity_y[0]
# grid
x = np.linspace(0, ndim, ndim)
y = np.linspace(0, ndim, ndim)

#dist = 40
#x_index = np.linspace(-1,1,dist)
#y_index = np.linspace(-1,1,dist)
xx, yy = np.meshgrid(x, y)
coreR = 5.0
gamma = 30
x_real = 64
y_real = 192
u_conv = 0.0
v_conv = 0.3
u_data, v_data = fitting.velocity_model(coreR, gamma, x_real, y_real, u_conv,
                                        v_conv, xx, yy)
u_data = u_data + u_conv
v_data = v_data + v_conv
#x_center_index = 200 #where to move the vortex
#y_center_index = 100
#print(u_data)
#print(v_data)
#for i in range(dist):
#    for j in range(dist):
#        velocity_x[0,i+x_center_index,j+y_center_index] = u_data[i,j]
#        velocity_y[0,i+x_center_index,j+y_center_index] = v_data[i,j]
#x = np.linspace(0,ndim,ndim)
#y = np.linspace(0,ndim,ndim)
#xx, yy = np.meshgrid(x,y)
#velx = velocity_x[0]
#vely = velocity_y[0]