title: numpy slicing using user defined input
body: <p>I have (in a larger project) data contained in numpy.array.
  Based on user input I need to move a selected axis (dimAxisNr) to the first dimension of the array and slice one or more (including the first) dimension based on user input (such as Select2 and Select0 in the example).</p>
  
  <p>Using this input I generate a DataSelect which contains the information needed to slice. But the output size of the sliced array is different from the one using inline indexing. So basically I need a way to generate the '37:40:2' and '0:2' from an input list.</p>
  
  <pre><code>import numpy as np
  dimAxisNr = 1
  Select2 = [37,39]
  Select0 = [0,1]
  
  
  plotData = np.random.random((102,72,145,2))
  
  DataSetSize = np.shape(plotData)
  DataSelect = [slice(0,item) for item in DataSetSize]
  DataSelect[2] = np.array(Select2)
  DataSelect[0] = np.array(Select0)
  
  
  def shift(seq, n):
      n = n % len(seq)
      return seq[n:] + seq[:n]
  
  #Sort and Slice the data
  
  print(np.shape(plotData))
  print(DataSelect)
  
  plotData = np.transpose(plotData, np.roll(range(plotData.ndim),-dimAxisNr))
  DataSelect = shift(DataSelect,dimAxisNr)
  
  print(DataSelect)
  print(np.shape(plotData))
  plotData = plotData[DataSelect]
  print(np.shape(plotData))
  
  plotDataDirect = plotData[slice(0, 72, None), 37:40:2, slice(0, 2, None), 0:2]
  print(np.shape(plotDataDirect))
  </code></pre>