Hi,

On Friday 04 March 2011 12:34 AM, BaiLong wrote:
I just started using Mayavi today and I'm amazed by it's possibilities!

Thank you for the kind compliments.

I have a little problem I can't figure out how to attack.

I want to draw spherical harmonics on spheres and I managed to get the right
shapes without a problem. But now I try to color them in the common way. Taht is
one color for positive values and another for negative.

Is there a way to change the LUT or just manipulate the color whenever it is
below 0? All my attempts to create my own LUT like in
http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/auto/example_custom_colormap.html
failed. Is there a more advanced tutorial?

And does someone know how the LUT exactly applies? How does the mesh know at
which shading point it has to look in which color array?

OK, this can be a little difficult but one way to solve your problem is to use the Threshold filter. Load up your data and then use a threshold and limit it. I've cooked up a simple script to demonstrate this and attach it below.

cheers,
Prabhu

import numpy
from enthought.mayavi import mlab
from enthought.mayavi.tools import sources
P = mlab.pipeline

pi = numpy.pi
cos = numpy.cos
sin = numpy.sin
dphi, dtheta = pi/250.0, pi/250.0
[phi,theta] = numpy.mgrid[0:pi+dphi*1.5:dphi,0:2*pi+dtheta*1.5:dtheta]
m0 = 4; m1 = 3; m2 = 2; m3 = 3; m4 = 6; m5 = 2; m6 = 6; m7 = 4;
r = sin(m0*phi)**m1 + cos(m2*phi)**m3 + sin(m4*theta)**m5 + cos(m6*theta)**m7
x = r*sin(phi)*cos(theta)
y = r*cos(phi)
z = r*sin(phi)*sin(theta);

src = sources.grid_source(x, y, z)
t1 = P.threshold(src)
t1.lower_threshold = 0.0
s1 = P.surface(t1)
t2 = P.threshold(src)
t2.upper_threshold = 0.0
s2 = P.surface(t2)

mlab.show()
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
MayaVi-users mailing list
MayaVi-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mayavi-users

Reply via email to