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 nCol = 9;
int freqEch = 250;
double freqEch = 250;

Binary file not shown.

View file

@ -2,28 +2,32 @@
#include "getArray.h"
#include "initialParameters.h"
double power(int **p){
double periode = (1/freqEch);
printf("periode : %d\n",periode);
double power[8];
void *power(int **p, double a[]){
double periode = 1.0/freqEch;
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++){
int j = 0;
double res = 0;
while(1){
if(!(p[j+1][i] == NULL)) break;
a[i] = 0;
while(j < nRow-1){
double aire = ( pow(p[j][i],2) + pow(p[j+1][i],2) ) / 2 * periode;
printf("aire [%d,%d] : %d\n",j,i,aire);
res += aire;
//printf("aire [%d,%d] : %f\n",j,i,aire);
a[i] += aire;
j++;
}
printf("résultat : %d\n",res);
power[i] = res;
a[i] *= temps;
}
return *power;
}
int main(int argc , char** argv){
int **p = getRawDataArray(nRow, nCol);
//printArray(p,nRow,nCol);
double pw = power(p);
printf("%d" , pw);
double pw[8];
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>
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 numpy as np
# import matplotlib.pyplot as plt
import struct
import csv
#"C:\Users\quent\OneDrive\Bureau\ENSC\TransD\Framboisier\02400001.TXT"
#! /usr/bin/env python3
# -*- coding: UTF-8 -*-
link = "test.txt"
f = open(link , "rb")#ouvertuture du fichier txt traiter
taille = 5
taille = 100000
freq = 250
periode = 1 / freq
temps = periode * taille
resultat = np.zeros(taille)
for i in range(taille):
resultat[i] = f.readline() #on sait que chaque ligne corespond à une mesure
f.close()
i = 0
# opening the CSV file
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
aire = 0
for i in range(taille-1):
aire += (resultat[i]+resultat[i+1]) / 2 * periode
f = open("puissance.txt" ,"a")
f.writelines(str(aire)+"\n")
f.close()
res = aire/temps
print(res)"""