MAYAVI2(1)

MAYAVI2 πŸ’–βœ¨

okay bestie, welcome to the manual for mayavi2, a General Commands Manual classic and honestly? a whole vibe. it's giving "science but make it pretty." let's get into it πŸ¦‹


NAME πŸŽ€

mayavi2 β€” a scientific visualization package for 2-D and 3-D data. yes. literally that. she visualizes your science. iconic behavior.


SYNOPSIS ✨

mayavi2 [options] [args]

so where do arg1, arg2, etc. come in? those are optional file names, and they correspond to:

  • saved Mayavi2 visualizations (filename.mv2)
  • Mayavi2 scripts (filename.py)
  • any data file formats that Mayavi supports

basically you can just hand her a file and she'll know what to do with it. main character energy fr fr πŸ’…


DESCRIPTION 🌸

Mayavi2 is a tool for 2-D and 3-D scientific visualization. and the features? oh we're listing them, bestie. features of Mayavi2 include:

  • Visualization of scalar and vector data in 2 and 3 dimensions
  • Easy scriptability using Python
  • Easy extendability via sources, components, modules, and data filters
  • Reading several file formats: VTK (legacy and XML), PLOT3D, etc.
  • Saving of visualizations
  • Saving rendered visualization in a variety of image formats.

like. scriptable, extendable, reads everything, saves everything. she does it ALL no cap πŸ‘‘


OPTIONS πŸ’…

every single flag, right here, in order, no skips, we're not doing that:

  • -h β€” prints all the available command line options and exits. also available through --help.
  • -V β€” prints the Mayavi version on the command line and exits. also available through --version.
  • -z filename.mv2 β€” loads a previously saved Mayavi2 visualization. also available through --viz filename.mv2 or --visualization filename.mv2.
  • -d datafile.* β€” opens any of the supported data file formats, or a non-file related data source. this includes VTK file formats (*.vtk, *.xml, *.vt[i,p,r,s,u], *.pvt[i,p,r,s,u]), VRML2 (*.wrl), 3D Studio (*.3ds), PLOT3D (*.xyz), STL, BYU, RAW, PLY, PDB, SLC, FACET, OBJ, AVSUCD (*.inp), GAMBIT (*.neu), Exodus (*.exii), PNG, JPEG, BMP, PNM, DCM, DEM, MHA, MHD, MINC, XIMG, TIFF, and various others that are supported. datafile.* can also be a source object that is not associated with a file β€” for example ParametricSurface or PointLoad will load the corresponding data sources into Mayavi. also available through --data.
  • -m module-name β€” a module is an object that actually visualizes the data. the given module-name is loaded in the current ModuleManager. the module name must be a valid one β€” if not, you will get an error message.

if a module is specified as 'package.sub.module.SomeModule' then the module (SomeModule) is imported from 'package.sub.module'. standard modules provided with mayavi2 do not need the full path specification. for example:

mayavi2 -d data.vtk -m Outline -m m2_user_modules.TestModule

in this example 'Outline' is a standard module and 'm2_user_modules.TestModule' is some user defined module. see the MAYAVI2 MODULES section below for an exhaustive list of available modules. also available through --module.

  • -f filter-name β€” a filter is an object that filters out the data in some way or the other. the given filter-name is loaded with respect to the current source/filter object. the filter name must be a valid one β€” if not you will get an error message.

if the filter is specified as 'package.sub.filter.SomeFilter' then the filter (SomeFilter) is imported from 'package.sub.filter'. standard modules provided with mayavi2 do not need the full path specification. for example:

mayavi2 -d data.vtk -f ExtractVectorNorm -f
m2_user_filters.TestFilter

in this example 'ExtractVectorNorm' is a standard filter and 'm2_user_filters.TestFilter' is some user defined filter.

see the MAYAVI2 FILTERS section below for an exhaustive list of available filters. also available through --filter.

  • -M β€” starts up a new module manager on the Mayavi pipeline. also available through --module-mgr.
  • -n β€” creates a new window/scene. any options passed after this will apply to this newly created scene. also available through --new-window.
  • -t β€” runs the mayavi2 test suite and exits. if run as such, this runs both the TVTK and Mayavi2 unittests. if any additional arguments are passed, they are passed along to the test runner. so this may be used to run other tests as well. for example:
mayavi2 -t enthought.persistence

this will run just the tests inside the enthought.persistence package. you can also specify a directory with test files to run with this, for example:

mayavi2 -t relative_path_to/integrationtests/mayavi

will run the integration tests from the mayavi sources. also available through --test.

  • -x script-file β€” executes the given script in a namespace where we guarantee that the name 'mayavi' is Mayavi's script instance β€” just like in the embedded Python interpreter. also available through --exec.
⚠️ WARNING: note that this uses execfile, so please note that this can be dangerous if the script does something nasty! 😭
  • -s python-expression β€” executes the expression on the last created object. for example, if the previous object was a module, and we want to set the color of that object, one can do -s "actor.property.color = (1,0,0)". one should use quotes for the expression. also available with --set. for example:
mayavi2 -d ParametricSurface -m Outline \
 -s "actor.property.color = (1,0,0)" \
 -s "scene.save('test.png', size=(800, 800))"
⚠️ WARNING: note that this uses exec, so please note that this can be dangerous! πŸ’€

MAYAVI2 MODULES πŸ‘‘

here's the full roster, bestie. every single one. she has RANGE:

  • Axes β€” draws simple axes.
  • ContourGridPlane β€” a contour grid plane module. this module lets one take a slice of input grid data and view contours of the data.
  • CustomGridPlane β€” a custom grid plane with a lot more flexibility than the GridPlane module.
  • DataSetClipper β€” this filter clips the dataset in a area. the area can be defined interactively as a box, a sphere...
  • Glyph β€” displays different types of glyphs oriented and colored as per scalar or vector data at the input points.
  • GridPlane β€” a simple grid plane module.
  • HyperStreamline β€” a module that integrates through a tensor field to generate a hyperstreamline. the integration is along the maximum eigenvector and the cross section of the hyperstreamline is defined by the two other eigenvectors. thus the shape of the hyperstreamline is "tube-like", with the cross section being elliptical. hyperstreamlines are used to visualize tensor fields.
  • ImageActor β€” a simple module to view image data efficiently.
  • ImagePlaneWidget β€” a simple module to view image data.
  • IsoSurface β€” a module that allows the user to make contours of input point data.
  • Labels β€” allows a user to label the current dataset or the current actor of the active module.
  • OrientationAxes β€” creates a small axes on the side that indicates the position of the co-ordinate axes and thereby marks the orientation of the scene. requires VTK-4.5 and above.
  • Outline β€” a module that draws an outline for the given data.
  • ScalarCutPlane β€” takes a cut plane of any input data set using an implicit plane and plots the data with optional contouring and scalar warping.
  • SliceUnstructuredGrid β€” this module takes a slice of the unstructured grid data and shows the cells that intersect or touch the slice.
  • Streamline β€” allows the user to draw streamlines for given vector data. this supports various types of seed objects (line, sphere, plane and point seeds). it also allows the user to draw ribbons or tubes and further supports different types of interactive modes of calculating the streamlines.
  • StructuredGridOutline β€” draws a grid-conforming outline for structured grids.
  • Surface β€” draws a surface for any input dataset with optional contouring.
  • TensorGlyph β€” displays tensor glyphs oriented and colored as per scalar or vector data at the input points.
  • Text β€” this module allows the user to place text on the screen.
  • VectorCutPlane β€” takes an arbitrary slice of the input data using an implicit cut plane and places glyphs according to the vector field data. the glyphs may be colored using either the vector magnitude or the scalar attributes.
  • Vectors β€” displays different types of glyphs oriented and colored as per vector data at the input points. this is merely a convenience module that is entirely based on the Glyph module.
  • Volume β€” the Volume module visualizes scalar fields using volumetric visualization techniques.
  • WarpVectorCutPlane β€” takes an arbitrary slice of the input data using an implicit cut plane and warps it according to the vector field data. the scalars are displayed on the warped surface as colors.

and that's the modules, bestie πŸ’œ more coming, don't you dare close the tab 🫢

πŸŽ€ MAYAVI2 FILTERS πŸŽ€

okay bestie, this is the good part β€” the filters πŸ’…. these are the lil' gizmos you bolt onto your pipeline with -f, or clicky-click in the GUI, to bend your data into whatever shape your heart desires. here's the whole roster, no cap:

  • CellDerivatives β€” takes your input point scalar and vector data, does the derivative thing, and hands you back cell data all about the gradients. want an approximate vorticity? this is giving exactly that ✨
  • CellToPointData β€” flips cell attribute data into point data by averaging the cell data from all the cells hanging out at that point 🫢
  • Contour β€” a contour filter that wraps around the Contour component, so you get iso-surfaces on literally any input dataset. iconic.
  • CutPlane β€” a cut plane you can slice through any dataset with πŸ”ͺ and it also brings a 3D widget interface so you can position and move the slice interactively. main character energy.
  • ElevationFilter β€” makes scalar data that corresponds to the elevation of the points along a line ⛰️
  • Delaunay2D β€” 2D Delaunay triangulation, periodt.
  • Delaunay3D β€” same vibe, but in 3D ✨
  • ExtractEdges β€” pulls the cell edges out of any input data.
  • ExtractGrid β€” lets you select just a part of a structured grid. choosey queen πŸ’…
  • ExtractTensorComponents β€” wraps the TVTK ExtractTensorComponents filter so you can extract components from a tensor field.
  • ExtractUnstructuredGrid β€” lets you select a part of an unstructured grid.
  • ExtractVectorNorm β€” computes the norm (Euclidean) of your input vector data, with optional scaling between [0, 1]. super useful when the input data has vector input but no scalar data for the magnitude of the vectors β€” like, where else are you gonna get it 😭
  • ExtractVectorComponents β€” wraps the TVTK ExtractVectorComponents filter to extract components of a vector. perfect for analysing individual components of vector data one at a time πŸ¦‹
  • GaussianSplatter β€” splats your points into a volume with an elliptical, Gaussian distribution. splat πŸ’₯
  • MaskPoints β€” selectively passes the input points downstream, which is how you subsample your points.
⚠️ heads up bestie: this does not pass geometry data. that means all grid information is lost. like, poof πŸ’€
  • GreedyTerrainDecimation β€” approximates a height field (image data) with a triangle mesh while keeping the number of triangles at a minimum. frugal and gorgeous 🌸
  • ImageChangeInformation β€” changes the origin, spacing and extents of an input image dataset without changing the data itself. glow-up with zero side effects ✨
  • ImageDataProbe β€” probes any dataset using a Structured Points dataset. it also lets you convert the scalar data to an unsigned short array so those scalars can be used for volume visualization πŸ‘‘
  • PointToCellData β€” does the inverse of the CellToPointData filter. exactly what it says on the tin πŸŽ€
  • PolyDataNormals β€” computes normals from input data, which gives meshes a smoother appearance. should work for any input dataset.
πŸ“Œ note: in the Mayavi2 GUI this one is called "Compute Normals" (Visualize/Filters/Compute Normals). yes, same filter, different name, it's giving alias πŸ’…
  • QuadricDecimation β€” reduces the triangles in a mesh and still forms a good approximation of the original mesh. less is more, periodt.
  • SelectOutput β€” lets you select one among several of the outputs of a given input. typically super useful for a multi-block data source, fr fr.
  • SetActiveAttribute β€” lets you set the active data attribute (scalars, vectors and tensors) on a VTK dataset. especially useful if you need to do something like compute contours of one scalar on the contour of another scalar. nesting dolls but make it science πŸͺ†
  • Stripper β€” creates triangle strips and/or poly-lines. great for regularizing broken up surfaces, such as those created by the Tube filter.
  • Threshold β€” a simple filter that thresholds on input data. simple, effective, iconic.
  • TransformData β€” performs a linear transformation to input data πŸ“
  • TriangleFilter β€” converts input polygons and triangle strips to triangles using the tvtk.TriangleFilter class. you want this when you've got a downstream filter that only processes triangles and nothing else πŸ™ˆ
  • Tube β€” turns lines into tubes. that's it. that's the filter 🧚
  • UserDefined β€” lets you define your own filter dynamically/interactively. it's like FilterBase but it allows you to specify the class without writing any code. DIY queen πŸ‘‘
  • Vorticity β€” computes the vorticity of an input vector field. for convenience, the filter lets you optionally pass-through the given input vector field, and it also lets you show the component of the vorticity along a particular cartesian co-ordinate axes. it produces point data on output which is ready to visualize 🌈
  • WarpScalar β€” warps the input data along a particular direction (either the normals or a direction you specify) with a scale specified by the local scalar value. carpet plots, bestie 🧢
  • WarpVector β€” warps the input data along the point vector attribute, scaled as per a scale factor. perfect for showing flow profiles or displacements πŸ’«

✨ EXAMPLES ✨

here's the vibe in action, copy-paste away:

mayavi2 -d heart.vtk -m Axes -m Outline -m GridPlane -m ContourGridPlane -m IsoSurface
mayavi2 -d fire_ug.vtu -m Axes -m Outline -m VectorCutPlane -f MaskPoints -m Glyph

In the above examples, heart.vti and fire_ug.vtu VTK files can be found in /usr/share/doc/mayavi2/examples/data. The examples directory (/usr/share/doc/mayavi2/examples/ on Debian) provides several useful examples πŸ‘€


πŸ’– AUTHOR πŸ’–

Mayavi was originally developed by Prabhu Ramachandran. Many people have later contributed to it. legends only 🫢

More information on Mayavi2 can be obtained from http://code.enthought.com/mayavi2


and that's the whole page, bestie! this is the MAYAVI2(1) manual page β€” section 1 of the manual, the one and only β€” so go forth and render something absolutely gorgeous. slay πŸ’…βœ¨πŸŒˆ

πŸ“¦ where this page comes from