title: Selecting which dimension to index in a numpy array
body: <p>I am writing a program that is suppose to be able to import numpy arrays of some higher dimension, e.g. something like an array a:</p>
  
  <pre><code>a = numpy.zeros([3,5,7,2])
  </code></pre>
  
  <p>Further, each dimension will correspond to some physical dimension, e.g. frequency, distance, ... and I will also import arrays with information about these dimensions, e.g. for a above:</p>
  
  <pre><code>freq = [1,2,3]
  time = [0,1,2,3,4,5,6]
  distance = [0,0,0,4,1]
  angle = [0,180]
  </code></pre>
  
  <p>Clearly from this example and the signature it can be figured out that freq belong to dimension 0, time to dimension 2 and so on. But since this is not known in advance, I can take a frequency slice like</p>
  
  <pre><code>a_f1 = a[1,:,:,:]
  </code></pre>
  
  <p>since I do not know which dimension the frequency is indexed.</p>
  
  <p>So, what I would like is to have some way to chose which dimension to index with an index; in some Python'ish code something like</p>
  
  <pre><code>a_f1 = a.get_slice([0,], [[1],])
  </code></pre>
  
  <p>This is suppose to return the slice with index 1 from dimension 0 and the full other dimensions.</p>
  
  <p>Doing</p>
  
  <pre><code>a_p = a[0, 1:, ::2, :-1]
  </code></pre>
  
  <p>would then correspond to something like</p>
  
  <pre><code>a_p = a.get_slice([0, 1, 2, 3], [[0,], [1,2,3,4], [0,2,4,6], [0,]])
  </code></pre>