Blame view
fft.php
2.65 KB
cf76164e6 20190709 |
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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
<!DOCTYPE html> <html> <?php require_once 'FFT.class.php'; $filename = "/home/pi/Desktop/vAlert/rec/20180118130646_1001[0001]_541.csv"; $row = 0; $i = 0; if (($handle = fopen($filename, "r")) !== FALSE) { while (($data = fgetcsv($handle, 10000, ",")) !== FALSE) { if($row == "2") $time = explode("e:",$data['0']); //find RecordLength if($row == "3") $sec = explode(":",$data['0']); if($row >= "28"){ $array_z[] = $data['0']; $array_x[] = $data['1']; $array_y[] = $data['2']; } $row++; } } foreach($array_x as $key=>$value){ $radial_x[]=$value; } $period = 512; $fft = new FFT($period); $divided = ($period/2)-1; $fft_data_z = $fft->fft($radial_x); $power = $fft->getAbsFFT($fft_data_z); foreach($power as $key=>$value){ $vertical[]="{x:".$key.",y:".$value."}"; } for($j=0;$j<=$divided;$j++){ $array_z[] = $power[$j]; } print_r($vertical); /*foreach($array_z as $key=>$value){ $vertical[]="{x:".$key.",y:".$value."}"; }*/ foreach($array_y as $key=>$value){ $transverse[]="{x:".$key.",y:".$value."}"; } foreach($array_x as $key=>$value){ $radial[]="{x:".$key.",y:".$value."}"; } ?> <head> <script> window.onload = function () { var transverse = { animationEnabled: true, zoomEnabled: true, title:{ text: "Transverse" }, data: [{ type: "line", dataPoints: [ <?php echo implode(",",$transverse); ?> ] }], axisY:{ includeZero: false } }; $("#chartContainer2").CanvasJSChart(transverse); var radial = { animationEnabled: true, zoomEnabled: true, title:{ text: "Radial" }, data: [{ type: "line", color: "#FF0000", dataPoints: [ <?php echo implode(",",$radial); ?> ] }], axisY:{ includeZero: false } }; $("#chartContainer").CanvasJSChart(radial); var vertical = { animationEnabled: true, zoomEnabled: true, title:{ text: "Vertical" }, data: [{ type: "line", color: "#33FF33", dataPoints: [ <?php echo implode(",",$vertical); ?> ] }], axisY:{ includeZero: false } }; $("#chartContainer1").CanvasJSChart(vertical); } </script> <h1>StartTime : <?php echo $time['1'];?> Record Length(sec) : <?php echo $sec['1'];?></h1> <div id="chartContainer2" style="height: 300px; width: 100%;"></div> <div id="chartContainer" style="height: 300px; width: 100%;"></div> <div id="chartContainer1" style="height: 300px; width: 100%;"></div> <script src="https://canvasjs.com/assets/script/jquery-1.11.1.min.js"></script> <script src="https://canvasjs.com/assets/script/jquery.canvasjs.min.js"></script> </body> </html> |