[SciPy-user] surface plotting

Lorenzo Isella lorenzo.isella@gmail....
Mon Dec 3 14:43:21 CST 2007


Hello,
> Sure. Tell us a bit more about your usecase. Do you want to produce
> figures for print/publication, do you want to interact with your data, or
> do you want simply to do some 3D plotting in a program of yours. You can
> do all this with Mayavi, but the solutions will depend a bit of your usecase.
>
>   
Well, seen that you ask, I often run thermo-hydraulic simulations.
I usually end up having a set of numerical values to plot on a 
non-trivial domain rather than an analytical function.
This can sometimes be done using a contour plot in matplotlib, but I am 
also looking for alternatives.
For instance, let us say that I want to plot some scalar (say a 
component of the velocity) on the cross section of a tube (I simply 
generate random numbers here; in reality I would read it from a file).
With pylab, this is what I would do:

#! /usr/bin/env python
from scipy import *
import pylab
import numpy


nt=20
nr=20




r=linspace(0.,10.,nr)


theta=linspace(0.,2.*pi,nt)
#print "theta is ", theta
sin_t=sin(theta)
cos_t=cos(theta)
rsin_t=r[newaxis,:]*sin_t[:,newaxis]
rcos_t=r[newaxis,:]*cos_t[:,newaxis]
rsin_t=ravel(rsin_t)
rcos_t=ravel(rcos_t)

rsin_t.shape=(nt,nr)
rcos_t.shape=(nt,nr)

vel_section=numpy.random.normal(0.,5.,(nr*nt))

vel_section=reshape(vel_section,(nt,nr))
print 'OK up to here'

#pylab.colorbar()
#pylab.clf()
pylab.figure()
X = rsin_t.transpose()
Y = rcos_t.transpose()
Z = vel_section.transpose()
velmin = vel_section.min()
velmax = vel_section.max()
print velmin, velmax
levels = arange(velmin, velmax+0.01, 0.1)
pylab.contourf(X, Y, Z, levels, cmap=pylab.cm.jet)
pylab.colorbar()

#pylab.show()

pylab.savefig("velocity_on_section_DNS")
#pylab.hold(False)

Can I do something similar with mayavi? And how?


> /usr/lib/python2.4/site-packages/scipy/misc/__init__.py:25: 
> > DeprecationWarning: ScipyTest is now called NumpyTest; please update 
> > your code
>> My main interest is point (1), i.e. to be sure that my python
>> installation is still OK (and know what to do in case it is not). 
>>     
>
> I think it is OK. What happened is that scipy got updated, and these are
> just harmless, albeit annoying, warnings.
>
>   
Here I am a bit puzzled. True, SciPy 0.6.x has recently been released, 
but on my box (Debian testing) I am still running 0.5.2 and I do not 
recall it having been updated recently...or have I missed it?

Many thanks and good luck with the defense of your PhD thesis.

Lorenzo


More information about the SciPy-user mailing list