extcsv 0.11.3 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/gemspec CHANGED
@@ -2,8 +2,8 @@ require 'rubygems'
2
2
 
3
3
  spec = Gem::Specification.new do |s|
4
4
  s.name = "extcsv"
5
- s.version = "0.11.3"
6
- s.date = Time.new.to_s
5
+ s.version = "0.12.0"
6
+ s.date = Time.new.strftime("%Y-%m-%d")
7
7
  s.author = "Ralf Mueller"
8
8
  s.email = "stark.dreamdetective@gmail.com"
9
9
  s.homepage = "http://extcsv.rubyforge.org"
data/lib/extcsv.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'csv'
2
2
  require 'ostruct'
3
+ require 'extcsv_diagram'
3
4
 
4
5
  class Nil
5
6
  def to_s; ''; end
@@ -29,7 +30,7 @@ end
29
30
  # ==== License: BSD - see {license file}[http:/extcsv.rubyforge.org/svn/extcsv/trunk/LICENSE]
30
31
  ################################################################################
31
32
  class ExtCsv < OpenStruct
32
- VERSION = '0.11.0'
33
+ VERSION = '0.12.0'
33
34
 
34
35
  include Comparable
35
36
  include Enumerable
@@ -684,7 +685,11 @@ class ExtCsv < OpenStruct
684
685
  def ExtCsv.combine(obj, obj_=nil)
685
686
  obj.combine(obj_)
686
687
  end
687
- private :deep_copy, :deep_split, :set_separators, :parse_content, :change_time_format
688
+
689
+ def plot(*args)
690
+ ExtCsvDiagram.plot(self,*args)
691
+ end
692
+ private :deep_copy, :set_separators, :parse_content, :change_time_format
688
693
  end
689
694
 
690
695
  class ExtCsvExporter
@@ -3,6 +3,35 @@ require 'gnuplot'
3
3
  require 'win32ole' if RUBY_PLATFORM =~ /(win32|cygwin)/i
4
4
  require 'extcsv_units'
5
5
 
6
+ ################################################################################
7
+ # Author: Ralf Müller
8
+ #
9
+ # ==== TODO: Units are automatically selected from the column name. You could add
10
+ # units here and they will be used for graphs. I think, this is a premature
11
+ # solution, because the file will be edited by nearly every user, so it
12
+ # actually is a configutration file. But without units, the graphs loose much
13
+ # of their information. There are separate packages for units like
14
+ # units.rubyforge.org. But there will allways be the problem, that column names
15
+ # cannot be restricted to find a appropriate unit.
16
+ ################################################################################
17
+ module ExtCsvUnits
18
+ Units =
19
+ {
20
+ :col1 => "kV",
21
+ :col2 => "kV",
22
+ :col3 => "kV",
23
+ :col4 => "kV",
24
+ :col5 => "kV",
25
+ :col6 => "kV",
26
+ :col7 => "kV",
27
+ :col8 => "kV",
28
+ :zeit => "yyyy-mm-dd hh:mm:ss",
29
+ :time => "yyyy-mm-dd hh:mm:ss",
30
+ :depth => "m",
31
+ :Temp => "degC"
32
+ }
33
+ end
34
+ ################################################################################
6
35
  # This module provides separate plotting methods
7
36
  module ExtCsvDiagram
8
37
  include ExtCsvUnits
@@ -13,6 +42,7 @@ module ExtCsvDiagram
13
42
  :size => nil,
14
43
  :filename => nil,
15
44
  :title => nil,
45
+ :addSettings => [],
16
46
  :label_position => "left",
17
47
  :label? => true,
18
48
  :grid => true,
@@ -27,9 +57,10 @@ module ExtCsvDiagram
27
57
  :logscale => nil,
28
58
  :add_settings => [],
29
59
  :point_label? => false,
30
- :time_format => '"%d.%m\n%H:%M:%S"'
60
+ :output_time_format => '"%Y-%m-%d\n%H:%M:%S"',
61
+ :input_time_format => '"%Y-%m-%d\n%H:%M:%S"'
31
62
  }
32
- @@timeColumns = %w[time time_camera zeit]
63
+ @@timeColumns = %w[time time_camera zeit date datetime timestamp]
33
64
 
34
65
  def ExtCsvDiagram.set_pointlabel(obj, plot, x_col, x, y, label_col=nil, size='10')
35
66
  timemode = (%w[zeit zeitstempel time timestamp].include?(x_col.to_s))
@@ -68,14 +99,111 @@ module ExtCsvDiagram
68
99
  def ExtCsvDiagram.enhanceTitleByGroup(group_by,ob)
69
100
  title = ''
70
101
  group_by.each {|col|
71
- colunit = Units[col.to_sym].nil? ? col.to_s : "[#{Units[col.to_sym]}]"
72
- name = [ob.send(col)[0],colunit]
73
- title += (col.to_sym == :focus) ? name.reverse.join('') : name[0]
74
- title += " " unless col == group_by.last
102
+ unit = Units[col.to_sym]
103
+ colunit = unit.nil? ? col.to_s : unit
104
+ name = [ob.send(col)[0],colunit]
105
+ title += (col.to_sym != :focus) ? name.join('') : name[0]
106
+ title += " " unless col == group_by.last
75
107
  }
76
108
  title
77
109
  end
78
110
 
111
+ def ExtCsvDiagram.checkColumns(obj,*cols)
112
+ cols.each {|col|
113
+ next if col.kind_of?(Hash)
114
+ unless obj.datacolumns.include?(col)
115
+ print "[plot] Input data does NOT contain column '#{col.to_s}'\n"
116
+ raise ArgumentError
117
+ end
118
+ }
119
+ end
120
+
121
+ def ExtCsvDiagram.setRangeAndLabel(plot,options)
122
+ plot.xrange options[:xrange] unless options[:xrange].nil?
123
+ plot.yrange options[:yrange] unless options[:yrange].nil?
124
+ plot.xlabel options[:xlabel] unless options[:xlabel].nil?
125
+ plot.ylabel options[:ylabel] unless options[:ylabel].nil?
126
+ plot.x2range options[:x2range] unless options[:x2range].nil?
127
+ plot.y2range options[:y2range] unless options[:y2range].nil?
128
+ plot.x2label options[:x2label] unless options[:x2label].nil?
129
+ plot.y2label options[:y2label] unless options[:y2label].nil?
130
+ end
131
+ def ExtCsvDiagram.setXTimeAxis(plot,input_time_format,output_time_format,*xColumns)
132
+ xColumns.each_with_index {|xcol,i|
133
+ next if xcol.nil? or xcol.kind_of?(Hash)
134
+ if @@timeColumns.include?(xcol.to_s)
135
+ plot.timefmt input_time_format
136
+ if 0 == i
137
+ plot.xdata 'time'
138
+ plot.format 'x ' + output_time_format
139
+ else
140
+ plot.x2data 'time'
141
+ plot.format 'x2 ' + output_time_format
142
+ end
143
+ end
144
+ }
145
+ end
146
+
147
+ def ExtCsvDiagram.addSettings(plot,settings)
148
+ settings.each {|setting|
149
+ md = /^(\w+)/.match(setting)
150
+ plot.set(md[1],md.post_match) unless md.nil?
151
+ }
152
+ end
153
+
154
+ def ExtCsvDiagram.setKeys(plot,options)
155
+ plot.key options[:label_position]
156
+ plot.key 'off' unless options[:label?]
157
+ end
158
+
159
+ def ExtCsvDiagram.setOutput(plot,options)
160
+ size = (options[:size].nil?) ? '' : " size #{options[:size]}"
161
+ plot.terminal options[:terminal] + size
162
+ plot.output outputfilename + "." + options[:terminal].split(" ")[0]
163
+ end
164
+
165
+ def ExtCsvDiagram.addDataToPlot(plot,obj,xColumn,yColumn,groupBy,options)
166
+ x = obj.send(xColumn)
167
+ y = obj.send(yColumn)
168
+ title = enhanceTitleByGroup(groupBy,obj)
169
+ plot.data << Gnuplot::DataSet.new([x,y]) {|ds|
170
+ unit = Units[yColumn.to_sym].nil? ? '' : "[#{Units[yColumn.to_sym]}]"
171
+ ds.using = @@timeColumns.include?(xColumn.to_s) ? '1:3' : '1:2'
172
+ ds.with = options[:type]
173
+ ds.title = options[:onlyGroupTitle] ? "#{title}" : "#{yColumn} #{unit}, #{title}"
174
+ }
175
+ return [x,y]
176
+ end
177
+ def ExtCsvDiagram.plot_xy(obj,xColumn,yColumn,title,options={})
178
+ checkColumns(obj,xColumn,yColumn) unless options[:skipColumnCheck]
179
+ options = GRAPH_OPTIONS.merge(options)
180
+ outputfilename = (options[:filename].nil?) ? obj.filename : options[:filename]
181
+ groupBy = (options[:groupBy]).nil? ? [] : options[:groupBy]
182
+ Gnuplot.open {|gp|
183
+ Gnuplot::Plot.new(gp) {|plot|
184
+ plot.title "'" + title + "'"
185
+ setKeys(plot,options)
186
+
187
+ setOutput(plot,options) unless 'x11' == options[:terminal]
188
+
189
+ plot.grid if options[:grid]
190
+
191
+ addSettings(plot,options[:addSettings]) unless options[:addSettings].empty?
192
+
193
+ setRangeAndLabel(plot,options)
194
+
195
+ setXTimeAxis(plot,options[:input_time_format],options[:output_time_format],xColumn)
196
+
197
+ # Data for first x-axes
198
+ obj.split(*groupBy) {|obj|
199
+ x,y = ExtCsvDiagram.addDataToPlot(plot,obj,xColumn,yColumn,groupBy,options)
200
+
201
+ # set labels if requested
202
+ set_pointlabel(ob,plot, xColumn, x,y, options[:label_column],options[:label_fsize]) if options[:point_label?]
203
+ }
204
+ }
205
+ }
206
+ end
79
207
  def ExtCsvDiagram.plot(obj,
80
208
  group_by, # array[col0, ..., colN]
81
209
  x1_col,
@@ -84,9 +212,12 @@ module ExtCsvDiagram
84
212
  y2_cols=[],
85
213
  title='',
86
214
  options={})
87
-
88
- options = GRAPH_OPTIONS.merge(options)
215
+
216
+ ExtCsvDiagram.checkColumns(obj,*([group_by,x1_col,y1_cols,x2_col,y2_cols].flatten.uniq.compact))
217
+
218
+ options = GRAPH_OPTIONS.merge(options)
89
219
  outputfilename = (options[:filename].nil?) ? obj.filename : options[:filename]
220
+
90
221
  Gnuplot.open {|gp|
91
222
  Gnuplot::Plot.new(gp) {|plot|
92
223
  plot.title "'" + title + "'"
@@ -100,52 +231,23 @@ module ExtCsvDiagram
100
231
 
101
232
  plot.grid if options[:grid]
102
233
 
103
- options[:add_settings].each {|setting|
104
- md = /^(\w+)/.match(setting)
105
- plot.set(md[1],md.post_match) unless md.nil?
106
- }
234
+ addSettings(plot,options[:addSettings]) unless options[:addSettings].empty?
107
235
 
108
236
  # handling of axes
109
- plot.y2tics 'in' unless ( y2_cols.nil? or y2_cols.empty? )
110
- plot.x2tics 'in' unless ( (x2_col.respond_to?(:empty?) and x2_col.empty?) or x2_col == nil)
111
-
112
- plot.xrange options[:xrange] unless options[:xrange].nil?
113
- plot.yrange options[:yrange] unless options[:yrange].nil?
114
- plot.x2range options[:x2range] unless options[:x2range].nil?
115
- plot.y2range options[:y2range] unless options[:y2range].nil?
116
- plot.xlabel options[:xlabel] unless options[:xlabel].nil?
117
- plot.ylabel options[:ylabel] unless options[:ylabel].nil?
118
- plot.x2label options[:x2label] unless options[:x2label].nil?
119
- plot.y2label options[:y2label] unless options[:y2label].nil?
237
+ plot.y2tics 'in' unless ( y2_cols.nil? or y2_cols.empty? )
238
+ plot.x2tics 'in' unless ( x2_col.nil? or x2_col.kind_of?(Hash) )
120
239
 
240
+ setRangeAndLabel(plot,options)
121
241
 
122
- if @@timeColumns.include?(x1_col.to_s)
123
- plot.xdata 'time'
124
- plot.timefmt '"%Y-%m-%d %H:%M:%S"'
125
- plot.format 'x ' + options[:time_format]
126
- end
127
- if @@timeColumns.include?(x2_col.to_s)
128
- plot.x2data 'time'
129
- plot.timefmt '"%Y-%m-%d %H:%M:%S"'
130
- plot.format 'x2 ' + options[:time_format]
131
- end
242
+ setXTimeAxis(plot,options[:input_time_format],options[:output_time_format],x1_col,x2_col)
132
243
 
133
244
  # Data for first x-axes
134
245
  obj.split(*group_by) {|ob|
135
246
  y1_cols.each {|y_col|
136
- x = ob.send(x1_col)
137
- y = ob.send(y_col)
138
- title = enhanceTitleByGroup(group_by,ob)
139
- plot.data << Gnuplot::DataSet.new([x,y]) {|ds|
140
- unit = Units[y_col.to_sym].nil? ? '' : "[#{Units[y_col.to_sym]}]"
141
- ds.using = @@timeColumns.include?(x1_col.to_s) ? '1:3' : '1:2'
142
- ds.with = options[:type] + " axes x1y1 lw #{options[:linewidth]}"
143
- ds.title = options[:onlyGroupTitle] ? "#{title}" : "#{y_col} #{unit}, #{title}"
144
- }
247
+ x,y = ExtCsvDiagram.addDataToPlot(plot,ob,x1_col,y_col,group_by,options)
145
248
 
146
249
  # set labels if requested
147
250
  set_pointlabel(ob,plot, x1_col, x,y, options[:label_column],options[:label_fsize]) if options[:point_label?]
148
-
149
251
  }
150
252
  y2_cols.each {|y_col|
151
253
  x = ob.send(x1_col)
data/lib/lsmodel.rb CHANGED
File without changes
data/rakefile CHANGED
File without changes
data/test/data/file00.txt CHANGED
File without changes
data/test/data/file01.txt CHANGED
File without changes
data/test/data/file02.txt CHANGED
File without changes
data/test/data/file03.txt CHANGED
File without changes
data/test/data/file04.csv CHANGED
File without changes
data/test/data/file05.csv CHANGED
File without changes
data/test/test_extcsv.rb CHANGED
@@ -12,17 +12,16 @@ class ExtCsv
12
12
  def setmode(mode)
13
13
  @mode = mode
14
14
  end
15
- public :deep_split
16
15
  end
17
16
 
18
17
  class TestExtCsv < Test::Unit::TestCase
19
- TEST_DIR = "test/"
20
- TEST_DIR = ""
21
- TEST_DATA_DIR = TEST_DIR + "data/"
22
- TEST_DATA = TEST_DIR + "data/file00.txt"
23
- TEST_DATA_NEW = TEST_DIR + "data/file01.txt"
24
- TEST_FD_DATA = TEST_DATA_NEW
25
- ERG_CSV_DATA = TEST_DIR + "data/file04.csv"
18
+ TEST_DIR = "test/"
19
+ TEST_DATA_DIR = TEST_DIR + "data/"
20
+ TEST_DATA = TEST_DIR + "data/file00.txt"
21
+ TEST_DATA_NEW = TEST_DIR + "data/file01.txt"
22
+ TEST_DATA_GERMAN = TEST_DIR + "data/german.txt"
23
+ TEST_FD_DATA = TEST_DATA_NEW
24
+ ERG_CSV_DATA = TEST_DIR + "data/file04.csv"
26
25
  ERG_CSV_DATA_ = TEST_DIR + "data/file05.csv"
27
26
  ERG_CSV_DATA.freeze
28
27
  TEST_OUTOUT_DIR = TEST_DIR + "output"
@@ -31,6 +30,10 @@ class TestExtCsv < Test::Unit::TestCase
31
30
  test_simple = ExtCsv.new(IMPORT_TYPE,"txt",TEST_DATA)
32
31
  assert_equal("txt",test_simple.datatype)
33
32
  end
33
+ def test_respond
34
+ test_simple = ExtCsv.new(IMPORT_TYPE,"txt",TEST_DATA)
35
+ %w|step try col1 col2 col4|.each {|col| assert_respond_to(test_simple,col.to_sym)}
36
+ end
34
37
  def test_create_csv
35
38
  test_simple = ExtCsv.new(IMPORT_TYPE,"ssv",ERG_CSV_DATA)
36
39
  end
@@ -302,8 +305,6 @@ class TestExtCsv < Test::Unit::TestCase
302
305
  assert_equal(ExtCsv.concat(obj0, obj1),ExtCsv.concat(*[obj0, obj1]))
303
306
  newobj01 = ExtCsv.concat(obj0, obj1)
304
307
  assert_equal(228,newobj01.size)
305
- obj0.delete_field(:step)
306
- obj2.delete_field(:step)
307
308
  #pp obj0.rsize
308
309
  #pp obj2.rsize
309
310
  newobj02 = ExtCsv.concat(obj0, obj2)
@@ -494,7 +495,7 @@ class TestExtCsv < Test::Unit::TestCase
494
495
  assert_nil(csv + simple0)
495
496
  end
496
497
  def test_version
497
- assert_equal('0.11.0',ExtCsv::VERSION)
498
+ assert_equal('0.12.0',ExtCsv::VERSION)
498
499
  end
499
500
 
500
501
  def test_add
@@ -509,7 +510,7 @@ class TestExtCsv < Test::Unit::TestCase
509
510
  end
510
511
 
511
512
  def test_umlaut
512
- simple = ExtCsv.new(IMPORT_TYPE, "txt", "./data/german.txt")
513
+ simple = ExtCsv.new(IMPORT_TYPE, "txt", TEST_DATA_GERMAN)
513
514
  #pp simple
514
515
  end
515
516
  def test_columns
@@ -8,142 +8,113 @@ require 'pp'
8
8
  # Author:: Ralf M�ller
9
9
  ################################################################################
10
10
  class TestExtCsvDisplay < Test::Unit::TestCase
11
- # include ExtCsvDiagram
11
+ include ExtCsvDiagram
12
12
 
13
13
  TEST_DIR = "test"
14
14
  TEST_DATA = TEST_DIR + "/data/file00.txt"
15
15
  TEST_DATA_NEW = TEST_DIR + "/data/file01.txt"
16
16
  DATALOGGER_DATA = TEST_DIR + ""
17
17
  IMPORT_TYPE = "file"
18
+ ICON = "/home/ram/src/git/icon/experiments/xom.r8563.tsrel_R2B02_linDesity/xomFldminT.dat"
18
19
 
19
- def test_gnuplot
20
- test_file = TEST_DIR + ""
21
- drift_test_file = TEST_DIR + ""
22
- qpol = ExtCsv.new(IMPORT_TYPE,"txt",test_file)
23
- qpol_drift = ExtCsv.new(IMPORT_TYPE,"txt",drift_test_file)
24
- qpol.select_by(:col1 => "(5|4)").gnuplot("col1",
25
- ["col2"],
26
- :graph_title => "SIZEMODE",
27
- :point_label? => true,
28
- :label_positions => 'outside',
29
- :dataset_title => 'notitle',
30
- :mode => "size",
31
- :xrange => "[1.0:1.4]",
32
- :yrange => "[1.0:1.4]"
33
- )
34
- qpol.select_by(:col1 => 5).gnuplot("zeit",["col2"],:mode => "drift")
35
- qpol.select_by(:col1 => "5").gnuplot("col3",
36
- ["col7","col8"])
37
- qpol.select_by(:col2 => "5",:col3 => "(140|80)").gnuplot(
38
- "col4",
39
- ["col7","col8"],
40
- {
41
- :point_label? => true,
42
- :xrange => "[0:1200]",
43
- :label_position => "right",
44
- :datasets => {:using => [nil,'1:($2*10)']},
45
- :graph_title => "USING-TEST",
46
- :mode => "qp"
47
- }
48
- )
49
- qpol_drift.select_by(:col2 => "5").gnuplot(
50
- "zeit",
51
- ["col2","col3"],
52
- {
53
- :yrange => "[0.7:1.4]",
54
- :graph_title => "Plotted from one File",
55
- :mode => "drift",
56
- :time_format => "'%H:%M'"
57
- }
58
- )
59
- qpol_drift.select_by(:focus => "5").gnuplot(["zeit","zeit"],
60
- ["iqa","iqc"],
61
- {
62
- #:yrange => "[0.7:1.4]",
63
- :graph_title => "Multi-Graph",
64
- :mode => "multi",
65
- :label_column => "col5",
66
- :point_label? => true,
67
- :time_format => "'%H:%M'"
68
- })
69
- qpol_drift.select_by(:col2 => "5",:col4 => "120").operate_on(:col1,"*rand(10.0)").operate_on(:x2,"*10.2*rand(1.0)").operate_on(:z1,"/rand(8.0)").operate_on(:z2,"*rand(10.0)").gnuplot(["col1","col2"],["col1","col2"],
70
- :graph_type => 'vectors',
71
- :mode => "multi",
72
- :arrowstyle => " arrow 1 head filled size screen 0.2, 30, 45 ",
73
- :linewidth => "1",
74
- #:linetype => "rgb '#ffee33'",
75
- :dataset_title => ["t3","t1"],
76
- :drawBox => "0,0,5,5,gray,1",
77
- :drawCurve => "1,1,6,6,blue,2",
78
- :graph_title => "Multi-Vectors"
79
- ) #if false
80
- end
81
- def test_ExtCsv_gnuplot
82
- test_data = TEST_DIR + ""
83
- test_data = TEST_DIR + ""
84
- qpol = ExtCsv.new(IMPORT_TYPE,"txt",TEST_DATA).select_by(:col3 => "5",
85
- :col2 => "100")
86
- qpol_ = ExtCsv.new(IMPORT_TYPE,"txt",test_data).select_by(:col3 => "5",
87
- :col2 => "100")
88
- ExtCsv.gnuplot([qpol,qpol_],
89
- ["9416 Gen1","9416 Gen3"],
90
- "col1",
91
- ["col7","col8"])
92
- ExtCsv.gnuplot([qpol,qpol_],
93
- ["9416 Gen1","9416 Gen3"],
94
- "col1",
95
- ["col5"])
96
- end
97
-
98
- def _test_gnuplot_with_combined_qpols
99
- qpols_const = []
100
- qpols_kv_const = []
101
- qpols_ = []
102
- # mA = const
103
- drift_files = [ "test/data/file02.txt" , "test/data/file03.txt"]
104
- drift_files.each {|dfile|
105
- qpols_const << ExtCsv.new(IMPORT_TYPE,"txt",dfile).selectBy(:col4 => "5")
106
- }
107
-
108
- ExtCsv.gnuplot(qpols_const,
109
- ["Title0","Title1","Title2"],
110
- "zeit",
111
- ["col8","col7"],
112
- {:graph_type => "points",
113
- :graph_title => "Display more than one ExtCsv object"}
114
- )
115
- qpol = ExtCsv.concat(*qpols_ma_const)
116
- qpol.gnuplot("zeit",
117
- ["col2","col2"],
118
- { :mode => "drift",
119
- :yrange => "[0.7:1.4]",
120
- :graph_title => "Plotted from a combined Object: col2 = const"
121
- }
122
- )
123
- end
124
-
125
- def test_tube_diagram_labels
126
- erg_csv = ExtCsv.new("file","txt",TEST_DATA_NEW)[0..10]
127
- ExtCsvDiagram.plot(erg_csv,[],:col2,[:col7,:col8],'',[],'',:point_label? => true,:label_column => :string)
128
- end
129
- def test_extcsv_diagram_limits
130
- td = ExtCsv.new("file","txt",TEST_DATA_NEW)
131
- ExtCsvDiagram.plot(td[0,21],
132
- [:col1],
133
- :index,
134
- [:col3],
135
- :zeit,
136
- [:col8],
137
- 'limit test',
138
- :y1limits => [1.9],
139
- :y1limitname => "y1 Limit",
140
- :y2limits => [8.2],
141
- :y2limitname => "y2 Limit",
142
- :xlabel => "index",
143
- :ylabel => "YLabel",
144
- :y2label => "'Y2Label'",
145
- :label_position => "out horiz bot",
146
- :time_format => "'%H:%M'",
147
- :linewidth => 1)
148
- end
20
+ def test_simple
21
+ f=ExtCsv.new("file","txt",TEST_DATA)
22
+ ExtCsvDiagram.plot(f,["col4"],"col0",["col1"])
23
+ end
24
+ def test_icon
25
+ icon = ExtCsv.new(IMPORT_TYPE,"psv",ICON)
26
+
27
+
28
+
29
+
30
+
31
+ icon.datetime = []
32
+ icon.date.each_with_index{|date,i| icon.datetime << [date,icon.time[i]].join(' ') }
33
+
34
+ [:date,:time,:depth,:temp].each {|col| pp [col.to_s,icon.send(col).max].join('[max]: ') }
35
+ ExtCsvDiagram.plot_xy(icon,"datetime","temp",'ICON OCE_BASE (lin. Desity): Min. Tempratures at different depths',
36
+ :label_position => 'outside',:skipColumnCheck => true,
37
+ :type => 'lines',:groupBy => ["depth"],
38
+ :yrange => '[-2.5:0.5]',:onlyGroupTitle => true,
39
+ # :terminal => "png",
40
+ :input_time_format => "'%Y%m%d %H:%M:%S'",
41
+ :filename => "icon",:output_time_format => "'%Y'",:size => "800,600")
42
+
43
+ end
44
+ def test_plotxy
45
+ f = ExtCsv.new(IMPORT_TYPE,"txt",TEST_DATA)
46
+ ExtCsvDiagram.plot_xy(f,"step","col5",'test',
47
+ :label_position => 'outside',
48
+ :groupBy => [:col4],
49
+ :type => 'lines')
50
+ end
51
+ def test_gnuplot
52
+ test_file = TEST_DATA
53
+ drift_test_file = TEST_DATA_NEW
54
+ qpol = ExtCsv.new(IMPORT_TYPE,"txt",test_file)
55
+ qpol_drift = ExtCsv.new(IMPORT_TYPE,"txt",drift_test_file)
56
+
57
+ f = qpol.selectBy(:col4 => /(5|4)/)
58
+ assert_not_equal(0,f.size)
59
+ ExtCsvDiagram.plot(f,["col4"],"col1",
60
+ ["col5"],nil,[],'',
61
+ :graph_title => "SIZEMODE",
62
+ :point_label? => true,
63
+ :label_positions => 'outside',
64
+ :dataset_title => 'notitle',
65
+ :mode => "size" )
66
+ f = qpol_drift.selectBy(:col4 => 5)
67
+ f.plot([],"zeit",["col6"],:type => 'lines')
68
+ qpol.plot([],
69
+ "step",
70
+ ["col7","col8"],
71
+ {
72
+ :point_label? => true,
73
+ :xrange => "[0:1200]",
74
+ :label_position => "right",
75
+ :datasets => {:using => [nil,'1:($2*10)']},
76
+ :graph_title => "USING-TEST",
77
+ :mode => "qp" })
78
+ # qpol_drift.selectBy(:focus => "5").plot(["zeit","zeit"],
79
+ # ["iqa","iqc"],
80
+ # {
81
+ # #:yrange => "[0.7:1.4]",
82
+ # :graph_title => "Multi-Graph",
83
+ # :mode => "multi",
84
+ # :label_column => "col5",
85
+ # :point_label? => true,
86
+ # :time_format => "'%H:%M'"
87
+ # })
88
+ # qpol.selectBy(:col2 => "5",:col4 => "120").operate_on(:col1,"*rand(10.0)").operate_on(:x2,"*10.2*rand(1.0)").operate_on(:z1,"/rand(8.0)").operate_on(:z2,"*rand(10.0)").plot(["col1","col2"],["col1","col2"],
89
+ # :graph_type => 'vectors',
90
+ # :mode => "multi",
91
+ # :arrowstyle => " arrow 1 head filled size screen 0.2, 30, 45 ",
92
+ # :linewidth => "1",
93
+ # #:linetype => "rgb '#ffee33'",
94
+ # :dataset_title => ["t3","t1"],
95
+ # :drawBox => "0,0,5,5,gray,1",
96
+ # :drawCurve => "1,1,6,6,blue,2",
97
+ # :graph_title => "Multi-Vectors"
98
+ # ) #if false
99
+ end
100
+ def test_extcsv_diagram_limits
101
+ td = ExtCsv.new("file","txt",TEST_DATA_NEW)
102
+ ExtCsvDiagram.plot(td[0,21],
103
+ [:col1],
104
+ :index,
105
+ [:col3],
106
+ :zeit,
107
+ [:col8],
108
+ 'limit test',
109
+ :y1limits => [1.9],
110
+ :y1limitname => "y1 Limit",
111
+ :y2limits => [8.2],
112
+ :y2limitname => "y2 Limit",
113
+ :xlabel => "index",
114
+ :ylabel => "YLabel",
115
+ :y2label => "'Y2Label'",
116
+ :label_position => "out horiz bot",
117
+ :time_format => "'%H:%M'",
118
+ :linewidth => 1)
119
+ end
149
120
  end
data/test/test_lsmodel.rb CHANGED
File without changes
metadata CHANGED
@@ -1,34 +1,23 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: extcsv
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 11
8
- - 3
9
- version: 0.11.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.12.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Ralf Mueller
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2011-05-12 14:20:20 +02:00
18
- default_executable:
12
+ date: 2012-04-11 00:00:00.000000000 Z
19
13
  dependencies: []
20
-
21
14
  description:
22
15
  email: stark.dreamdetective@gmail.com
23
16
  executables: []
24
-
25
17
  extensions: []
26
-
27
18
  extra_rdoc_files: []
28
-
29
- files:
19
+ files:
30
20
  - lib/lsmodel.rb
31
- - lib/extcsv_units.rb
32
21
  - lib/extcsv_diagram.rb
33
22
  - lib/extcsv.rb
34
23
  - rakefile
@@ -44,39 +33,32 @@ files:
44
33
  - test/data/file03.txt
45
34
  - test/data/german.txt
46
35
  - test/data/file01.txt
47
- has_rdoc: true
48
36
  homepage: http://extcsv.rubyforge.org
49
37
  licenses: []
50
-
51
38
  post_install_message:
52
39
  rdoc_options: []
53
-
54
- require_paths:
40
+ require_paths:
55
41
  - lib
56
- required_ruby_version: !ruby/object:Gem::Requirement
42
+ required_ruby_version: !ruby/object:Gem::Requirement
57
43
  none: false
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- segments:
62
- - 0
63
- version: "0"
64
- required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
49
  none: false
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- segments:
70
- - 0
71
- version: "0"
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
72
54
  requirements: []
73
-
74
55
  rubyforge_project: extcsv
75
- rubygems_version: 1.3.7
56
+ rubygems_version: 1.8.17
76
57
  signing_key:
77
58
  specification_version: 3
78
- summary: "Let CSV-like files behave like DB-tables: selection, data operations on columns. Easy plotting with gnuplot and modelling"
79
- test_files:
59
+ summary: ! 'Let CSV-like files behave like DB-tables: selection, data operations on
60
+ columns. Easy plotting with gnuplot and modelling'
61
+ test_files:
80
62
  - test/test_lsmodel.rb
81
63
  - test/test_extcsv_diagram.rb
82
64
  - test/test_extcsv.rb
data/lib/extcsv_units.rb DELETED
@@ -1,26 +0,0 @@
1
- ################################################################################
2
- # Author: Ralf M�ller
3
- #
4
- # ==== TODO: Units are automatically selected from the column name. You could add
5
- # units here and they will be used for graphs. I think, this is a premature
6
- # solution, because the file will be edited by nearly every user, so it
7
- # actually is a configutration file. But without units, the graphs loose much
8
- # of their information. There are separate packages for units like
9
- # units.rubyforge.org. But there will allways be the problem, that column names
10
- # cannot be restricted to find a appropriate unit.
11
- ################################################################################
12
- module ExtCsvUnits
13
- Units =
14
- {
15
- :col1 => "kV",
16
- :col2 => "kV",
17
- :col3 => "kV",
18
- :col4 => "kV",
19
- :col5 => "kV",
20
- :col6 => "kV",
21
- :col7 => "kV",
22
- :col8 => "kV",
23
- :zeit => "yyyy-mm-dd hh:mm:ss",
24
- :time => "yyyy-mm-dd hh:mm:ss"
25
- }
26
- end