[Tutor] problem in plotting circular plates at regular separation

Debashish Saha silideba at gmail.com
Tue Feb 14 14:56:26 CET 2012


from __future__ import division
import numpy
from enthought.mayavi import mlab
for r in range (1,5):
    print r

    pi = numpy.pi
    cos = numpy.cos
    sin = numpy.sin
    dphi, dtheta, dz = pi/250.0, pi/250.0, 0.01
    [s,theta]=numpy.mgrid[0.01:r+0.015:.01,0:2*pi+dtheta*1.5:dtheta]
    x=s*cos(theta)
    y=s*sin(theta)
    z=r
    mlab.mesh(x, y,z, colormap='Greens')

error:

AssertionError                            Traceback (most recent call last)
C:\Users\as\<ipython-input-81-1360d2653557> in <module>()
     13     y=s*sin(theta)
     14     z=r
---> 15     mlab.mesh(x, y,z, colormap='Greens')

C:\Python27\lib\site-packages\mayavi\tools\helper_functions.pyc in
the_function(*args, **kwargs)
     32 def document_pipeline(pipeline):
     33     def the_function(*args, **kwargs):
---> 34         return pipeline(*args, **kwargs)
     35
     36     if hasattr(pipeline, 'doc'):

C:\Python27\lib\site-packages\mayavi\tools\helper_functions.pyc in
__call__(self, *args, **kwargs)
     77             scene.disable_render = True
     78         # Then call the real logic

---> 79         output = self.__call_internal__(*args, **kwargs)
     80         # And re-enable the rendering, if needed.

     81         if scene is not None:

C:\Python27\lib\site-packages\mayavi\tools\helper_functions.pyc in
__call_internal__(self, *args, **kwargs)
    830         filters.
    831         """
--> 832         self.source = self._source_function(*args, **kwargs)
    833         kwargs.pop('name', None)
    834         self.store_kwargs(kwargs)

C:\Python27\lib\site-packages\mayavi\tools\sources.pyc in
grid_source(x, y, z, **kwargs)
   1259     x, y, z, scalars = convert_to_arrays((x, y, z, scalars))
   1260     data_source = MGridSource()
-> 1261     data_source.reset(x=x, y=y, z=z, scalars=scalars)
   1262
   1263     name = kwargs.pop('name', 'GridSource')

C:\Python27\lib\site-packages\mayavi\tools\sources.pyc in reset(self, **traits)
    689         assert len(x.shape) == 2, "Array x must be 2 dimensional."
    690         assert len(y.shape) == 2, "Array y must be 2 dimensional."
--> 691         assert len(z.shape) == 2, "Array z must be 2 dimensional."
    692         assert x.shape == y.shape, "Arrays x and y must have
same shape."
    693         assert y.shape == z.shape, "Arrays y and z must have
same shape."

AssertionError: Array z must be 2 dimensional.


More information about the Tutor mailing list