technical_graph 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/DOCUMENTATION.textile +374 -0
- data/README.md +35 -96
- data/VERSION +1 -1
- data/lib/technical_graph/array.rb +14 -0
- data/lib/technical_graph/data_layer.rb +42 -34
- data/lib/technical_graph/data_layer_processor.rb +24 -194
- data/lib/technical_graph/data_layer_processor_noise_removal.rb +90 -0
- data/lib/technical_graph/data_layer_processor_simple_smoother.rb +234 -0
- data/lib/technical_graph/data_point.rb +43 -0
- data/lib/technical_graph/graph_axis.rb +18 -6
- data/lib/technical_graph/graph_image_drawer.rb +8 -6
- data/lib/technical_graph.rb +0 -2
- data/test/test_technical_autocolor.rb +2 -1
- data/test/test_technical_axis_enlarge.rb +2 -1
- data/test/test_technical_graph.rb +20 -10
- data/test/test_technical_graph_axis.rb +12 -6
- data/test/test_technical_multilayer.rb +2 -1
- data/test/test_technical_noise_removal.rb +36 -0
- data/test/test_technical_readme.rb +207 -0
- data/test/test_technical_simple_graph.rb +2 -1
- data/test/test_technical_smoother.rb +18 -18
- data/test/test_technical_smoother_adv.rb +115 -0
- metadata +12 -4
@@ -77,7 +77,8 @@ class TestTechnicalAutocolor < Test::Unit::TestCase
|
|
77
77
|
@tg.add_layer(layer_data_d, layer_params_d)
|
78
78
|
|
79
79
|
|
80
|
-
@tg.layers.last.
|
80
|
+
@tg.layers.last.raw_data.size.should > 0
|
81
|
+
@tg.layers.last.processed_data.size.should > 0
|
81
82
|
@tg.layers.size.should == 4
|
82
83
|
|
83
84
|
@tg.render
|
@@ -53,7 +53,8 @@ class TestTechnicalAxisEnlarge < Test::Unit::TestCase
|
|
53
53
|
end
|
54
54
|
@tg.add_layer(layer_data, layer_params)
|
55
55
|
# should be added
|
56
|
-
@tg.layers.last.
|
56
|
+
@tg.layers.last.raw_data.size.should > 0
|
57
|
+
@tg.layers.last.processed_data.size.should > 0
|
57
58
|
# checking ranger for layer
|
58
59
|
|
59
60
|
@tg.render
|
@@ -52,7 +52,8 @@ class TestTechnicalGraph < Test::Unit::TestCase
|
|
52
52
|
@tg.layers.size.should == layers + 1
|
53
53
|
|
54
54
|
layer = @tg.layers.last
|
55
|
-
layer.
|
55
|
+
layer.raw_data.size.should == @data_size
|
56
|
+
layer.processed_data.size.should == @data_size
|
56
57
|
end
|
57
58
|
|
58
59
|
should 'has ability to manipulate layers, add more data' do
|
@@ -60,11 +61,13 @@ class TestTechnicalGraph < Test::Unit::TestCase
|
|
60
61
|
layer = @tg.layers.last
|
61
62
|
layer.class.should == DataLayer
|
62
63
|
|
63
|
-
layer.
|
64
|
+
layer.raw_data.size.should == @data_size
|
65
|
+
layer.processed_data.size.should == @data_size
|
64
66
|
|
65
67
|
# adding second data
|
66
68
|
layer.append_data(@second_data)
|
67
|
-
layer.
|
69
|
+
layer.raw_data.size.should == 2 * @data_size
|
70
|
+
layer.processed_data.size.should == 2 * @data_size
|
68
71
|
|
69
72
|
# @tg.render
|
70
73
|
# @tg.image.save_to_file('samples/tests/test1.png')
|
@@ -73,29 +76,36 @@ class TestTechnicalGraph < Test::Unit::TestCase
|
|
73
76
|
should 'has ability to filter records with similar x\'es' do
|
74
77
|
@tg.add_layer
|
75
78
|
layer = @tg.layers.last
|
76
|
-
layer.
|
79
|
+
layer.raw_data.size.should == 0
|
80
|
+
layer.processed_data.size.should == 0
|
77
81
|
layer.append_data([{ :x => 0, :y => 1 }])
|
78
|
-
layer.
|
82
|
+
layer.raw_data.size.should == 1
|
83
|
+
layer.processed_data.size.should == 1
|
79
84
|
|
80
85
|
# uniq check
|
81
86
|
layer.append_data([{ :x => 0, :y => 1 }])
|
82
87
|
layer.append_data([{ :x => 0, :y => 1 }])
|
83
|
-
layer.
|
88
|
+
layer.raw_data.size.should == 1
|
89
|
+
layer.processed_data.size.should == 1
|
84
90
|
layer.append_data([{ :x => 2, :y => 1 }])
|
85
|
-
layer.
|
91
|
+
layer.raw_data.size.should == 2
|
92
|
+
layer.processed_data.size.should == 2
|
86
93
|
end
|
87
94
|
|
88
95
|
should 'has ability to filter bad records' do
|
89
96
|
@tg.add_layer
|
90
97
|
layer = @tg.layers.last
|
91
|
-
layer.
|
98
|
+
layer.raw_data.size.should == 0
|
99
|
+
layer.processed_data.size.should == 0
|
92
100
|
layer.append_data([{ :x => 0, :y => 1 }])
|
93
|
-
layer.
|
101
|
+
layer.raw_data.size.should == 1
|
102
|
+
layer.processed_data.size.should == 1
|
94
103
|
|
95
104
|
# uniq check
|
96
105
|
layer.append_data([{ :z => 0, :y => 1 }])
|
97
106
|
layer.append_data([{}])
|
98
|
-
layer.
|
107
|
+
layer.raw_data.size.should == 1
|
108
|
+
layer.processed_data.size.should == 1
|
99
109
|
end
|
100
110
|
|
101
111
|
end
|
@@ -70,7 +70,8 @@ class TestTechnicalGraphAxis < Test::Unit::TestCase
|
|
70
70
|
]
|
71
71
|
@tg.add_layer(layer_data)
|
72
72
|
# should be added
|
73
|
-
@tg.layers.last.
|
73
|
+
@tg.layers.last.raw_data.size > 0
|
74
|
+
@tg.layers.last.processed_data.size > 0
|
74
75
|
# checking ranger for layer
|
75
76
|
|
76
77
|
@tg.render
|
@@ -100,7 +101,8 @@ class TestTechnicalGraphAxis < Test::Unit::TestCase
|
|
100
101
|
]
|
101
102
|
@tg.add_layer(layer_data)
|
102
103
|
# should be added
|
103
|
-
@tg.layers.last.
|
104
|
+
@tg.layers.last.raw_data.size > 1
|
105
|
+
@tg.layers.last.processed_data.size > 1
|
104
106
|
|
105
107
|
@tg.render
|
106
108
|
|
@@ -145,7 +147,8 @@ class TestTechnicalGraphAxis < Test::Unit::TestCase
|
|
145
147
|
]
|
146
148
|
@tg.add_layer(layer_data)
|
147
149
|
# should be added
|
148
|
-
@tg.layers.last.
|
150
|
+
@tg.layers.last.raw_data.size > 0
|
151
|
+
@tg.layers.last.processed_data.size > 0
|
149
152
|
# checking ranger for layer
|
150
153
|
|
151
154
|
@tg.render
|
@@ -212,7 +215,8 @@ class TestTechnicalGraphAxis < Test::Unit::TestCase
|
|
212
215
|
]
|
213
216
|
@tg.add_layer(layer_data)
|
214
217
|
# should be added
|
215
|
-
@tg.layers.last.
|
218
|
+
@tg.layers.last.raw_data.size > 0
|
219
|
+
@tg.layers.last.processed_data.size > 0
|
216
220
|
# checking ranger for layer
|
217
221
|
|
218
222
|
@tg.render
|
@@ -254,7 +258,8 @@ class TestTechnicalGraphAxis < Test::Unit::TestCase
|
|
254
258
|
]
|
255
259
|
@tg.add_layer(layer_data)
|
256
260
|
# should be added
|
257
|
-
@tg.layers.last.
|
261
|
+
@tg.layers.last.raw_data.size > 0
|
262
|
+
@tg.layers.last.processed_data.size > 0
|
258
263
|
# checking ranger for layer
|
259
264
|
|
260
265
|
@tg.render
|
@@ -292,7 +297,8 @@ class TestTechnicalGraphAxis < Test::Unit::TestCase
|
|
292
297
|
end
|
293
298
|
@tg.add_layer(layer_data)
|
294
299
|
# should be added
|
295
|
-
@tg.layers.last.
|
300
|
+
@tg.layers.last.raw_data.size > 0
|
301
|
+
@tg.layers.last.processed_data.size > 0
|
296
302
|
# checking ranger for layer
|
297
303
|
|
298
304
|
@tg.render
|
@@ -81,7 +81,8 @@ class TestTechnicalMultilayer < Test::Unit::TestCase
|
|
81
81
|
@tg.add_layer(layer_data_d, layer_params_d)
|
82
82
|
|
83
83
|
|
84
|
-
@tg.layers.last.
|
84
|
+
@tg.layers.last.raw_data.size.should > 0
|
85
|
+
@tg.layers.last.processed_data.size.should > 0
|
85
86
|
@tg.layers.size.should == 4
|
86
87
|
|
87
88
|
@tg.render
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestTechnicalNoiseRemoval < Test::Unit::TestCase
|
4
|
+
context 'basic noise (wrong data) removal' do
|
5
|
+
|
6
|
+
should 'do linear dry test' do
|
7
|
+
layer_data = Array.new
|
8
|
+
size = 100
|
9
|
+
(0..size).each do |i|
|
10
|
+
layer_data << { :x => i.to_f, :y => 5.0 }
|
11
|
+
end
|
12
|
+
# noise, spike
|
13
|
+
layer_data << { :x => 50.1, :y => 12.0 }
|
14
|
+
|
15
|
+
layer_params = {
|
16
|
+
:noise_removal => true,
|
17
|
+
:noise_removal_level => 3,
|
18
|
+
:noise_removal_window_size => 10,
|
19
|
+
}
|
20
|
+
|
21
|
+
dl = DataLayer.new(layer_data, layer_params)
|
22
|
+
dlp = DataLayerProcessor.new(dl)
|
23
|
+
|
24
|
+
dlp.noise_removal.should == true
|
25
|
+
dlp.noise_removal_level.should == 3
|
26
|
+
dlp.noise_removal_window_size.should == 10
|
27
|
+
|
28
|
+
# start only noise removal for test
|
29
|
+
#dlp.noise_removal_process
|
30
|
+
# start everything
|
31
|
+
dl.process!
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,207 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestTechnicalReadme < Test::Unit::TestCase
|
4
|
+
context 'generate sample graphs using readme options description' do
|
5
|
+
setup do
|
6
|
+
@simple_data_array = [
|
7
|
+
{ :x => 0, :y => 0 },
|
8
|
+
{ :x => 1, :y => 1 },
|
9
|
+
{ :x => 2, :y => 2 },
|
10
|
+
{ :x => 3, :y => 2 },
|
11
|
+
{ :x => 4, :y => 1 },
|
12
|
+
{ :x => 5, :y => 0 },
|
13
|
+
]
|
14
|
+
@simple_data_array_b = [
|
15
|
+
{ :x => 0.5, :y => 0.5 },
|
16
|
+
{ :x => 1.5, :y => 0.5 },
|
17
|
+
{ :x => 2.5, :y => 1.5 },
|
18
|
+
{ :x => 3.5, :y => 1.0 },
|
19
|
+
{ :x => 4.5, :y => 1.5 },
|
20
|
+
{ :x => 5.5, :y => 1.5 },
|
21
|
+
]
|
22
|
+
@float_data_array = [
|
23
|
+
{ :x => 0, :y => 0 },
|
24
|
+
{ :x => 0.111, :y => 0.123 },
|
25
|
+
{ :x => 1.222, :y => 1.456 },
|
26
|
+
{ :x => 1.333, :y => 2.8756 },
|
27
|
+
{ :x => 2.555, :y => 1.042 },
|
28
|
+
{ :x => 2.888, :y => 0.988 },
|
29
|
+
]
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
should 'create simplest graph' do
|
34
|
+
return # TODO remove it later, when all tests are done
|
35
|
+
@tg = TechnicalGraph.new
|
36
|
+
@tg.add_layer(@simple_data_array)
|
37
|
+
@tg.render
|
38
|
+
file_name = 'samples/readme/01_simplest.png'
|
39
|
+
@tg.image_drawer.save_to_file(file_name)
|
40
|
+
|
41
|
+
# test
|
42
|
+
@tg.image_drawer.to_png.class.should == String
|
43
|
+
File.exist?(file_name).should == true
|
44
|
+
end
|
45
|
+
|
46
|
+
#
|
47
|
+
should 'create 2-layer graph' do
|
48
|
+
return # TODO remove it later, when all tests are done
|
49
|
+
@tg = TechnicalGraph.new
|
50
|
+
@tg.add_layer(@simple_data_array)
|
51
|
+
@tg.add_layer(@simple_data_array_b)
|
52
|
+
@tg.render
|
53
|
+
file_name = 'samples/readme/02_two_layers.png'
|
54
|
+
@tg.image_drawer.save_to_file(file_name)
|
55
|
+
|
56
|
+
# test
|
57
|
+
@tg.image_drawer.to_png.class.should == String
|
58
|
+
File.exist?(file_name).should == true
|
59
|
+
end
|
60
|
+
|
61
|
+
#
|
62
|
+
should 'change ranges' do
|
63
|
+
return # TODO remove it later, when all tests are done
|
64
|
+
@tg = TechnicalGraph.new(
|
65
|
+
{
|
66
|
+
:x_min => -2,
|
67
|
+
:x_max => 10,
|
68
|
+
:y_min => -1,
|
69
|
+
:y_max => 10,
|
70
|
+
})
|
71
|
+
@tg.add_layer(@simple_data_array)
|
72
|
+
@tg.render
|
73
|
+
file_name = 'samples/readme/03_changed_ranges.png'
|
74
|
+
@tg.image_drawer.save_to_file(file_name)
|
75
|
+
|
76
|
+
# test
|
77
|
+
@tg.image_drawer.to_png.class.should == String
|
78
|
+
File.exist?(file_name).should == true
|
79
|
+
end
|
80
|
+
|
81
|
+
should 'change ranges (fixed)' do
|
82
|
+
return # TODO remove it later, when all tests are done
|
83
|
+
@tg = TechnicalGraph.new(
|
84
|
+
{
|
85
|
+
:x_min => 1,
|
86
|
+
:x_max => 2,
|
87
|
+
:y_min => 1,
|
88
|
+
:y_max => 2,
|
89
|
+
:xy_behaviour => :fixed
|
90
|
+
})
|
91
|
+
@tg.add_layer(@simple_data_array)
|
92
|
+
@tg.render
|
93
|
+
file_name = 'samples/readme/04_changed_ranges_fixed.png'
|
94
|
+
@tg.image_drawer.save_to_file(file_name)
|
95
|
+
|
96
|
+
# test
|
97
|
+
@tg.image_drawer.to_png.class.should == String
|
98
|
+
File.exist?(file_name).should == true
|
99
|
+
end
|
100
|
+
|
101
|
+
should 'fixed amount of axis' do
|
102
|
+
return # TODO remove it later, when all tests are done
|
103
|
+
@tg = TechnicalGraph.new(
|
104
|
+
{
|
105
|
+
:x_axis_fixed_interval => false,
|
106
|
+
:y_axis_fixed_interval => false,
|
107
|
+
:y_axis_count => 20,
|
108
|
+
:x_axis_count => 20,
|
109
|
+
})
|
110
|
+
@tg.add_layer(@simple_data_array)
|
111
|
+
@tg.render
|
112
|
+
file_name = 'samples/readme/05_axis_fixed_amount.png'
|
113
|
+
@tg.image_drawer.save_to_file(file_name)
|
114
|
+
|
115
|
+
# test
|
116
|
+
@tg.image_drawer.to_png.class.should == String
|
117
|
+
File.exist?(file_name).should == true
|
118
|
+
end
|
119
|
+
|
120
|
+
should 'fixed axis interval' do
|
121
|
+
return # TODO remove it later, when all tests are done
|
122
|
+
@tg = TechnicalGraph.new(
|
123
|
+
{
|
124
|
+
:x_axis_fixed_interval => true,
|
125
|
+
:y_axis_fixed_interval => true,
|
126
|
+
:y_axis_interval => 0.8,
|
127
|
+
:x_axis_interval => 0.6,
|
128
|
+
})
|
129
|
+
@tg.axis.x_axis_interval.should == 0.6
|
130
|
+
@tg.axis.y_axis_interval.should == 0.8
|
131
|
+
@tg.add_layer(@simple_data_array)
|
132
|
+
@tg.axis.x_axis_interval.should == 0.6
|
133
|
+
@tg.axis.y_axis_interval.should == 0.8
|
134
|
+
|
135
|
+
# axis_x = @tg.axis.calc_axis(@simple_data_array.first[:x], @simple_data_array.last[:x], 0.1, nil, true)
|
136
|
+
# axis_y = @tg.axis.calc_axis(@simple_data_array.first[:y], @simple_data_array.last[:y], 0.1, nil, true)
|
137
|
+
# puts axis_x.inspect
|
138
|
+
# puts axis_y.inspect
|
139
|
+
|
140
|
+
@tg.render
|
141
|
+
file_name = 'samples/readme/06_axis_fixed_interval.png'
|
142
|
+
@tg.image_drawer.save_to_file(file_name)
|
143
|
+
|
144
|
+
# test
|
145
|
+
@tg.image_drawer.to_png.class.should == String
|
146
|
+
File.exist?(file_name).should == true
|
147
|
+
end
|
148
|
+
|
149
|
+
should 'let choose axis label' do
|
150
|
+
return # TODO remove it later, when all tests are done
|
151
|
+
@tg = TechnicalGraph.new(
|
152
|
+
{
|
153
|
+
:x_axis_label => 'parameter',
|
154
|
+
:y_axis_label => 'value',
|
155
|
+
:axis_label_font_size => 36
|
156
|
+
})
|
157
|
+
@tg.add_layer(@simple_data_array)
|
158
|
+
@tg.render
|
159
|
+
file_name = 'samples/readme/07_axis_label.png'
|
160
|
+
@tg.image_drawer.save_to_file(file_name)
|
161
|
+
|
162
|
+
# test
|
163
|
+
@tg.image_drawer.to_png.class.should == String
|
164
|
+
File.exist?(file_name).should == true
|
165
|
+
end
|
166
|
+
|
167
|
+
|
168
|
+
should 'test truncate string' do
|
169
|
+
#return # TODO remove it later, when all tests are done
|
170
|
+
@tg = TechnicalGraph.new(
|
171
|
+
{
|
172
|
+
:truncate_string => "%.3f"
|
173
|
+
})
|
174
|
+
@layer_params = {
|
175
|
+
:value_labels => true
|
176
|
+
}
|
177
|
+
@tg.add_layer(@float_data_array, @layer_params)
|
178
|
+
@tg.render
|
179
|
+
file_name = 'samples/readme/08a_truncate_string.png'
|
180
|
+
@tg.image_drawer.save_to_file(file_name)
|
181
|
+
|
182
|
+
# test
|
183
|
+
@tg.image_drawer.to_png.class.should == String
|
184
|
+
File.exist?(file_name).should == true
|
185
|
+
end
|
186
|
+
|
187
|
+
should 'test truncate string 2' do
|
188
|
+
#return # TODO remove it later, when all tests are done
|
189
|
+
@tg = TechnicalGraph.new(
|
190
|
+
{
|
191
|
+
:truncate_string => "%.1f"
|
192
|
+
})
|
193
|
+
@layer_params = {
|
194
|
+
:value_labels => true
|
195
|
+
}
|
196
|
+
@tg.add_layer(@float_data_array, @layer_params)
|
197
|
+
@tg.render
|
198
|
+
file_name = 'samples/readme/08b_truncate_string.png'
|
199
|
+
@tg.image_drawer.save_to_file(file_name)
|
200
|
+
|
201
|
+
# test
|
202
|
+
@tg.image_drawer.to_png.class.should == String
|
203
|
+
File.exist?(file_name).should == true
|
204
|
+
end
|
205
|
+
|
206
|
+
end
|
207
|
+
end
|
@@ -49,7 +49,8 @@ class TestTechnicalSimpleGraph < Test::Unit::TestCase
|
|
49
49
|
end
|
50
50
|
@tg.add_layer(layer_data, layer_params)
|
51
51
|
# should be added
|
52
|
-
@tg.layers.last.
|
52
|
+
@tg.layers.last.raw_data.size.should > 0
|
53
|
+
@tg.layers.last.processed_data.size.should > 0
|
53
54
|
# checking ranger for layer
|
54
55
|
|
55
56
|
@tg.render
|
@@ -34,17 +34,17 @@ class TestTechnicalSmoother < Test::Unit::TestCase
|
|
34
34
|
|
35
35
|
should 'calculated vector has proper size and sum eq. 1.0' do
|
36
36
|
@processor.generate_vector.should.kind_of? Array
|
37
|
-
@processor.generate_vector.size.should == @processor.
|
37
|
+
@processor.generate_vector.size.should == @processor.simple_smoother_level
|
38
38
|
|
39
|
-
DataLayerProcessor::
|
40
|
-
@processor.
|
41
|
-
@processor.
|
39
|
+
DataLayerProcessor::SIMPLE_SMOOTHER_STRATEGIES.keys.each do |s|
|
40
|
+
@processor.simple_smoother_strategy = s
|
41
|
+
@processor.simple_smoother_strategy.should == s
|
42
42
|
|
43
43
|
(1...10).each do |i|
|
44
|
-
@processor.
|
45
|
-
@processor.
|
44
|
+
@processor.simple_smoother_level = i
|
45
|
+
@processor.simple_smoother_level.should == i
|
46
46
|
|
47
|
-
@processor.generate_vector.size.should == @processor.
|
47
|
+
@processor.generate_vector.size.should == @processor.simple_smoother_level
|
48
48
|
|
49
49
|
s = 0.0
|
50
50
|
@processor.generate_vector.each do |t|
|
@@ -59,17 +59,18 @@ class TestTechnicalSmoother < Test::Unit::TestCase
|
|
59
59
|
end
|
60
60
|
|
61
61
|
should 'processed data has the same size that old one' do
|
62
|
-
DataLayerProcessor::
|
63
|
-
@processor.
|
64
|
-
@processor.
|
62
|
+
DataLayerProcessor::SIMPLE_SMOOTHER_STRATEGIES.keys.each do |s|
|
63
|
+
@processor.simple_smoother_strategy = s
|
64
|
+
@processor.simple_smoother_strategy.should == s
|
65
65
|
(1...9).each do |i|
|
66
|
-
@processor.
|
67
|
-
@processor.
|
66
|
+
@processor.simple_smoother_level = i
|
67
|
+
@processor.simple_smoother_level.should == i
|
68
68
|
|
69
|
-
@processor.generate_vector.size.should == @processor.
|
69
|
+
@processor.generate_vector.size.should == @processor.simple_smoother_level
|
70
70
|
|
71
71
|
new_data = @processor.process
|
72
|
-
new_data.size.should == @data_layer.
|
72
|
+
new_data.size.should == @data_layer.raw_data.size
|
73
|
+
new_data.size.should == @data_layer.processed_data.size
|
73
74
|
|
74
75
|
# add as new layer
|
75
76
|
#@data_layer = DataLayer.new(@layer_data, @layer_params)
|
@@ -111,10 +112,9 @@ class TestTechnicalSmoother < Test::Unit::TestCase
|
|
111
112
|
|
112
113
|
# process and add
|
113
114
|
approx = layer_data_b = tg.layers[0].processor
|
114
|
-
approx.
|
115
|
-
approx.
|
116
|
-
|
117
|
-
|
115
|
+
approx.simple_smoother_strategy = :gauss
|
116
|
+
approx.simple_smoother_level = 9
|
117
|
+
|
118
118
|
layer_data_b = approx.process
|
119
119
|
layer_params_b = {
|
120
120
|
:antialias => false,
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestTechnicalSmootherAdv < Test::Unit::TestCase
|
4
|
+
context 'using additional X values in smoothing process' do
|
5
|
+
|
6
|
+
should 'calculate proper values' do
|
7
|
+
max = 2000
|
8
|
+
|
9
|
+
layer_data = Array.new
|
10
|
+
(0..max).each do |i|
|
11
|
+
x = -10.0 + (20.0 * i.to_f / max.to_f)
|
12
|
+
y = 10.0 * Math.cos(i.to_f * (2.0 * 3.14 / max.to_f))
|
13
|
+
|
14
|
+
y += rand * 4.0
|
15
|
+
x += rand * 1.5
|
16
|
+
|
17
|
+
layer_data << { :x => x, :y => y }
|
18
|
+
end
|
19
|
+
dl = DataLayer.new(layer_data)
|
20
|
+
dlp = DataLayerProcessor.new(dl)
|
21
|
+
|
22
|
+
level = 50
|
23
|
+
|
24
|
+
dlp.simple_smoother_strategy = :gauss
|
25
|
+
dlp.simple_smoother_level = level
|
26
|
+
dlp.simple_smoother_x = true
|
27
|
+
dlp.generate_vector
|
28
|
+
|
29
|
+
test_array = Array.new
|
30
|
+
x = 0.0
|
31
|
+
y = 2.0
|
32
|
+
level.times do
|
33
|
+
dp = DataPoint.xy(x, y + rand)
|
34
|
+
x += 1.0
|
35
|
+
test_array << dp
|
36
|
+
end
|
37
|
+
current_position = (test_array.size / 2.0).floor
|
38
|
+
current_position_point = test_array[current_position]
|
39
|
+
|
40
|
+
processed_yx = dlp.process_part_only_x(test_array, current_position_point)
|
41
|
+
processed_x = dlp.process_part_only_y(test_array)
|
42
|
+
|
43
|
+
puts processed_x.inspect
|
44
|
+
puts processed_yx.inspect
|
45
|
+
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
should 'create simple X smoothing' do
|
51
|
+
#return # TODO
|
52
|
+
|
53
|
+
tg = TechnicalGraph.new(
|
54
|
+
{
|
55
|
+
:width => 8000,
|
56
|
+
:height => 6000,
|
57
|
+
|
58
|
+
:legend => true,
|
59
|
+
:legend_auto => true,
|
60
|
+
:legend_width => 90,
|
61
|
+
:legend_margin => 60,
|
62
|
+
:legend_x => 50,
|
63
|
+
:legend_y => 50,
|
64
|
+
}
|
65
|
+
)
|
66
|
+
max = 2000
|
67
|
+
|
68
|
+
layer_data = Array.new
|
69
|
+
(0..max).each do |i|
|
70
|
+
x = -10.0 + (20.0 * i.to_f / max.to_f)
|
71
|
+
y = 10.0 * Math.cos(i.to_f * (2.0 * 3.14 / max.to_f))
|
72
|
+
|
73
|
+
y += rand * 4.0
|
74
|
+
x += rand * 1.5
|
75
|
+
|
76
|
+
layer_data << { :x => x, :y => y }
|
77
|
+
end
|
78
|
+
|
79
|
+
# adding simple layer
|
80
|
+
layer_params = {
|
81
|
+
:antialias => false,
|
82
|
+
:color => 'red',
|
83
|
+
:label => 'raw',
|
84
|
+
:value_labels => false,
|
85
|
+
:simple_smoother => false,
|
86
|
+
:simple_smoother_level => 1,
|
87
|
+
:simple_smoother_strategy => :gauss,
|
88
|
+
:simple_smoother_x => false
|
89
|
+
}
|
90
|
+
layer_params_c = layer_params.clone.merge(
|
91
|
+
{
|
92
|
+
:color => 'green',
|
93
|
+
:label => 'processed - level 100',
|
94
|
+
:simple_smoother_level => 100,
|
95
|
+
:simple_smoother => true
|
96
|
+
})
|
97
|
+
layer_params_d = layer_params_c.clone.merge(
|
98
|
+
{
|
99
|
+
:color => 'blue',
|
100
|
+
:simple_smoother_x => true
|
101
|
+
})
|
102
|
+
|
103
|
+
tg.add_layer(layer_data.clone, layer_params)
|
104
|
+
tg.add_layer(layer_data.clone, layer_params_c)
|
105
|
+
tg.add_layer(layer_data.clone, layer_params_d)
|
106
|
+
|
107
|
+
tg.render
|
108
|
+
tg.image_drawer.save_to_file('samples/tests/test_smoothing_x_values.png')
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: technical_graph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 1
|
10
|
+
version: 0.3.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Aleksander Kwiatkowski
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-10-
|
18
|
+
date: 2011-10-16 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -114,6 +114,7 @@ extra_rdoc_files:
|
|
114
114
|
- LICENSE.txt
|
115
115
|
- README.md
|
116
116
|
files:
|
117
|
+
- DOCUMENTATION.textile
|
117
118
|
- Gemfile
|
118
119
|
- Gemfile.lock
|
119
120
|
- LICENSE.txt
|
@@ -121,8 +122,12 @@ files:
|
|
121
122
|
- Rakefile
|
122
123
|
- VERSION
|
123
124
|
- lib/technical_graph.rb
|
125
|
+
- lib/technical_graph/array.rb
|
124
126
|
- lib/technical_graph/data_layer.rb
|
125
127
|
- lib/technical_graph/data_layer_processor.rb
|
128
|
+
- lib/technical_graph/data_layer_processor_noise_removal.rb
|
129
|
+
- lib/technical_graph/data_layer_processor_simple_smoother.rb
|
130
|
+
- lib/technical_graph/data_point.rb
|
126
131
|
- lib/technical_graph/graph_axis.rb
|
127
132
|
- lib/technical_graph/graph_color_library.rb
|
128
133
|
- lib/technical_graph/graph_data_processor.rb
|
@@ -133,8 +138,11 @@ files:
|
|
133
138
|
- test/test_technical_graph.rb
|
134
139
|
- test/test_technical_graph_axis.rb
|
135
140
|
- test/test_technical_multilayer.rb
|
141
|
+
- test/test_technical_noise_removal.rb
|
142
|
+
- test/test_technical_readme.rb
|
136
143
|
- test/test_technical_simple_graph.rb
|
137
144
|
- test/test_technical_smoother.rb
|
145
|
+
- test/test_technical_smoother_adv.rb
|
138
146
|
has_rdoc: true
|
139
147
|
homepage: http://github.com/akwiatkowski/technical_graph
|
140
148
|
licenses:
|