[Numpy-discussion] Understanding mgrid

Brad Malone brad.malone at gmail.com
Fri Sep 19 13:59:22 EDT 2008


Hi, I was wondering if someone could englighten me on what the geometrical
significance of numpy.mgrid is. I can play around with it and see trends in
the sizes and number of arrays, but why does it give the output that it
does? Looking at the example shown below, why does it return a matrix and
its transpose? Is this a representation of some geometrical grid? Does the
output imply some sort of connectivity? If so, how do you see it?

 >>> mgrid[0:5,0:5]
   array([[[0, 0, 0, 0, 0],
           [1, 1, 1, 1, 1],
           [2, 2, 2, 2, 2],

           [3, 3, 3, 3, 3],
           [4, 4, 4, 4, 4]],
   <BLANKLINE>
          [[0, 1, 2, 3, 4],

           [0, 1, 2, 3, 4],
           [0, 1, 2, 3, 4],
           [0, 1, 2, 3, 4],

           [0, 1, 2, 3, 4]]])



I have a cubic grid in 3D space that is spanned by 3 orthogonal vectors. Am
I able to generate this equivalent grid with mgrid somehow? If so, how is it
done? I am using mayavi and I need to be able to construct some arrays in
the same way that mgrid would have constructed them, so this is why I ask.

Thanks for the help,
Brad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20080919/82c24417/attachment.html>


More information about the NumPy-Discussion mailing list