title: How to carry out time lag analysis / cross correlation between wind and ocean wave data with python?
body: <p>I have hourly wind speed data and hourly surface wave height data and would like to see if these correlate and whether there is a time lag between the two. The data is currently in two separate panda data frames. I have tried using scipy.correlate and np.xcorr but they either return only zeros or the size of the data as the result. Any help would be much appreciated.</p>
  
  <pre><code>nsamples = wind.speed.size
  
  wind.speed -= wind.speed.mean(); wind.speed /= wind.speed.std()
  wave.HEIGHT -= wave.HEIGHT.mean(); wave.HEIGHT /= wave.HEIGHT.std()
  
  xcorr = correlate(wind.speed, wave.HEIGHT)
  
  dt = np.arange(1-nsamples, nsamples)
  
  recovered_time_shift = xcorr.argmax()
  
  print dt
  print "Recovered time shift: %d" % (recovered_time_shift)
  </code></pre>
  
  <p>Many thanks,</p>