Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Createmesh grid with a spacing of 0.5 x 0.5
- stepx = 0.5
- stepy = 0.5
- xx = np.arange(min(x), max(x), stepx)
- yy = np.arange(min(y), max(y), stepy)
- xgrid, ygrid = np.meshgrid(xx, yy)
- grid_z1 = interpolate.griddata((x,y), Arrival_Time, (xgrid, ygrid), method='linear') #Interpolating the Time values
- #Formatdata
- X = np.ravel(xgrid)
- Y= np.ravel(ygrid)
- zs = np.ravel(grid_z1)
- Z = zs.reshape(X.shape)
- #Calculate Gradient
- (dy,dx) = np.gradient(grid_z1) #Find gradient for points on meshgrid
- Velocity_dx= dx/stepx #velocity ms/m
- Velocity_dy= dy/stepx #velocity ms/m
- Resultant = (Velocity_dx**2 + Velocity_dy**2)**0.5 #Resultant scalar value ms/m
- average_BR = np.nanmean(Resultant)
- Min_BR = np.nanmin(Resultant)
- Max_BR = np.nanmax(Resultant)
- Median_BR =np.nanmedian(Resultant)
- Resultant = np.ravel(Resultant)
- #Integrate to compare the original data input
- dxintegral = np.nancumsum(Velocity_dx, axis=1)*stepx
- dyintegral = np.nancumsum(Velocity_dy, axis=0)*stepy
- valintegral = np.ma.zeros(dxintegral.shape) #Makes an array filled with 0's the same shape as dx integral
- for i in range(len(yy)):
- for j in range(len(xx)):
- valintegral[i, j] = np.ma.sum([dxintegral[0, len(xx) // 2], dyintegral[i, len(xx) // 2], dxintegral[i, j], - dxintegral[i, len(xx) // 2]])
- valintegral[np.isnan(dx)] = np.nan
- min_value = np.nanmin(valintegral)
- valintegral=valintegral+(min_value*-1)
- ## convert your array into a dataframe
- print(valintegral)
- fig = pyplot.figure()
- ax = fig.add_subplot()
- ax.scatter(x,y,color='black',s=7,zorder=3)
- ax.set_xlabel('X-Coordinates')
- ax.set_ylabel('Y-Coordinates')
- ax.contour(xgrid, ygrid, valintegral,levels=100,colors='red',zorder=2)
- ax.contour(xgrid,ygrid, grid_z1 ,levels=100,colors='blue',zorder=1)
- ax.set_aspect('equal')
- pyplot.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement