title: Compute time Series from PSD python
body: <p>I have a signal spectrum PSD that looks like :</p>
  
  <p><img src="https://i.stack.imgur.com/AZQ5R.png" alt="enter image description here"></p>
  
  <p>The  frequency range of the PSD is np.linspace(0,2,500). I want to convert this spectrum into a time series of 600s . The code is shown below:</p>
  
  <pre><code>def spectrumToSeries(timeSeries,frequency,psdLoad):
      ''' 
      Function that gicen a PSD converts into a time series
  
      '''
      #
      #Obtian interval frequency
      df=frequency[2]-frequency[1]    
  
      #Obtian the spectrum amplitudes
      amplitude=np.sqrt(2*np.array(psdLoad)*df)
  
      #Pre allocation of matrices
      epsilon=np.zeros((len(amplitude)))
      randomSeries=np.zeros((len(amplitude)))
  
  
      #Create time series from spectrum
      #Generate random phases between [-2pi,2pi]
      epsilon=-np.pi + 2*np.pi*np.random.randn(1,len(amplitude))
  
      #Inverse Fourier
      randomSeries=len(timeSeries)*np.real(np.fft.ifft(amplitude*np.exp(epsilon*1j*2*np.pi))));
  
      return randomSeries
  </code></pre>
  
  <p>However my end result looks like: </p>
  
  <pre><code>timeSeries = spectrumToSeries(thrustBladed,param.frequency,analyticalThrustPSD[iwind])   
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/RKWXX.png" alt="enter image description here"></p>
  
  <p>The x axis is refering the number of points of the time series. However, the time series should be of 600s. Any help? Thanks </p>