fftfreq
The function fftfreq is a numerical routine provided by the NumPy library in Python. It generates an array of sample frequencies for use with real and complex discrete Fourier transforms performed by the numpy.fft module. The name stands for frequency domain for Fourier Transform. The function requires the length of the signal, N, and optionally the sample spacing, d, which defaults to one. The output is a one‑dimensional array of length N containing frequency bins that correspond to the order of components returned by the Discrete Fourier Transform.
The computed frequencies are in units of the inverse of d. For even N, the array contains
A typical usage example is to plot the magnitude spectrum of an audio signal sampled at 44100
Related functions include fftshift, ifftshift, rfftfreq, and irfftfreq, which are designed for handling shifted frequency arrays