Traitement-signal-plantes/Py-Script/puissance.py

38 lines
941 B
Python
Raw Normal View History

2022-03-18 14:29:49 +01:00
import math
import numpy as np
2022-06-02 13:57:01 +02:00
import matplotlib.pyplot as plt
import csv
2022-03-18 14:29:49 +01:00
taille = 100000
freq = 250
2022-03-18 14:29:49 +01:00
periode = 1 / freq
temps = periode * taille
2022-06-02 13:57:01 +02:00
resultat = np.zeros([taille,8])
j = 0
# opening the CSV file
with open('rawData.csv', mode ='r') as file:
# reading the CSV file
2022-06-02 13:57:01 +02:00
csvFile = csv.reader(file, delimiter=",")
# displaying the contents of the CSV file
for lines in csvFile:
2022-06-02 13:57:01 +02:00
line = np.zeros(8)
for i in range(8):
line[i] = lines[i+1]
resultat[j] = line
j+=1
if(j == taille) : break
#print(resultat.shape)
2022-03-24 15:39:51 +01:00
resultat*=resultat
2022-06-02 13:57:01 +02:00
for i in range(8):
aire = 0
2022-06-02 18:10:42 +02:00
flag = False
2022-06-02 13:57:01 +02:00
for j in range(taille-1):
aire += (resultat[j,i]+resultat[j+1,i]) / 2 * periode
2022-06-02 18:10:42 +02:00
if(aire!=0 and flag == False):
flag = True
print(i , j , resultat[j,i] , resultat[j+1,i], aire)
2022-06-02 13:57:01 +02:00
res = aire/temps
print("power c°" + str(i+1) + " : " + str(res))