-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfourier.py
More file actions
55 lines (37 loc) · 1.36 KB
/
fourier.py
File metadata and controls
55 lines (37 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import numpy as np
import matplotlib.pyplot as plt
from scipy import fft
from time import sleep
import math
from comandos_linux import *
class Fourier:
def __init__(self, datos_para_calcular, fourier_a_iu , barrera_fourier, barrera_fourier_fin, posicion_cpu, pids, porcen_cpu):
self.fourier_a_iu = fourier_a_iu
self.ventana = [0]*100
self.datos_para_calcular = datos_para_calcular
self.porcen_cpu = porcen_cpu
self.posicion_cpu = posicion_cpu
self.pids = pids
self.barrera_fourier = barrera_fourier
self.barrera_fourier_fin = barrera_fourier_fin
def update_info_cpu(self):
self.pids[1] = pid()
self.posicion_cpu[1] = cpu(self.pids[1])
self.porcen_cpu[1] = porcentaje_cpu(self.pids[1])
def iniciar(self):
ventana = []
while(True):
self.barrera_fourier.wait()
self.update_info_cpu()
dato = self.datos_para_calcular.get()
ventana.append(dato)
if len(ventana) == 100:
l_fourier = self.fourier(ventana)
self.fourier_a_iu.put(l_fourier)
ventana = []
self.barrera_fourier_fin.wait()
def fourier(self, y):
n = len(y)
Y = np.fft.fft(y) / n
Y = Y[range(int(n/2))]
return np.abs(Y)