power c ok working on power py to verify

This commit is contained in:
quentin.perret 2022-06-02 12:12:41 +02:00
parent 0f51dceaa1
commit 4bf0dfc70d
6 changed files with 800054 additions and 800037 deletions

View file

@ -1,3 +1,3 @@
int nRow = 100000; int nRow = 100000;
int nCol = 9; int nCol = 9;
int freqEch = 250; double freqEch = 250;

Binary file not shown.

View file

@ -2,28 +2,32 @@
#include "getArray.h" #include "getArray.h"
#include "initialParameters.h" #include "initialParameters.h"
double power(int **p){ void *power(int **p, double a[]){
double periode = (1/freqEch);
printf("periode : %d\n",periode); double periode = 1.0/freqEch;
double power[8]; double temps = 1/(nRow * periode);
printf("periode : %f\n",periode);
printf("temps : %f\n",temps);
//Fill array with the power of the signal for each captor
for(int i = 1; i < nCol; i++){ for(int i = 1; i < nCol; i++){
int j = 0; int j = 0;
double res = 0; a[i] = 0;
while(1){ while(j < nRow-1){
if(!(p[j+1][i] == NULL)) break;
double aire = ( pow(p[j][i],2) + pow(p[j+1][i],2) ) / 2 * periode; double aire = ( pow(p[j][i],2) + pow(p[j+1][i],2) ) / 2 * periode;
printf("aire [%d,%d] : %d\n",j,i,aire); //printf("aire [%d,%d] : %f\n",j,i,aire);
res += aire; a[i] += aire;
j++; j++;
} }
printf("résultat : %d\n",res); a[i] *= temps;
power[i] = res;
} }
return *power;
} }
int main(int argc , char** argv){ int main(int argc , char** argv){
int **p = getRawDataArray(nRow, nCol); int **p = getRawDataArray(nRow, nCol);
//printArray(p,nRow,nCol); //printArray(p,nRow,nCol);
double pw = power(p); double pw[8];
printf("%d" , pw); power(p,pw);
for(int i = 1 ; i < nCol ; i++){
printf("power c°%d : %f\n",i,pw[i]);
}
} }

View file

@ -1,3 +1,3 @@
#include <math.h> #include <math.h>
double power(int **p); //double *power(int **p);

File diff suppressed because it is too large Load diff

View file

@ -1,26 +1,39 @@
import math import math
import numpy as np import numpy as np
# import matplotlib.pyplot as plt # import matplotlib.pyplot as plt
import struct import csv
#"C:\Users\quent\OneDrive\Bureau\ENSC\TransD\Framboisier\02400001.TXT" #"C:\Users\quent\OneDrive\Bureau\ENSC\TransD\Framboisier\02400001.TXT"
#! /usr/bin/env python3 #! /usr/bin/env python3
# -*- coding: UTF-8 -*- # -*- coding: UTF-8 -*-
link = "test.txt"
f = open(link , "rb")#ouvertuture du fichier txt traiter
taille = 5
taille = 100000
freq = 250 freq = 250
periode = 1 / freq periode = 1 / freq
temps = periode * taille temps = periode * taille
resultat = np.zeros(taille) resultat = np.zeros(taille)
for i in range(taille): i = 0
resultat[i] = f.readline() #on sait que chaque ligne corespond à une mesure # opening the CSV file
f.close() with open('rawData.csv', mode ='r') as file:
# reading the CSV file
csvFile = csv.DictReader(file)
# displaying the contents of the CSV file
for lines in csvFile:
resultat[i] = lines
print(lines)
i+=1
"""
resultat*=resultat resultat*=resultat
aire = 0 aire = 0
for i in range(taille-1): for i in range(taille-1):
aire += (resultat[i]+resultat[i+1]) / 2 * periode aire += (resultat[i]+resultat[i+1]) / 2 * periode
f = open("puissance.txt" ,"a") res = aire/temps
f.writelines(str(aire)+"\n") print(res)"""
f.close()