Initial
This commit is contained in:
49
fft_meas.py
Normal file
49
fft_meas.py
Normal file
@@ -0,0 +1,49 @@
|
||||
import numpy as np
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import fft
|
||||
|
||||
class fft_meas(object):
|
||||
"""docstring for fft_meas"""
|
||||
def __init__(self, fs=50e3, tn=0.2):
|
||||
self.fs = fs
|
||||
self.ts = 1/fs
|
||||
self.tn = tn
|
||||
self.N = int(int(fs*tn))
|
||||
self.data = np.zeros(self.N)
|
||||
self.idx = -1
|
||||
self.time = 0
|
||||
|
||||
self.freq = 0
|
||||
self.a = 0
|
||||
self.b = 0
|
||||
self.c = 0
|
||||
self.Y_C = 0
|
||||
self.phi = 0
|
||||
|
||||
def step(self, data, time, f_H1, unit):
|
||||
|
||||
if time - self.time > self.ts:
|
||||
self.time = time
|
||||
self.idx += 1
|
||||
|
||||
self.data[self.idx] = data
|
||||
|
||||
if self.idx == self.N-1:
|
||||
|
||||
|
||||
self.freq , self.a, self.b , self.c, self.Y_C, self.phi = fft.fft(x=self.data, fs=self.fs)
|
||||
|
||||
self.idx = -1
|
||||
|
||||
|
||||
|
||||
def plot(self):
|
||||
#fs, a, b, c, YC, phi = ftt.fft(Ph1, sample_freq)
|
||||
|
||||
plt.plot(self.freq, self.c)
|
||||
plt.xlabel("x")
|
||||
plt.ylabel("y")
|
||||
plt.title("Simple plot")
|
||||
plt.show()
|
||||
|
||||
Reference in New Issue
Block a user