title: SciPy: convert feature to frequency domain
body: <p><em>Problem statement</em></p>
  
  <p><strong>Given</strong>: A timeseries which consists of time/amplitude values</p>
  
  <p><strong>Desired output</strong>: A conversion of the given signal into the frequency domain which consists of time/frequency values</p>
  
  <p><em>More info</em></p>
  
  <p>I would like to have an identical mapping of the timestamps in the input, to a frequency level in the output. </p>
  
  <p>To do this I used the <code>signal.spectrogram</code> function from <code>SciPy</code>. It is clear that there is a correspondence between input and output. </p>
  
  <p><strong>Question</strong>: What is the preferred way to convert this output into time/frequency values? Is it good practice to take the maximum value?</p>
  
  <p><em>Code</em></p>
  
  <pre><code>fs = 1.0
  f, t, Sxx = signal.spectrogram(x, fs)
  plt.pcolormesh(t, f, Sxx)
  plt.ylabel('Frequency [Hz]')
  plt.xlabel('Time [sec]')
  plt.axis([t.min(), t.max(), f.min(), .02])
  plt.show()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Dr9Bc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Dr9Bc.png" alt="Input"></a>
  <a href="https://i.stack.imgur.com/DHpPl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DHpPl.png" alt="Spectrogram"></a></p>