geoptima 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/csv_chart +42 -14
- data/bin/show_geoptima +1 -1
- data/examples/csv_chart.rb +42 -14
- data/examples/show_geoptima.rb +1 -1
- data/lib/geoptima/version.rb +1 -1
- metadata +3 -3
data/bin/csv_chart
CHANGED
@@ -6,14 +6,37 @@ $: << '../lib'
|
|
6
6
|
|
7
7
|
require 'geoptima/chart'
|
8
8
|
require 'geoptima/options'
|
9
|
+
require 'fileutils'
|
9
10
|
|
10
|
-
$
|
11
|
+
$export_dir = '.'
|
12
|
+
|
13
|
+
$files = Geoptima::Options.process_args do |option|
|
14
|
+
option.m {$merge_all = true}
|
15
|
+
option.D {$export_dir = ARGV.shift}
|
16
|
+
option.N {$merged_name = ARGV.shift}
|
17
|
+
end
|
18
|
+
|
19
|
+
FileUtils.mkdir_p $export_dir
|
20
|
+
|
21
|
+
$help = true unless($files.length>0)
|
22
|
+
if $help
|
23
|
+
puts <<EOHELP
|
24
|
+
Usage: csv_chart <-dhm> <-N name> <-D dir> files...
|
25
|
+
-d debug mode #{cw $debug}
|
26
|
+
-h print this help #{cw $help}
|
27
|
+
-m merge all files into single stats #{cw $merge_all}
|
28
|
+
-N use specified name for merged dataset: #{$merged_name}
|
29
|
+
-D export charts to specified directory: #{$export_dir}
|
30
|
+
Files to import: #{$files.join(', ')}
|
31
|
+
EOHELP
|
32
|
+
exit
|
33
|
+
end
|
11
34
|
|
12
35
|
class Stats
|
13
|
-
attr_reader :file, :
|
14
|
-
def initialize(file,
|
36
|
+
attr_reader :file, :name, :headers, :stats, :data
|
37
|
+
def initialize(file,name,fields)
|
15
38
|
@file = file
|
16
|
-
@
|
39
|
+
@name = name
|
17
40
|
@headers = fields
|
18
41
|
@stats = fields.map{|h| {}}
|
19
42
|
@data = fields.map{|h| []}
|
@@ -57,7 +80,10 @@ $stats = {}
|
|
57
80
|
|
58
81
|
$files.each do |file|
|
59
82
|
lines = 0
|
60
|
-
|
83
|
+
filename = File.basename(file)
|
84
|
+
(names = filename.split(/[_\.]/)).pop
|
85
|
+
name = $merged_name || names.join('_')
|
86
|
+
puts "About to read file #{file}"
|
61
87
|
File.open(file).each do |line|
|
62
88
|
lines += 1
|
63
89
|
fields=line.chomp.split(/\t/)
|
@@ -66,8 +92,10 @@ $files.each do |file|
|
|
66
92
|
fields.each_with_index do |field,index|
|
67
93
|
$stats[file].add(field,index)
|
68
94
|
end
|
95
|
+
elsif($merge_all && $stats.length>0)
|
96
|
+
file = $stats.values[0].file
|
69
97
|
else
|
70
|
-
$stats[file] = Stats.new(
|
98
|
+
$stats[file] = Stats.new(filename,name,fields)
|
71
99
|
end
|
72
100
|
end
|
73
101
|
end
|
@@ -78,33 +106,33 @@ $stats.each do |file,stats|
|
|
78
106
|
case header
|
79
107
|
when 'signal.strength'
|
80
108
|
Geoptima::Chart.draw_line_chart(
|
81
|
-
stats.
|
109
|
+
stats.name,
|
82
110
|
stats.data[0],
|
83
111
|
stats.data[index].map{|f| v=f.to_i; (v>-130 && v<0) ? v : nil},
|
84
112
|
:title => 'Signal Strength',
|
85
113
|
:maximum_value => -30,
|
86
114
|
:minimum_value => -130,
|
87
115
|
:width => 1024
|
88
|
-
).write("Chart_#{stats.
|
116
|
+
).write("#{$export_dir}/Chart_#{stats.name}_#{header}.png")
|
89
117
|
|
90
118
|
hist = stats.stats[index]
|
91
119
|
keys = hist.keys.sort{|a,b| a.to_i <=> b.to_i}
|
92
120
|
values = keys.map{|k| hist[k]}
|
93
121
|
Geoptima::Chart.draw_histogram_chart(
|
94
|
-
stats.
|
122
|
+
stats.name, keys, values,
|
95
123
|
:title => 'Signal Strength Distribution',
|
96
124
|
:width => 1024
|
97
|
-
).write("Chart_#{stats.
|
125
|
+
).write("#{$export_dir}/Chart_#{stats.name}_#{header}_distribution.png")
|
98
126
|
|
99
127
|
when 'Event'
|
100
128
|
hist = stats.stats[index]
|
101
129
|
keys = hist.keys.sort{|a,b| a.to_i <=> b.to_i}
|
102
130
|
values = keys.map{|k| hist[k]}
|
103
131
|
Geoptima::Chart.draw_category_chart(
|
104
|
-
stats.
|
132
|
+
stats.name, keys, values,
|
105
133
|
:title => "#{header} Distribution",
|
106
134
|
:width => 1024
|
107
|
-
).write("Chart_#{stats.
|
135
|
+
).write("#{$export_dir}/Chart_#{stats.name}_#{header}_distribution.png")
|
108
136
|
|
109
137
|
else
|
110
138
|
if stats.diverse?(index)
|
@@ -114,7 +142,7 @@ $stats.each do |file,stats|
|
|
114
142
|
hist = stats.stats[index]
|
115
143
|
keys = hist.keys.sort{|a,b| a.to_i <=> b.to_i}
|
116
144
|
values = keys.map{|k| hist[k]}
|
117
|
-
args = [stats.
|
145
|
+
args = [stats.name, keys, values, {
|
118
146
|
:title => "#{header} Distribution",
|
119
147
|
:width => 1024}]
|
120
148
|
g = (stats.length(index) > 50) ?
|
@@ -124,7 +152,7 @@ $stats.each do |file,stats|
|
|
124
152
|
(stats.length(index) > 1) ?
|
125
153
|
Geoptima::Chart.draw_category_chart(*args) :
|
126
154
|
nil
|
127
|
-
g && g.write("Chart_#{stats.
|
155
|
+
g && g.write("#{$export_dir}/Chart_#{stats.name}_#{header}_distribution.png")
|
128
156
|
end
|
129
157
|
end
|
130
158
|
end
|
data/bin/show_geoptima
CHANGED
data/examples/csv_chart.rb
CHANGED
@@ -6,14 +6,37 @@ $: << '../lib'
|
|
6
6
|
|
7
7
|
require 'geoptima/chart'
|
8
8
|
require 'geoptima/options'
|
9
|
+
require 'fileutils'
|
9
10
|
|
10
|
-
$
|
11
|
+
$export_dir = '.'
|
12
|
+
|
13
|
+
$files = Geoptima::Options.process_args do |option|
|
14
|
+
option.m {$merge_all = true}
|
15
|
+
option.D {$export_dir = ARGV.shift}
|
16
|
+
option.N {$merged_name = ARGV.shift}
|
17
|
+
end
|
18
|
+
|
19
|
+
FileUtils.mkdir_p $export_dir
|
20
|
+
|
21
|
+
$help = true unless($files.length>0)
|
22
|
+
if $help
|
23
|
+
puts <<EOHELP
|
24
|
+
Usage: csv_chart <-dhm> <-N name> <-D dir> files...
|
25
|
+
-d debug mode #{cw $debug}
|
26
|
+
-h print this help #{cw $help}
|
27
|
+
-m merge all files into single stats #{cw $merge_all}
|
28
|
+
-N use specified name for merged dataset: #{$merged_name}
|
29
|
+
-D export charts to specified directory: #{$export_dir}
|
30
|
+
Files to import: #{$files.join(', ')}
|
31
|
+
EOHELP
|
32
|
+
exit
|
33
|
+
end
|
11
34
|
|
12
35
|
class Stats
|
13
|
-
attr_reader :file, :
|
14
|
-
def initialize(file,
|
36
|
+
attr_reader :file, :name, :headers, :stats, :data
|
37
|
+
def initialize(file,name,fields)
|
15
38
|
@file = file
|
16
|
-
@
|
39
|
+
@name = name
|
17
40
|
@headers = fields
|
18
41
|
@stats = fields.map{|h| {}}
|
19
42
|
@data = fields.map{|h| []}
|
@@ -57,7 +80,10 @@ $stats = {}
|
|
57
80
|
|
58
81
|
$files.each do |file|
|
59
82
|
lines = 0
|
60
|
-
|
83
|
+
filename = File.basename(file)
|
84
|
+
(names = filename.split(/[_\.]/)).pop
|
85
|
+
name = $merged_name || names.join('_')
|
86
|
+
puts "About to read file #{file}"
|
61
87
|
File.open(file).each do |line|
|
62
88
|
lines += 1
|
63
89
|
fields=line.chomp.split(/\t/)
|
@@ -66,8 +92,10 @@ $files.each do |file|
|
|
66
92
|
fields.each_with_index do |field,index|
|
67
93
|
$stats[file].add(field,index)
|
68
94
|
end
|
95
|
+
elsif($merge_all && $stats.length>0)
|
96
|
+
file = $stats.values[0].file
|
69
97
|
else
|
70
|
-
$stats[file] = Stats.new(
|
98
|
+
$stats[file] = Stats.new(filename,name,fields)
|
71
99
|
end
|
72
100
|
end
|
73
101
|
end
|
@@ -78,33 +106,33 @@ $stats.each do |file,stats|
|
|
78
106
|
case header
|
79
107
|
when 'signal.strength'
|
80
108
|
Geoptima::Chart.draw_line_chart(
|
81
|
-
stats.
|
109
|
+
stats.name,
|
82
110
|
stats.data[0],
|
83
111
|
stats.data[index].map{|f| v=f.to_i; (v>-130 && v<0) ? v : nil},
|
84
112
|
:title => 'Signal Strength',
|
85
113
|
:maximum_value => -30,
|
86
114
|
:minimum_value => -130,
|
87
115
|
:width => 1024
|
88
|
-
).write("Chart_#{stats.
|
116
|
+
).write("#{$export_dir}/Chart_#{stats.name}_#{header}.png")
|
89
117
|
|
90
118
|
hist = stats.stats[index]
|
91
119
|
keys = hist.keys.sort{|a,b| a.to_i <=> b.to_i}
|
92
120
|
values = keys.map{|k| hist[k]}
|
93
121
|
Geoptima::Chart.draw_histogram_chart(
|
94
|
-
stats.
|
122
|
+
stats.name, keys, values,
|
95
123
|
:title => 'Signal Strength Distribution',
|
96
124
|
:width => 1024
|
97
|
-
).write("Chart_#{stats.
|
125
|
+
).write("#{$export_dir}/Chart_#{stats.name}_#{header}_distribution.png")
|
98
126
|
|
99
127
|
when 'Event'
|
100
128
|
hist = stats.stats[index]
|
101
129
|
keys = hist.keys.sort{|a,b| a.to_i <=> b.to_i}
|
102
130
|
values = keys.map{|k| hist[k]}
|
103
131
|
Geoptima::Chart.draw_category_chart(
|
104
|
-
stats.
|
132
|
+
stats.name, keys, values,
|
105
133
|
:title => "#{header} Distribution",
|
106
134
|
:width => 1024
|
107
|
-
).write("Chart_#{stats.
|
135
|
+
).write("#{$export_dir}/Chart_#{stats.name}_#{header}_distribution.png")
|
108
136
|
|
109
137
|
else
|
110
138
|
if stats.diverse?(index)
|
@@ -114,7 +142,7 @@ $stats.each do |file,stats|
|
|
114
142
|
hist = stats.stats[index]
|
115
143
|
keys = hist.keys.sort{|a,b| a.to_i <=> b.to_i}
|
116
144
|
values = keys.map{|k| hist[k]}
|
117
|
-
args = [stats.
|
145
|
+
args = [stats.name, keys, values, {
|
118
146
|
:title => "#{header} Distribution",
|
119
147
|
:width => 1024}]
|
120
148
|
g = (stats.length(index) > 50) ?
|
@@ -124,7 +152,7 @@ $stats.each do |file,stats|
|
|
124
152
|
(stats.length(index) > 1) ?
|
125
153
|
Geoptima::Chart.draw_category_chart(*args) :
|
126
154
|
nil
|
127
|
-
g && g.write("Chart_#{stats.
|
155
|
+
g && g.write("#{$export_dir}/Chart_#{stats.name}_#{header}_distribution.png")
|
128
156
|
end
|
129
157
|
end
|
130
158
|
end
|
data/examples/show_geoptima.rb
CHANGED
data/lib/geoptima/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geoptima
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 8
|
10
|
+
version: 0.0.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Craig Taverner
|