Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numpy -> VTK conversion #7

Open
geophysics opened this issue Oct 10, 2012 · 2 comments
Open

Numpy -> VTK conversion #7

geophysics opened this issue Oct 10, 2012 · 2 comments

Comments

@geophysics
Copy link
Owner

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
Copy link
Collaborator

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
Copy link
Owner Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants