from evtk.hl import gridToVTK
# make sure you have installed this module (as shown above)
# chop off shallow data (optional)
mindepth = 1200
votes = votes[votes[:,2] >= mindepth]
nz = np.unique(votes[:,2]).size
# reshape data
lons = np.reshape(votes[:,0],[181,361,nz],order='F')
lats = np.reshape(votes[:,1],[181,361,nz],order='F')
deps = np.reshape(votes[:,2],[181,361,nz],order='F')
slow = np.asfortranarray(np.reshape(votes[:,3],[181,361,nz],order='F'))
neut = np.asfortranarray(np.reshape(votes[:,4],[181,361,nz],order='F'))
fast = np.asfortranarray(np.reshape(votes[:,5],[181,361,nz],order='F'))
# vals = np.asfortranarray(np.reshape(votes[:,6],[181,361,nz],order='F'))
def sph2cart(lat,lon,r):
lat = np.deg2rad(lat)
lon = np.deg2rad(lon)
z = r * np.sin(lat)
y = r * np.cos(lat) * np.sin(lon)
x = r * np.cos(lat) * np.cos(lon)
return x,y,z
x,y,z = sph2cart(lats,lons,(6371.-deps)/6371.)
# this will output a ".vts" file that can be viewed in paraview
gridToVTK('votes',x,y,z,pointData = {"slow": slow,"neutral": neut, "fast":fast})