SlideShare a Scribd company logo
3D visualisation  with Mayavi March 19, 2010
What is Mayavi ? Mayavi is a general purpose, cross-platform tool for 3-D scientific data visualization Visualization of scalar, vector and tensor data in 2 and 3 dimensions. Easy scriptability using Python. Easy extendability via custom sources, modules, and data filters. Reading several file formats: VTK, PLOT3D, etc. Saving of visualizations. Saving rendered visualization in a variety of image formats. Convenient functionality for rapid scientific plotting via mlab A very example of what you can build on top of ETS
Enthought Tool Suite
Mayavi user interface
Mayavi user interface DataSource, Filter and Modules Recording Shell plugin and scripting
Mayavi user interface DataSource, Filter and Modules Recording Shell plugin and scripting
Mayavi user interface DataSource, Filter and Modules Recording Shell plugin and scripting
Mayavi “API” or scripting with mlab # Create the data. from numpy import pi, sin, cos, mgrid dphi, dtheta = pi/250.0, pi/250.0 [phi,theta] = 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) # View it. from enthought.mayavi import mlab s = mlab.mesh(x, y, z) mlab.show()
Running mlab within ipython C:\ ipython –wthread >>> from enthought.mayavi import mlab matplotlib  also has an  mlab  namespace.  Be sure you are using the one from  enthought.mayavi
Plotting commands 0D data mlab.points3d(x, y, z) 1D data mlab.plot3d(x, y, z) 3D data mlab.contour3d(x, y, z) Vector field mlab.quiver(x, y, z, u, v, w) 2D data mlab.surf(x, y, z)
Example with points in 3D mlab.points3d(x, y, z, color=(1.0,0.0,1.0), mode=‘sphere’, scale_factor=0.1) { x.shape == y.shape == z.shape color = (R, G, B) 0.0 <= R, G, B <= 1.0 default  is (1.0, 1.0, 1.0) mode =  ‘sphere’ , ‘cone’, ‘cube’, ‘arrow’, ‘cylinder’, ‘point’, ‘2darrow’, ‘2dcircle’, ‘2dcross’, ‘2ddash’, ‘2ddiamond’, ‘2dhooked_arrow’, ‘2dsquare’, ‘2dthick_arrow’, ‘2dthick_cross’, ‘2dtriangle’, ‘2dvertex’ scaling applied from numpy.random import rand x,y,z = rand(30),rand(30),rand(30) mlab.axes()
Mlab decorations mlab.title('A title') mlab.axes() mlab.colorbar() mlab.clf() mlab.figure() mlab.gcf()
Mlab helper functions and the engine pipeline >>> mlab.figure() >>> mlab.surf(call_values) >>> mlab.axes() Array2DSource \__ WarpScalar \__ PolyDataNormals \__ Colors and legends \__ Surface   Array2DSource  \__ WarpScalar  \__ PolyDataNormals  \__ Colors and leg \__ Surface def complete_pipeline_call(data_array): src = mlab.pipeline.array2d_source(data_array) warp = mlab.pipeline.warp_scalar(src) normals = mlab.pipeline.poly_data_normals(warp) return mlab.pipeline.surface(normals)
Looking for help and demo’s mlab.test_points3d() mlab.test_plot3d() mlab.test_surf() mlab.test_contour3d() mlab.test_quiver3d() mlab.test_molecule() mlab.test_flow() mlab.test_mesh() Use ?? in IPython to look at the source code of these examples. Documentation Mayavi examples coming with EPD enthought-dev mailing list  Mlab test functions :
Mlab and Traits (mlab_traits_ui.py) class ActorViewer(HasTraits):  scene = Instance(MlabSceneModel, ())  view = View(Item(name='scene‘,  editor=SceneEditor(scene_class=MayaviScene), show_label=False,  resizable=True,  height=500, width=500),  resizable=True)  def __init__(self, **traits):  HasTraits.__init__(self, **traits)  self.generate_data()  def generate_data(self):  X, Y = mgrid[-2:2:100j, -2:2:100j]  R = 10*sqrt(X**2 + Y**2)  Z = sin(R)/R  self.scene.mlab.surf(X, Y, Z, colormap='gist_earth') if __name__ == '__main__':  a = ActorViewer()  a.configure_traits()
Mlab and Traits (lorenz_ui.py)
Traits, Mayavi and Chaco Vtk_commodities.py (Thanks to Travis Vaught for the example)
EPD http://www.enthought.com/products/epd.php Enthought Training: http://www.enthought.com/training/ Webinars http://www.enthought.com/training/webinars.php

More Related Content

KEY
Numpy Talk at SIAM
PDF
Numpy tutorial(final) 20160303
PDF
Introduction to NumPy for Machine Learning Programmers
PDF
Effective Numerical Computation in NumPy and SciPy
PDF
Intoduction to numpy
PDF
NumPy Refresher
KEY
NumPy/SciPy Statistics
PDF
Scientific Computing with Python - NumPy | WeiYuan
Numpy Talk at SIAM
Numpy tutorial(final) 20160303
Introduction to NumPy for Machine Learning Programmers
Effective Numerical Computation in NumPy and SciPy
Intoduction to numpy
NumPy Refresher
NumPy/SciPy Statistics
Scientific Computing with Python - NumPy | WeiYuan

What's hot (19)

PDF
Introduction to NumPy (PyData SV 2013)
PPTX
Python Scipy Numpy
PPTX
Introduction to numpy Session 1
PDF
Python3 cheatsheet
PDF
Python 2.5 reference card (2009)
PPTX
PDF
Python Cheat Sheet
PDF
Recommendation System --Theory and Practice
PPTX
Introduction to matplotlib
PDF
Python For Data Science Cheat Sheet
PDF
Python matplotlib cheat_sheet
PDF
Cheat sheet python3
PDF
Python seaborn cheat_sheet
PDF
Google TensorFlow Tutorial
PDF
Numpy python cheat_sheet
PDF
Statistical inference for (Python) Data Analysis. An introduction.
PDF
Cheat Sheet for Machine Learning in Python: Scikit-learn
PPTX
Machine Learning - Introduction to Tensorflow
Introduction to NumPy (PyData SV 2013)
Python Scipy Numpy
Introduction to numpy Session 1
Python3 cheatsheet
Python 2.5 reference card (2009)
Python Cheat Sheet
Recommendation System --Theory and Practice
Introduction to matplotlib
Python For Data Science Cheat Sheet
Python matplotlib cheat_sheet
Cheat sheet python3
Python seaborn cheat_sheet
Google TensorFlow Tutorial
Numpy python cheat_sheet
Statistical inference for (Python) Data Analysis. An introduction.
Cheat Sheet for Machine Learning in Python: Scikit-learn
Machine Learning - Introduction to Tensorflow
Ad

Viewers also liked (10)

PDF
3D visualization with VTVK and MayaVi2
PDF
Real-Time 3D Data Visualization and Analysis of Unlimited Detail
PPTX
Measuring Influence: The Value of 3D Data Visualization
PPTX
Top 10 Data Visualization Tools
PDF
Visualization of Big Data in Web Apps
PPTX
By www.fastrackengine.com- Performance Enhancement of Automotive Silencer usi...
PDF
Finite Element Analysis Made Easy Lr
PDF
UI for Big Data Visualization | Jonathan Stray | UX Week 2012
PDF
Workshop: Big Data Visualization for Security
PDF
Big Data Visualization
3D visualization with VTVK and MayaVi2
Real-Time 3D Data Visualization and Analysis of Unlimited Detail
Measuring Influence: The Value of 3D Data Visualization
Top 10 Data Visualization Tools
Visualization of Big Data in Web Apps
By www.fastrackengine.com- Performance Enhancement of Automotive Silencer usi...
Finite Element Analysis Made Easy Lr
UI for Big Data Visualization | Jonathan Stray | UX Week 2012
Workshop: Big Data Visualization for Security
Big Data Visualization
Ad

Similar to Scientific Computing with Python Webinar March 19: 3D Visualization with Mayavi (20)

PDF
Mayavi.pdf
PPT
Computational Methods in Physics for Students
PPTX
K10947 Vikas ct
PDF
Scientific visualization with_gr
PDF
lecture_16_jiajun.pdf
PDF
TAO Fayan_X-Ray and MIP volume rendering
PDF
IAP09 CUDA@MIT 6.963 - Lecture 01: High-Throughput Scientific Computing (Hans...
PDF
Structural Dynamics Toolbox and OpenFEM, a technical overview
PDF
04 - Geometric Modelling para el diseño ...
PDF
Practical Spherical Harmonics Based PRT Methods
ODP
Implementation of “Parma Polyhedron Library”-functions in MATLAB
PPTX
K10765 Matlab 3D Mesh Plots
PDF
A Simple 3D Graphics Engine Written in Python and Allegro
PDF
Standardizing on a single N-dimensional array API for Python
PDF
Modern OpenGL scientific visualization
PPTX
Wrangle 2016: (Lightning Talk) FizzBuzz in TensorFlow
PPT
Intro
PDF
Neural Networks in the Wild: Handwriting Recognition
PDF
Overview of the TriBITS Lifecycle Model
Mayavi.pdf
Computational Methods in Physics for Students
K10947 Vikas ct
Scientific visualization with_gr
lecture_16_jiajun.pdf
TAO Fayan_X-Ray and MIP volume rendering
IAP09 CUDA@MIT 6.963 - Lecture 01: High-Throughput Scientific Computing (Hans...
Structural Dynamics Toolbox and OpenFEM, a technical overview
04 - Geometric Modelling para el diseño ...
Practical Spherical Harmonics Based PRT Methods
Implementation of “Parma Polyhedron Library”-functions in MATLAB
K10765 Matlab 3D Mesh Plots
A Simple 3D Graphics Engine Written in Python and Allegro
Standardizing on a single N-dimensional array API for Python
Modern OpenGL scientific visualization
Wrangle 2016: (Lightning Talk) FizzBuzz in TensorFlow
Intro
Neural Networks in the Wild: Handwriting Recognition
Overview of the TriBITS Lifecycle Model

More from Enthought, Inc. (12)

PDF
Talk at NYC Python Meetup Group
PDF
Scientific Applications with Python
PDF
SciPy 2010 Review
PDF
Chaco Step-by-Step
PDF
February EPD Webinar: How do I...use PiCloud for cloud computing?
PDF
SciPy India 2009
PDF
Parallel Processing with IPython
PDF
Scientific Computing with Python Webinar: Traits
PDF
Scientific Computing with Python Webinar 9/18/2009:Curve Fitting
PPT
Scientific Computing with Python Webinar --- August 28, 2009
PPT
Scientific Computing with Python Webinar --- June 19, 2009
PPT
Scientific Computing with Python Webinar --- May 22, 2009
Talk at NYC Python Meetup Group
Scientific Applications with Python
SciPy 2010 Review
Chaco Step-by-Step
February EPD Webinar: How do I...use PiCloud for cloud computing?
SciPy India 2009
Parallel Processing with IPython
Scientific Computing with Python Webinar: Traits
Scientific Computing with Python Webinar 9/18/2009:Curve Fitting
Scientific Computing with Python Webinar --- August 28, 2009
Scientific Computing with Python Webinar --- June 19, 2009
Scientific Computing with Python Webinar --- May 22, 2009

Recently uploaded (20)

PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
cuic standard and advanced reporting.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Cloud computing and distributed systems.
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
KodekX | Application Modernization Development
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Approach and Philosophy of On baking technology
PDF
Encapsulation theory and applications.pdf
PPT
Teaching material agriculture food technology
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
Unlocking AI with Model Context Protocol (MCP)
cuic standard and advanced reporting.pdf
Review of recent advances in non-invasive hemoglobin estimation
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Chapter 3 Spatial Domain Image Processing.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Cloud computing and distributed systems.
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
KodekX | Application Modernization Development
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Approach and Philosophy of On baking technology
Encapsulation theory and applications.pdf
Teaching material agriculture food technology
20250228 LYD VKU AI Blended-Learning.pptx
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Digital-Transformation-Roadmap-for-Companies.pptx

Scientific Computing with Python Webinar March 19: 3D Visualization with Mayavi

  • 1. 3D visualisation with Mayavi March 19, 2010
  • 2. What is Mayavi ? Mayavi is a general purpose, cross-platform tool for 3-D scientific data visualization Visualization of scalar, vector and tensor data in 2 and 3 dimensions. Easy scriptability using Python. Easy extendability via custom sources, modules, and data filters. Reading several file formats: VTK, PLOT3D, etc. Saving of visualizations. Saving rendered visualization in a variety of image formats. Convenient functionality for rapid scientific plotting via mlab A very example of what you can build on top of ETS
  • 5. Mayavi user interface DataSource, Filter and Modules Recording Shell plugin and scripting
  • 6. Mayavi user interface DataSource, Filter and Modules Recording Shell plugin and scripting
  • 7. Mayavi user interface DataSource, Filter and Modules Recording Shell plugin and scripting
  • 8. Mayavi “API” or scripting with mlab # Create the data. from numpy import pi, sin, cos, mgrid dphi, dtheta = pi/250.0, pi/250.0 [phi,theta] = 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) # View it. from enthought.mayavi import mlab s = mlab.mesh(x, y, z) mlab.show()
  • 9. Running mlab within ipython C:\ ipython –wthread >>> from enthought.mayavi import mlab matplotlib also has an mlab namespace. Be sure you are using the one from enthought.mayavi
  • 10. Plotting commands 0D data mlab.points3d(x, y, z) 1D data mlab.plot3d(x, y, z) 3D data mlab.contour3d(x, y, z) Vector field mlab.quiver(x, y, z, u, v, w) 2D data mlab.surf(x, y, z)
  • 11. Example with points in 3D mlab.points3d(x, y, z, color=(1.0,0.0,1.0), mode=‘sphere’, scale_factor=0.1) { x.shape == y.shape == z.shape color = (R, G, B) 0.0 <= R, G, B <= 1.0 default is (1.0, 1.0, 1.0) mode = ‘sphere’ , ‘cone’, ‘cube’, ‘arrow’, ‘cylinder’, ‘point’, ‘2darrow’, ‘2dcircle’, ‘2dcross’, ‘2ddash’, ‘2ddiamond’, ‘2dhooked_arrow’, ‘2dsquare’, ‘2dthick_arrow’, ‘2dthick_cross’, ‘2dtriangle’, ‘2dvertex’ scaling applied from numpy.random import rand x,y,z = rand(30),rand(30),rand(30) mlab.axes()
  • 12. Mlab decorations mlab.title('A title') mlab.axes() mlab.colorbar() mlab.clf() mlab.figure() mlab.gcf()
  • 13. Mlab helper functions and the engine pipeline >>> mlab.figure() >>> mlab.surf(call_values) >>> mlab.axes() Array2DSource \__ WarpScalar \__ PolyDataNormals \__ Colors and legends \__ Surface Array2DSource \__ WarpScalar \__ PolyDataNormals \__ Colors and leg \__ Surface def complete_pipeline_call(data_array): src = mlab.pipeline.array2d_source(data_array) warp = mlab.pipeline.warp_scalar(src) normals = mlab.pipeline.poly_data_normals(warp) return mlab.pipeline.surface(normals)
  • 14. Looking for help and demo’s mlab.test_points3d() mlab.test_plot3d() mlab.test_surf() mlab.test_contour3d() mlab.test_quiver3d() mlab.test_molecule() mlab.test_flow() mlab.test_mesh() Use ?? in IPython to look at the source code of these examples. Documentation Mayavi examples coming with EPD enthought-dev mailing list Mlab test functions :
  • 15. Mlab and Traits (mlab_traits_ui.py) class ActorViewer(HasTraits): scene = Instance(MlabSceneModel, ()) view = View(Item(name='scene‘, editor=SceneEditor(scene_class=MayaviScene), show_label=False, resizable=True, height=500, width=500), resizable=True) def __init__(self, **traits): HasTraits.__init__(self, **traits) self.generate_data() def generate_data(self): X, Y = mgrid[-2:2:100j, -2:2:100j] R = 10*sqrt(X**2 + Y**2) Z = sin(R)/R self.scene.mlab.surf(X, Y, Z, colormap='gist_earth') if __name__ == '__main__': a = ActorViewer() a.configure_traits()
  • 16. Mlab and Traits (lorenz_ui.py)
  • 17. Traits, Mayavi and Chaco Vtk_commodities.py (Thanks to Travis Vaught for the example)
  • 18. EPD http://www.enthought.com/products/epd.php Enthought Training: http://www.enthought.com/training/ Webinars http://www.enthought.com/training/webinars.php

Editor's Notes

  • #4: This begins the technical overview—this section of our presentation was interspersed with several live demos which I’ll not try to duplicate here.
  • #10: [toc] level = 1 title = 3D Visualization with mlab # end config