title: Numpy Correlate is not providing an offset
body: <p>I am trying to look at astronomical spectra using Python, and I'm using numpy.correlate to try and find a radial velocity shift.  I'm comparing each spectrum I have to one template spectrum.  The problem that I'm encountering is that, no matter which spectra I use, numpy.correlate states that the maximal value of the correlation function occurs with a shift of zero pixels, i.e. the spectra already line up, which is very clearly not true.  Here is some of the relevant code:</p>
  
  <pre><code>corr = np.correlate(temp_data, imag_data, mode='same')
  ax1.plot(delta_data, corr, c='g')
  ax1.plot(delta_data, 100*temp_data, c='b')
  ax1.plot(delta_data, 100*imag_data, c='r')
  </code></pre>
  
  <p>The output of this code is shown here:</p>
  
  <p><a href="https://i.stack.imgur.com/NJqiH.png" rel="nofollow noreferrer">What I Have</a></p>
  
  <p>Note that the cross-correlation function peaks at an offset of zero pixels despite the template (blue) and observed (red) spectra clearly showing an offset.  What I would expect to see would be something a bit like (albeit not exactly like; this is merely the closest representation I could produce):</p>
  
  <p><a href="https://i.stack.imgur.com/2RGlV.png" rel="nofollow noreferrer">What I Want</a></p>
  
  <p>Here I have introduced an artificial offset of 50 pixels in the template data, and they more or less line up now.  What I would like is, for a case like this, for a peak to appear at an offset of 50 pixels rather than at zero (I don't care if the spectra at the bottom appear lined up; that is merely for visual representation).  However, despite several hours of work and research online, I can't find someone who even describes this problem, let alone a solution.  I've attempted to use ScyPy's correlate and MatLib's xcorr, and bot show this same thing (although I'm led to believe that they are essentially the same function).</p>
  
  <p>Why is the cross-correlation not acting the way I expect, and how to do I get it to act in a useful way?</p>