'Python 2.7: Mayavi Flow function using six input arrays

I am attempting to accurately visualize some CFD data using Mayavi's flow function. I have six 100x100x100 arrays (X, Y, Z, U, V, W), pertaining to the positions and velocities of the particles being analyzed. These were created from single-column arrays with numpy.meshgrid.

The plot comes out nicely when I input three of the arrays, such as U, V, and W, but in this case the visualization is lacking the rest of the data. enter image description here

When I input all six arrays, the 3D plot comes out as a straight line.

enter image description here

My question is: how can I input all six arrays and get a working Flow plot? More specifically, can someone explain the following, an excerpt from the Flow documentation?

"the positions of the arrows are assumed to be the indices of the corresponding points in the (u, v, w) arrays."



Solution 1:[1]

The Flow documentation reads:

The x, y and z arrays are then supposed to have been generated by numpy.mgrid...

So, in order to succeed plotting with the Flow function using six input arrays, one must create the first three using numpy.mgrid

With X, Y, and Z already designated as 1-dimensional arrays, this is what my code looks like this:

Xgrid, Ygrid, Zgrid = np.mgrid[X[1]:X[-1]:50j,Y[1]:Y[-1]:50j,Z[1]:Z[-1]:50j]

Note: numpy.mgrid is different than numpy.meshgrid.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 salamander