import scipy.io from numpy import * #script writing coordinates and velocity files. Output units are metres/second for velocity and centimetres for distance Data=scipy.io.loadmat("Diffuser_1_data.mat") Xold=Data['x'] Yold=Data['y'] Zold=Data['z'] Uold=Data['vx'] Vold=Data['vy'] Wold=Data['vz'] # X=zeros((256,61,60)) Y=zeros((256,61,60)) Z=zeros((256,61,60)) U=zeros((256,61,60)) V=zeros((256,61,60)) W=zeros((256,61,60)) for i in range(0,256): for j in range(0,61): for k in range(0,60): X[i][j][k]=Xold[j][256-1-i][k]*100.0 Y[i][j][k]=Yold[j][256-1-i][k]*100.0 Z[i][j][k]=Zold[j][256-1-i][k]*100.0 U[i][j][k]=Uold[j][256-1-i][k]*100.0 V[i][j][k]=Vold[j][256-1-i][k]*100.0 W[i][j][k]=Wold[j][256-1-i][k]*100.0 Xlist=range(0,257) Ylist=range(0,62) Zlist=range(0,61) Xlist[0]=X[0][0][0]-(X[1][0][0]-X[0][0][0])/2.0 Xlist[256]=X[255][0][0]+(X[255][0][0]-X[254][0][0])/2.0 for i in range(1,256): Xlist[i]=(X[i-1][0][0]+X[i][0][0])/2.0 Ylist[0]=Y[0][0][0]-(Y[0][1][0]-Y[0][0][0])/2.0 Ylist[61]=Y[0][60][0]+(Y[0][60][0]-Y[0][59][0])/2.0 for j in range(1,61): Ylist[j]=(Y[0][j-1][0]+Y[0][j][0])/2.0 Zlist[0]=Z[0][0][0]-(Z[0][0][1]-Z[0][0][0])/2.0 Zlist[60]=Z[0][0][59]+(Z[0][0][59]-Z[0][0][58]) for k in range(1,60): Zlist[k]=(Z[0][0][k-1]+Z[0][0][k])/2.0 file = open('X.dat', 'w') for i in range(0,257): file.write("%f \n" %(Xlist[i])) file.close() file = open('Y.dat', 'w') for i in range(0,62): file.write("%f \n" %(Ylist[i])) file.close() file = open('Z.dat', 'w') for i in range(0,61): file.write("%f \n" %(Zlist[i])) file.close() file_U = open('U_exp.dat','w') file_V = open('V_exp.dat','w') file_W = open('W_exp.dat','w') for k in range(0,60): for j in range(0,61): for i in range(0,256): value=U[i][j][k]/100.0 if(value==0): value=-999.0 file_U.write("%f \n" %(value)) value=V[i][j][k]/100.0 if(value==0): value=-999.0 file_V.write("%f \n" %(value)) value=W[i][j][k]/100.0 if(value==0): value=-999.0 file_W.write("%f \n" %(value)) file_U.close() file_V.close() file_W.close()