[Python] FFT Does Not Detect Expected Frequencies in Experimental Data with Known Periodicities

Discussão em 'Python' iniciado por Stack, Março 13, 2025.

  1. Stack

    Stack Membro Participativo

    I am analyzing experimental data where resistance Rxx is measured as a function of an angle Phi, which ranges from 0 to 360 degrees in steps of 2 degrees. The dataset consists of two columns: Phi (angle in degrees, from 0 to 360 with step 2°), Rxx (longitudinal resistance) which both only contain real numbers.

    The Problem:

    The dataset can be well described by a function consisting of the sum of two squared cosines: Rxx(Phi) = A * cos^2(Pi * (Phi - Phi_0) / 180) + B * cos^2(Pi * (Phi - Phi_0) / 90) + const

    However, when I apply FFT I do not observe peaks at 2 or 4 cycles per 360°. Instead, I see a low-frequency artifact that do not correspond to the expected periodicities.

    My Questions:

    Why does FFT fail to detect the expected frequencies (2 and 4 cycles per 360°)? How to fix this?

    The code I'm using:

    import numpy as np
    import pandas as pd
    import matplotlib.pyplot as plt
    from scipy.fft import fft, fftfreq


    # import data

    data = pd.read_csv("test")
    x = data["Phi"].to_numpy()
    Rxx = data["Rxx"].to_numpy()

    angles = np.deg2rad(x) # convert degrees to radians
    dPhi = np.deg2rad(angles[2]-angles[1]) # define angular step
    N = len(angles) # number of points

    fft_Rxx = fft(Rxx) # compute FFT
    freqs = fftfreq(N, dPhi) / (2 * np.pi) # compute frequency

    amplitude_Rxx = np.abs(fft_Rxx) # compute magnitude spectrum

    # plot results

    plt.plot(freqs, amplitude_Rxx)
    plt.show()


    Here is a link to my dataset: link

    Continue reading...

Compartilhe esta Página