title: How to generate a 3D grid of vectors ? (each position in the 3D grid is a vector)
body: <p>I want to generate a four dimensional array with dimensions (dim,N,N,N). The first component ndim =3 and N corresponds to the grid length. How can one elegantly generate such an array using python ? </p>
  
  <p>here is my 'ugly' implementation:</p>
  
  <pre><code>qvec=np.zeros([ndim,N,N,N])  
  
  freq   = np.arange(-(N-1)/2.,+(N+1)/2.)
  x, y, z = np.meshgrid(freq[range(N)], freq[range(N)], freq[range(N)],indexing='ij')
  
  qvec[0,:,:,:]=x
  qvec[1,:,:,:]=y
  qvec[2,:,:,:]=z
  </code></pre>