0
mirror of https://github.com/ltian059/Graduation-Project.git synced 2025-02-05 19:37:44 +00:00
itian059-grad-project/Summer 2024 Health Monitoring - Charlie's Work/Charlie_Code/Data Analysis and Matching/Python/FFTanalysis.py
2024-12-04 12:46:40 -05:00

12 lines
312 B
Python

import numpy as np
from scipy.fft import fft
def FFTanalysis(y, fs):
len_y = len(y)
NFFT = 2 ** np.ceil(np.log2(len_y)).astype(int)
y = y - np.mean(y)
sub = fft(y, NFFT) / len_y
sub = 2 * np.abs(sub[:NFFT // 2 + 1])
f = (fs / 2) * np.linspace(0, 1, NFFT // 2 + 1) * 60
return sub, f