Advertisement
Guest User

Untitled

a guest
Aug 16th, 2020
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. #Createmesh grid with a spacing of 0.5 x 0.5
  2. stepx = 0.5
  3. stepy = 0.5
  4. xx = np.arange(min(x), max(x), stepx)
  5. yy = np.arange(min(y), max(y), stepy)
  6. xgrid, ygrid = np.meshgrid(xx, yy)
  7. grid_z1 = interpolate.griddata((x,y), Arrival_Time, (xgrid, ygrid), method='linear') #Interpolating the Time values
  8.  
  9. #Formatdata
  10. X = np.ravel(xgrid)
  11. Y= np.ravel(ygrid)
  12. zs = np.ravel(grid_z1)
  13. Z = zs.reshape(X.shape)
  14.  
  15. #Calculate Gradient
  16. (dy,dx) = np.gradient(grid_z1) #Find gradient for points on meshgrid
  17.  
  18. Velocity_dx= dx/stepx #velocity ms/m
  19. Velocity_dy= dy/stepx #velocity ms/m
  20.  
  21. Resultant = (Velocity_dx**2 + Velocity_dy**2)**0.5 #Resultant scalar value ms/m
  22.  
  23. average_BR = np.nanmean(Resultant)
  24. Min_BR = np.nanmin(Resultant)
  25. Max_BR = np.nanmax(Resultant)
  26. Median_BR =np.nanmedian(Resultant)
  27. Resultant = np.ravel(Resultant)
  28.  
  29.  
  30. #Integrate to compare the original data input
  31. dxintegral = np.nancumsum(Velocity_dx, axis=1)*stepx
  32. dyintegral = np.nancumsum(Velocity_dy, axis=0)*stepy
  33.  
  34. valintegral = np.ma.zeros(dxintegral.shape) #Makes an array filled with 0's the same shape as dx integral
  35. for i in range(len(yy)):
  36. for j in range(len(xx)):
  37. valintegral[i, j] = np.ma.sum([dxintegral[0, len(xx) // 2], dyintegral[i, len(xx) // 2], dxintegral[i, j], - dxintegral[i, len(xx) // 2]])
  38. valintegral[np.isnan(dx)] = np.nan
  39. min_value = np.nanmin(valintegral)
  40.  
  41.  
  42. valintegral=valintegral+(min_value*-1)
  43.  
  44. ## convert your array into a dataframe
  45.  
  46. print(valintegral)
  47. fig = pyplot.figure()
  48. ax = fig.add_subplot()
  49. ax.scatter(x,y,color='black',s=7,zorder=3)
  50. ax.set_xlabel('X-Coordinates')
  51. ax.set_ylabel('Y-Coordinates')
  52. ax.contour(xgrid, ygrid, valintegral,levels=100,colors='red',zorder=2)
  53. ax.contour(xgrid,ygrid, grid_z1 ,levels=100,colors='blue',zorder=1)
  54. ax.set_aspect('equal')
  55.  
  56. pyplot.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement