Created
March 11, 2012 14:33
-
-
Save niklas/2016620 to your computer and use it in GitHub Desktop.
434 Mhz grau
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PPo00011110101010001111111110000001o | |
PPo00011110101010001111111100000011o | |
PPo00011110101010001111111110000011o | |
PPo00011110101010001111111110000000o | |
PPo00011110101010001111111110000000o | |
PPo00011110101010001111111100000000o | |
PPo00011110101010001111111110000010o | |
{"1000"=>"0", "1110"=>"1", "1111"=>"P", "0000"=>"o"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 #!/usr/bin/env ruby | |
2 | |
3 require 'gnuplot' | |
4 | |
5 Pulse = 25 | |
6 | |
7 | |
8 def read_csv(filename) | |
9 points = File.read(filename).lines.grep(/^\d/).map do |line| | |
10 line.split(',')[1].to_f | |
11 end | |
12 points | |
13 end | |
14 | |
15 def normalize(points) | |
16 n = points.map do |v| | |
17 v > 2 ? 1 : 0 | |
18 end | |
19 n.shift while n.first == 0 | |
20 n | |
21 end | |
22 | |
23 def compress(points) | |
24 [].tap do |comp| | |
25 while !points.empty? | |
26 val = points.shift | |
27 count = 1 | |
28 while points.shift == val | |
29 count +=1 | |
30 end | |
31 comp << [val, count] | |
32 end | |
33 end | |
34 end | |
35 | |
36 def scale(points) | |
37 points.map do |val,count| | |
38 val.to_s * (count.to_f / Pulse).round | |
39 end | |
40 end | |
41 | |
42 | |
43 | |
44 | |
45 ARGV.each do |filename| | |
46 points = read_csv(filename) | |
47 points = normalize(points) | |
48 points = compress(points) | |
49 points = scale(points) | |
50 puts "#{filename} #{points.join}" | |
51 end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
measurements/tekwayWaveData173.csv 1111111100001000100010001110111011101110100011101000111010001110100010001000111011101110111011101110111011101110100010001000100010001000111000000 | |
measurements/tekwayWaveData174.csv 111111110000100010001000111011101110111010001110100011101000111010001000100011101110111011101110111011101110100010001000100010001000111011100000000 | |
measurements/tekwayWaveData175.csv 111111110000100010001000111011101110111010001110100011101000111010001000100011101110111011101110111011101110111010001000100010001000111011100000000 | |
measurements/tekwayWaveData176.csv 111111110000100010001000111011101110111010001110100011101000111010001000100011101110111011101110111011101110111010001000100010001000100010000000000 | |
measurements/tekwayWaveData177.csv 111111110000100010001000111011101110111010001110100011101000111010001000100011101110111011101110111011101110111010001000100010001000100010000000000 | |
measurements/tekwayWaveData178.csv 111111110000100010001000111011101110111010001110100011101000111010001000100011101110111011101110111011101110100010001000100010001000100010000000000 | |
measurements/tekwayWaveData179.csv 111111110000100010001000111011101110111010001110100011101000111010001000100011101110111011101110111011101110111010001000100010001000111010000000000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment