geophysics / mtpy

collection of python tools for standard MT data processing
GNU General Public License v3.0
32 stars 32 forks source link

Numpy -> VTK conversion #7

Open geophysics opened 11 years ago

geophysics commented 11 years ago

Stephan mentioned, there is some conversion from Numpy into VTK for the paraview visualisation around? Is it the wsmt_pv (thus specifically for th ws output)?

A generalised version would be a good thing to have in 'utils'. I start trying to browse through it today and see, if I get an idea.

kujaku11 commented 11 years ago

Yes this is a wrapper to get the output of the WS3DINV into something useable for visualization which turns out to be Paraview. There is a module called evtk that is another wrapper from numpy arrays into vtk formats. I have only got this package to compile properly under linux, it compiles under windows but has a bug in making 3D points. But it is very handy. I'm sure with more work we wouldn't need the evtk module just the vtk library which is pretty standard library in Python. In the mean time, it should be left as a stand alone file until we can find an easy way to incoorporate into WS3DTools with relative ease removing the dependence on evtk package. Again the only problem is the evtk package that is not standard.

geophysics commented 11 years ago

Ok, worked with PyVTK today. It's a small extra package, and I am not sure, if contained in standard distributions. However, it's far simpler than the original vtk module and it seems to work ok, even for non-regular (rectilinear though) grids:

def f(x,y,z): return x_y_z

from numpy import from pyvtk import

vtk_object = VtkData(RectilinearGrid(arange(30)/2.-10,sin(pi_arange(40)/39.)_40,arange(60))) vtk_object.point_data.append(vtk_object.structure.Scalars(f,'x_y_z')) vtk_object.tofile('example2f_rg')

I could read and visualise this file with paraview without problems.

I check out 'UnstructuredGrid' tomorrow