Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
CSE3802/FinalProj.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
61 lines (38 sloc)
1.34 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import division | |
import matplotlib as mpl | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import numpy.fft as dft | |
inputfp = np.loadtxt("ECGSamples.txt", dtype= np.float16) | |
inputea = np.loadtxt("ECGSamples.txt", dtype= np.float128) | |
import random | |
import math | |
import cmath | |
plt.close() | |
time_step = 1 / 30 | |
freqsfp = dft.fftfreq(inputfp.size, time_step) | |
freqsea = dft.fftfreq(inputea.size, time_step) | |
idxfp = np.argsort(freqsfp) | |
idxea = np.argsort(freqsea) | |
# FFT, Floating Point | |
fft_fp_data = np.abs(dft.fft(inputfp)) ** 2#We don't want imaginaries! Messes up our data! | |
#plt.figure() | |
#plt.plot(freqsfp[idxfp],fft_fp_data[idxfp], 'r') | |
#plt.xlabel('frequency [Hz]') | |
#plt.ylabel('Linear Spectrum [V RMS]') | |
fft_ea_data = np.abs(dft.fft(inputea)) ** 2 | |
np.savetxt("FFT_FP.csv", fft_fp_data, delimiter=",") | |
np.savetxt("freqs.csv", freqsea, delimiter=",") | |
np.savetxt("FFT_EA.csv", fft_ea_data,delimiter=",") | |
# | |
# plt.plot(freqs[idx],fft_fp_data[idx]) | |
# FFT, Exact Arithmetic | |
# It always computes the exact answers, just matters if you're importing it as a float or arithmetic | |
#eadata = inputt.astype(Decimal) | |
# | |
#plt.plot(freqsea[idxea],fft_ea_data[idxea], 'b') | |
#fft_xact_data = np.abs(dft.fft(input)) ** 2 | |
#np.savetxt("FFT_XACT.csv", fft_xact_data, delimiter=",") | |
# Prime Algorithm, Floating Point | |
# Prime Algorithm, Exact Arithmetic | |
plt.show() |