Thursday, March 25, 2010

plotting numpy data with mayavi

just getting started trying to use mlab in mayavi to visualize unstructured 3d data in numpy arrays. found some links from this examples page:
scipy cookbook has an example of structured data (one of the last examples on the page). most of the non-mlab mayavi examples use data loaded from a file, so unstructured numpy examples are a little harder to find. here is (i think) an updated version for mayavi2. also, here is an example of how to pick a point on a surface with the mouse, which should come in handy at some point.
also, i could use the auto script generator to help me figure out which functions and object i need to use.
also, make sure to use -wthread with ipython, and this from the docs:

You can also use show() to decorate a function, and have it run in the event-loop, which gives you more flexibility:

from enthought.mayavi 
import mlab 
from numpy import random  
@mlab.show 
def image(): 
   mlab.imshow(random.random((10, 10))) 

With this decorator, each time the image function is called, mlab makes sure an interactive environment is running before executing the image function. If an interactive environment is not running, mlab will start one and the image function will not return until it is closed.

No comments: