[SciPy-user] Post-Processing 3D Array

Gael Varoquaux gael.varoquaux@normalesup....
Sun Mar 25 07:33:31 CDT 2007


On Sat, Mar 24, 2007 at 08:49:04PM +0000, Bryan Cole wrote:
> > (1) It would be very nice to be able to cut several cross-sections of 
> > the tube along which I'd like to plot v_z. I can easily obtain the 2D 
> > array v_z_cross[i,j], function of theta and r only, but then I am not 
> > sure about how to plot it in 2D. Also, the geometry of the resulting 
> > plot has to look like a circle and absolutely not a square.
> > (2)Would it also be possible to make a full 3D plot of v_z[i,j,k]? As in 
> > (1), the geometry of the resulting plot has to look like a cylinder and 
> > not a cube or a square duct.

> Sounds like a job for VTK (www.vtk.org). In VTK-speak, your dataset is
> best represented as a "structured grid". This means your data points can
> be indexed as i,j,k (i.e. a grid), but it's not a Cartesian grid, so the
> 3D location of each data point must be specified directly. At each data
> point, you can have an arbitrary number of scalar, vector or tensor
> attributes.

> I would say the easiest way to start is to write out your data as a VTK
> format file (this can be ASCII or binary) with format description given
> in http://www.vtk.org/pdf/file-formats.pdf , then load this up in either
> MayaVi (http://mayavi.sourceforge.net/) or Paraview
> (http://www.paraview.org/HTML/Index.html). 

> There is a python module for writing VTK files called pyvtk
> (http://cens.ioc.ee/projects/pyvtk/ ) which may simplify the task
> further.

Indeed I would say that vtk is very suited for this task. Tvtk and
mayavi2 are python wrapper for vtk that are very pythonic and nice for
interactiv work. I am currently working on a module to drive mayavi2 from
"ipython -wthread" for scripting and interactive work. It still needs
some work before I can even submit it for inclusion to mayavi2 but I am
sending it along just in case in can be of some use. It can be of much
help as it deals with the building of the vtk data objects from numpy
arrays for most cases.

Tvtk and mayavi2 are part of the enthought tools suite, if you want to
use the attached module you will have to use the svn:
https://svn.enthought.com/enthought/wiki/GrabbingAndBuilding

For more info on mayavi2 and tvtk see the scipy wiki at
http://www.scipy.org (I cannot provide a direct link to the proper page,
as the wiki is down right now).

HTH

Gaël



More information about the SciPy-user mailing list