#NEWLINE# def spectrogram( x , fs = 1.0 , window = ( 'tukey' , 0.25 ) , nperseg = 256 , noverlap = None , nfft = None , detrend = 'constant' , return_onesided = True , scaling = 'density' , axis = ( - 1 ) , mode = 'psd' ) : #NEWLINE# #INDENT# '\n    Compute a spectrogram with consecutive Fourier transforms.\n\n    Spectrograms can be used as a way of visualizing the change of a\n    nonstationary signal\'s frequency content over time.\n\n    Parameters\n    ----------\n    x : array_like\n        Time series of measurement values\n    fs : float, optional\n        Sampling frequency of the `x` time series. Defaults to 1.0.\n    window : str or tuple or array_like, optional\n        Desired window to use. See `get_window` for a list of windows and\n        required parameters. If `window` is array_like it will be used\n        directly as the window and its length will be used for nperseg.\n        Defaults to a Tukey window with shape parameter of 0.25.\n    nperseg : int, optional\n        Length of each segment.  Defaults to 256.\n    noverlap : int, optional\n        Number of points to overlap between segments. If None,\n        ``noverlap = nperseg // 8``.  Defaults to None.\n    nfft : int, optional\n        Length of the FFT used, if a zero padded FFT is desired.  If None,\n        the FFT length is `nperseg`. Defaults to None.\n    detrend : str or function or False, optional\n        Specifies how to detrend each segment. If `detrend` is a string,\n        it is passed as the ``type`` argument to `detrend`.  If it is a\n        function, it takes a segment and returns a detrended segment.\n        If `detrend` is False, no detrending is done.  Defaults to \'constant\'.\n    return_onesided : bool, optional\n        If True, return a one-sided spectrum for real data. If False return\n        a two-sided spectrum. Note that for complex data, a two-sided\n        spectrum is always returned.\n    scaling : { \'density\', \'spectrum\' }, optional\n        Selects between computing the power spectral density (\'density\')\n        where `Pxx` has units of V**2/Hz and computing the power spectrum\n        (\'spectrum\') where `Pxx` has units of V**2, if `x` is measured in V\n        and fs is measured in Hz.  Defaults to \'density\'\n    axis : int, optional\n        Axis along which the spectrogram is computed; the default is over\n        the last axis (i.e. ``axis=-1``).\n    mode : str, optional\n        Defines what kind of return values are expected. Options are [\'psd\',\n        \'complex\', \'magnitude\', \'angle\', \'phase\'].\n\n    Returns\n    -------\n    f : ndarray\n        Array of sample frequencies.\n    t : ndarray\n        Array of segment times.\n    Sxx : ndarray\n        Spectrogram of x. By default, the last axis of Sxx corresponds to the\n        segment times.\n\n    See Also\n    --------\n    periodogram: Simple, optionally modified periodogram\n    lombscargle: Lomb-Scargle periodogram for unevenly sampled data\n    welch: Power spectral density by Welch\'s method.\n    csd: Cross spectral density by Welch\'s method.\n\n    Notes\n    -----\n    An appropriate amount of overlap will depend on the choice of window\n    and on your requirements. In contrast to welch\'s method, where the entire\n    data stream is averaged over, one may wish to use a smaller overlap (or\n    perhaps none at all) when computing a spectrogram, to maintain some\n    statistical independence between individual segments.\n\n    .. versionadded:: 0.16.0\n\n    References\n    ----------\n    .. [1] Oppenheim, Alan V., Ronald W. Schafer, John R. Buck "Discrete-Time\n           Signal Processing", Prentice Hall, 1999.\n\n    Examples\n    --------\n    >>> from scipy import signal\n    >>> import matplotlib.pyplot as plt\n\n    Generate a test signal, a 2 Vrms sine wave whose frequency linearly changes\n    with time from 1kHz to 2kHz, corrupted by 0.001 V**2/Hz of white noise\n    sampled at 10 kHz.\n\n    >>> fs = 10e3\n    >>> N = 1e5\n    >>> amp = 2 * np.sqrt(2)\n    >>> noise_power = 0.001 * fs / 2\n    >>> time = np.arange(N) / fs\n    >>> freq = np.linspace(1e3, 2e3, N)\n    >>> x = amp * np.sin(2*np.pi*freq*time)\n    >>> x += np.random.normal(scale=np.sqrt(noise_power), size=time.shape)\n\n    Compute and plot the spectrogram.\n\n    >>> f, t, Sxx = signal.spectrogram(x, fs)\n    >>> plt.pcolormesh(t, f, Sxx)\n    >>> plt.ylabel(\'Frequency [Hz]\')\n    >>> plt.xlabel(\'Time [sec]\')\n    >>> plt.show()\n    ' #NEWLINE# if ( noverlap is None ) : #NEWLINE# #INDENT# noverlap = ( nperseg // 8 ) #NEWLINE# #UNINDENT# ( freqs , time , Pxy ) = _spectral_helper ( x , x , fs , window , nperseg , noverlap , nfft , noverlap , return_onesided , scaling , axis , mode = mode ) #NEWLINE# return ( freqs , time , Pxy )