Xlist = np.arange(0.0,lon+xstep,xstep)# x co-ordinates of the desired array shape Ylist = np.arange(0.0,lat+ystep,ystep)# y co-ordinates of the desired array shape Zlist = np.arange(0.0,depth_ml+zstep,zstep)# y co-ordinates of the desired array shape [X,Y,Z] = myfun.meshgrid2(Xlist,Ylist,Zlist) Y = np.reshape(Y,(np.size(Y),)) X = np.reshape(X,(np.size(X),)) Z = np.reshape(Z,(np.size(Z),)) par = np.zeros((pt,3,tt)) time = det['ElapsedTime']['value'] # read particles for d in range(pt): temp = det['Particles_'+myfun.digit(d+1,6)]['position'] par[d,:,:] = temp[:,0:tt] #fsle param di = 0.5 # base separation distance [m]. Taken as the distance between the particles in the triplet. # read ML depth from file Tref = [0.2,0.3] mld = [] for i in range(len(Tref)): Data = pyvtk.VtkData('/nethome/jmensa/scripts_fluidity/2D/ML/output/'+exp+'/ML_'+myfun.digit(Tref[i],3)+'_'+exp+'_'+day+'.vtk') mld.append(np.reshape(Data.point_data.data[0].scalars,[len(Ylist),len(Xlist)])) # read T from archive
for z in range(0,len(Zlist),2): print 'depth', z par2Dz = par[z::6,:,:] # for t in range(1,tt,5): print 'time', time[t]/3600.0 fig = plt.figure(figsize=(10,7)) ax = fig.add_subplot(111, projection='3d') # s2D = ax.scatter(par2Dz[:,0,t]/1000.0, par2Dz[:,1,t]/1000.0, par2Dz[:,2,t]-Zlist[z], c = par2Dz[:,2,t], s = 35, marker='.', lw = 0) # print 'Saving 2D to eps' # ax.text(-120, -120, 90, str(Zlist[z])+'m', fontsize=16) ax.text(-120, -120, 80, str(np.round((time[t]/86400 - time[0]/86400)*10)/10.0)+'day', fontsize=16) # ax.set_xlabel('X [km]',fontsize=18) ax.set_ylabel('Y [km]',fontsize=18) ax.set_zlabel(r'$\Delta$Z [m]',fontsize=18) ax.tick_params(axis='x', labelsize=14) ax.tick_params(axis='y', labelsize=14) ax.tick_params(axis='z', labelsize=14) ax.set_xlim([-120,120]) ax.set_ylim([-120,120]) ax.set_zlim([-50,50]) plt.savefig('./plot/'+exp+'/traj_3d_'+exp+'_'+str(Zlist[z])+'_'+myfun.digit(str(int(time[t]/3600)),4)+'.eps') print './plot/'+exp+'/traj_3d_'+exp+'_'+str(Zlist[z])+'_'+myfun.digit(str(int(time[t]/3600)),4)+'.eps' plt.close()
tt = 267 #tt = 120 if len(time2D) < len(time3D): time = time2D[:tt] else: time = time3D[:tt] print 'particles:',pt print 'timesteps:',tt par3D = np.zeros((pt,3,tt)) par2D = np.zeros((pt,3,tt)) for d in xrange(pt): temp3D = det3D['particles_'+myfun.digit(d+1,len(str(pt)))]['position'] par3D[d,:,:] = temp3D[:,:tt] temp2D = det2D['particles_'+myfun.digit(d+1,len(str(pt)))]['position'] par2D[d,:,:] = temp2D[:,:tt] # horizontal depth = 11 #11 pd = range(1,depth,3) nl = len(pd) A_3D = np.zeros((tt,nl)) A_2D = np.zeros((tt,nl)) D_3D = np.zeros((tt,nl)) D_2D = np.zeros((tt,nl))
tt = 1200 pt = 5896 step = 1 z = range(-10,-890,-10) x = range(-100000,100000,3000) y = 0.0 par = np.zeros((pt,3,tt)) time = range(1800,1800*(tt+1),1800) # read particles for d in range(pt): temp = det['particles_'+myfun.digit(d+1,4)]['position'] par[d,:,:] = temp[:,0:tt] #fsle param di = 10 # base separation distance [m]. Taken as the distance between the particles in the triplet. # read T from archive for r in np.linspace(1,3): #print 'plotting for dr:',r*di fsle = np.zeros(pt)*np.nan df = 11.0 #r*di # separation distance # # loop triplets in time # #
# print "fields: ", data.GetFieldNames() # Ts = np.reshape(data.ProbeData(vtktools.arr(zip(X, Y, Z)), "Temperature"), [len(Zlist), len(Ylist), len(Xlist)]) triangles = myfun.pts2trs(len(Xlist), len(Ylist)) # # for t in range(len(Tref)): points = np.zeros([len(Ylist) * len(Xlist), 3]) mld = np.zeros(len(Ylist) * len(Xlist)) id = 0 # for j in xrange(len(Ylist)): for i in xrange(len(Xlist)): for k in xrange(len(Zlist)): if Ts[k, j, i] - Ts[0, j, i] <= -Tref[t]: points[id, :] = Xlist[i], Ylist[j], Zlist[k] mld[id] = Zlist[k] id = id + 1 break vtk = pyvtk.VtkData( pyvtk.UnstructuredGrid(points, triangle=triangles), pyvtk.PointData(pyvtk.Scalars(mld, "MLD")), "Unstructured Grid Example", ) print "./output/" + label + "/ML_" + myfun.digit(Tref[t], 3) + "_" + file1 vtk.tofile("./output/" + label + "/ML_" + myfun.digit(Tref[t], 3) + "_" + file1) del data
# e1.set_facecolor('none') # e1.set_edgecolor('k') # e1.set_linewidth(2.5) # e1.set_linestyle('dashed') # # ax.text(0, 3.5, str(z0[z])+'m, '+str(time0[t]/3600)+'h', fontsize=18) plt.xlabel('X [$km$]', fontsize=18) plt.ylabel('Y [$km$]', fontsize=18) plt.xticks(fontsize=16) plt.yticks(fontsize=16) # plt.xlim([-1 , 9]) # plt.ylim([-1 , 9]) plt.xlim([-5 , 13]) plt.ylim([-5 , 13]) plt.savefig('./plot/'+exp+'/traj_'+exp+'_z'+str(z0[z])+'_'+myfun.digit(int(time0[t]),10)+'_h.eps') print './plot/'+exp+'/traj_'+exp+'_z'+str(z0[z])+'_'+myfun.digit(int(time0[t]),10)+'_h.eps' plt.close() # plot ellipse # vertical fig = plt.figure(figsize=(8,8)) plt.plot((3.5,3.5),(0,-50),'k',linewidth=2) plt.plot((4.5,4.5),(0,-50),'k',linewidth=2) #plt.plot((3,3),(0,-50),'k') #plt.plot((4,4),(0,-50),'k') # s2D = plt.scatter(par2Dz[:,0,t]/1000, par2Dz[:,2,t], marker='.', s=35, facecolor='b', lw = 0)
pt = int(os.popen('grep position '+filename+'| wc -l').read()) # read the number of particles grepping all the positions in the file print 'particles:',pt print 'timesteps:',tt print 'step:',step # read particles par = np.zeros((pt,3,tt)) time = det['ElapsedTime']['value'] # read particles for d in range(pt): temp = det['particles_'+myfun.digit(d+1,len(str(pt)))]['position'] par[d,:,:] = temp[:,0:tt] # line takes only two points at the time. it has to be defined for each segment if flag == 0: # build points coord # for st in range(tt): # build points coord points = [] lines = [] l = 0 # for d in range(0,pt-step,step): for i in [0,4]:
tt = 120 if len(time2D) < len(time3D): time = time2D[:tt] else: time = time3D[:tt] print "particles:", pt print "timesteps:", tt par3D = np.zeros((pt, 3, tt)) par2D = np.zeros((pt, 3, tt)) for d in xrange(pt): temp3D = det3D["particles_" + myfun.digit(d + 1, len(str(pt)))]["position"] par3D[d, :, :] = temp3D[:, :tt] temp2D = det2D["particles_" + myfun.digit(d + 1, len(str(pt)))]["position"] par2D[d, :, :] = temp2D[:, :tt] # horizontal nl = 10 for z in range(nl): print z A_3D = np.zeros((tt, nl)) A_2D = np.zeros((tt, nl)) D_3D = np.zeros((tt, nl)) D_2D = np.zeros((tt, nl)) Cd_3D = np.zeros((tt, nl)) Cd_2D = np.zeros((tt, nl))