[SciPy-user] Post-Processing 3D Array
Bryan Cole
bryan@cole.uklinux....
Sat Mar 24 15:49:04 CDT 2007
> I am currently running a code to solve Navier-Stokes equations in a
> cylinder. The equations are solved in cylindrical coordinates
> (theta,r,z). The output is fundamentally made up of several 3D arrays
> containing e.g. the axial component of the velocity in space v_z[i,j,k]
> and so on.
> I am using Python to post-process the data, but there are a few problems
> I do not know how to tackle.
> (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.
HTH
BC
>
> Kind Regards
>
> Lorenzo
More information about the SciPy-user
mailing list