Skip to content

mlab.psd returns incorrect frequency axis for two-sided spectra with nfft odd. #1561

Closed
@ewmoore

Description

@ewmoore

mlab.psd should probably just be calling np.fft.fftfreq here.

In [1]: import numpy as np

In [2]: import matplotlib.pyplot as plt

In [3]: pxx, f = plt.psd(np.ones(1025), 1025, 10e3, sides='twosided')

In [4]: f
Out[4]:
array([-5004.87804878, -4995.12195122, -4985.36585366, ...,  4965.85365854,
        4975.6097561 ,  4985.36585366])

In this example I have set Fs = 10 kHz, meaning that the highest frequency can't be any larger in than 5 kHz.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions