power c ok working on power py to verify
This commit is contained in:
parent
0f51dceaa1
commit
4bf0dfc70d
|
@ -1,3 +1,3 @@
|
|||
int nRow = 100000;
|
||||
int nCol = 9;
|
||||
int freqEch = 250;
|
||||
double freqEch = 250;
|
BIN
Code-C/power
BIN
Code-C/power
Binary file not shown.
|
@ -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]);
|
||||
}
|
||||
}
|
|
@ -1,3 +1,3 @@
|
|||
#include <math.h>
|
||||
|
||||
double power(int **p);
|
||||
//double *power(int **p);
|
1600022
Code-C/rawData.txt
1600022
Code-C/rawData.txt
File diff suppressed because it is too large
Load diff
|
@ -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)"""
|
Loading…
Reference in a new issue