ctioga2 0.0 → 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. data/Changelog +25 -1
  2. data/lib/ctioga2/commands/commands.rb +13 -2
  3. data/lib/ctioga2/commands/doc/doc.rb +13 -17
  4. data/lib/ctioga2/commands/doc/documentation-commands.rb +14 -1
  5. data/lib/ctioga2/commands/doc/help.rb +136 -25
  6. data/lib/ctioga2/commands/doc/html.rb +56 -4
  7. data/lib/ctioga2/commands/doc/introspection.rb +45 -9
  8. data/lib/ctioga2/commands/doc/man.rb +7 -5
  9. data/lib/ctioga2/commands/doc/markup.rb +39 -12
  10. data/lib/ctioga2/commands/doc/wordwrap.rb +70 -0
  11. data/lib/ctioga2/commands/general-commands.rb +7 -4
  12. data/lib/ctioga2/commands/general-types.rb +27 -12
  13. data/lib/ctioga2/commands/interpreter.rb +2 -2
  14. data/lib/ctioga2/commands/parsers/command-line.rb +9 -5
  15. data/lib/ctioga2/commands/parsers/file.rb +5 -3
  16. data/lib/ctioga2/commands/type.rb +10 -3
  17. data/lib/ctioga2/commands/variables.rb +2 -2
  18. data/lib/ctioga2/data/backends/backend.rb +17 -15
  19. data/lib/ctioga2/data/backends/backends.rb +2 -2
  20. data/lib/ctioga2/data/backends/backends/gnuplot.rb +20 -5
  21. data/lib/ctioga2/data/backends/backends/math.rb +2 -2
  22. data/lib/ctioga2/data/backends/backends/text.rb +112 -17
  23. data/lib/ctioga2/data/backends/description.rb +10 -11
  24. data/lib/ctioga2/data/datacolumn.rb +73 -14
  25. data/lib/ctioga2/data/dataset.rb +305 -9
  26. data/lib/ctioga2/data/filters.rb +49 -1
  27. data/lib/ctioga2/data/indexed-dtable.rb +137 -0
  28. data/lib/ctioga2/data/point.rb +98 -7
  29. data/lib/ctioga2/data/stack.rb +98 -21
  30. data/lib/ctioga2/graphics/coordinates.rb +19 -2
  31. data/lib/ctioga2/graphics/elements.rb +12 -2
  32. data/lib/ctioga2/graphics/elements/containers.rb +14 -2
  33. data/lib/ctioga2/graphics/elements/contour.rb +67 -0
  34. data/lib/ctioga2/graphics/elements/curve2d.rb +103 -42
  35. data/lib/ctioga2/graphics/elements/element.rb +12 -2
  36. data/lib/ctioga2/graphics/elements/gradient-region.rb +94 -0
  37. data/lib/ctioga2/graphics/elements/parametric2d.rb +172 -0
  38. data/lib/ctioga2/graphics/elements/primitive.rb +37 -21
  39. data/lib/ctioga2/graphics/elements/region.rb +143 -0
  40. data/lib/ctioga2/graphics/elements/subplot.rb +92 -32
  41. data/lib/ctioga2/graphics/elements/tangent.rb +99 -0
  42. data/lib/ctioga2/graphics/elements/xyz-map.rb +126 -0
  43. data/lib/ctioga2/graphics/generator.rb +91 -6
  44. data/lib/ctioga2/graphics/legends.rb +26 -21
  45. data/lib/ctioga2/graphics/legends/area.rb +8 -8
  46. data/lib/ctioga2/graphics/legends/items.rb +5 -5
  47. data/lib/ctioga2/graphics/legends/storage.rb +4 -2
  48. data/lib/ctioga2/graphics/root.rb +24 -2
  49. data/lib/ctioga2/graphics/styles.rb +8 -0
  50. data/lib/ctioga2/graphics/styles/axes.rb +49 -23
  51. data/lib/ctioga2/graphics/styles/base.rb +2 -2
  52. data/lib/ctioga2/graphics/styles/carrays.rb +9 -2
  53. data/lib/ctioga2/graphics/styles/colormap.rb +272 -0
  54. data/lib/ctioga2/graphics/styles/curve.rb +64 -4
  55. data/lib/ctioga2/graphics/styles/drawable.rb +68 -9
  56. data/lib/ctioga2/graphics/styles/errorbar.rb +73 -0
  57. data/lib/ctioga2/graphics/styles/factory.rb +133 -17
  58. data/lib/ctioga2/graphics/styles/gradients.rb +60 -0
  59. data/lib/ctioga2/graphics/styles/location.rb +64 -0
  60. data/lib/ctioga2/graphics/styles/map-axes.rb +164 -0
  61. data/lib/ctioga2/graphics/styles/plot.rb +165 -62
  62. data/lib/ctioga2/graphics/styles/sets.rb +14 -1
  63. data/lib/ctioga2/graphics/styles/texts.rb +44 -34
  64. data/lib/ctioga2/graphics/subplot-commands.rb +94 -6
  65. data/lib/ctioga2/graphics/types.rb +113 -35
  66. data/lib/ctioga2/graphics/types/bijection.rb +3 -3
  67. data/lib/ctioga2/graphics/types/boundaries.rb +120 -1
  68. data/lib/ctioga2/graphics/types/dimensions.rb +8 -1
  69. data/lib/ctioga2/graphics/types/grid.rb +196 -0
  70. data/lib/ctioga2/graphics/types/location.rb +228 -0
  71. data/lib/ctioga2/graphics/types/point.rb +2 -2
  72. data/lib/ctioga2/log.rb +18 -18
  73. data/lib/ctioga2/metabuilder/type.rb +15 -3
  74. data/lib/ctioga2/metabuilder/types.rb +2 -2
  75. data/lib/ctioga2/metabuilder/types/coordinates.rb +13 -1
  76. data/lib/ctioga2/metabuilder/types/data.rb +50 -0
  77. data/lib/ctioga2/metabuilder/types/generic.rb +60 -0
  78. data/lib/ctioga2/metabuilder/types/lists.rb +53 -16
  79. data/lib/ctioga2/metabuilder/types/styles.rb +26 -45
  80. data/lib/ctioga2/plotmaker.rb +91 -20
  81. data/lib/ctioga2/postprocess.rb +8 -8
  82. data/lib/ctioga2/utils.rb +23 -4
  83. metadata +107 -75
  84. data/lib/ctioga2/data/merge.rb +0 -43
@@ -19,7 +19,7 @@ require 'ctioga2/data/backends/factory'
19
19
  # This module contains all the classes used by ctioga
20
20
  module CTioga2
21
21
 
22
- Version::register_svn_info('$Revision: 82 $', '$Date: 2009-06-11 22:28:14 +0200 (Thu, 11 Jun 2009) $')
22
+ Version::register_svn_info('$Revision: 194 $', '$Date: 2010-11-22 10:26:54 +0100 (Mon, 22 Nov 2010) $')
23
23
 
24
24
 
25
25
  module Data
@@ -81,6 +81,8 @@ EOH
81
81
  TrimFilter =
82
82
  Cmd.new("trim", nil, "--trim",
83
83
  [CmdArg.new('integer')], {}) do |plotmaker, number, opts|
84
+ ## @todo There should be a way to add commands in a type-safe
85
+ ## way, without having to convert to string first.
84
86
  plotmaker.data_stack.add_to_dataset_hook("trim-last(#{number})")
85
87
  end
86
88
 
@@ -124,6 +126,52 @@ Install the {command: cherry-pick-last} command as a dataset hook (see
124
126
  false for subsequent datasets will be removed.
125
127
  EOH
126
128
 
129
+ AverageDupOperation =
130
+ Cmd.new("avg-dup-last", nil, "--avg-dup-last",
131
+ [], {}) do |plotmaker|
132
+ plotmaker.data_stack.last.average_duplicates!
133
+ end
134
+
135
+ AverageDupOperation.describe("Average successive elements with identical X values",
136
+ <<EOH, FiltersGroup)
137
+ Averages successive points with identical X values. This algorithm is
138
+ naive with respect to the min/max values and averages them just as
139
+ well, whereas one might expect something more clever.
140
+
141
+ To average over identical X values when they are not successive in the
142
+ dataset, you might want to hand it over to {command: sort-last} first.
143
+
144
+ EOH
145
+
146
+ AverageDupFilter =
147
+ Cmd.new("avg-dup", nil, "--avg-dup",
148
+ [], {}) do |plotmaker, formula|
149
+ plotmaker.data_stack.add_to_dataset_hook("avg-dup-last()")
150
+ end
151
+
152
+ AverageDupFilter.describe("Systematicallly average successive elements with identical X values",
153
+ <<EOH, FiltersGroup)
154
+ Install the {command: avg-dup-last} command as a dataset hook (see
155
+ {command: dataset-hook}): all datasets acquired after this is on will
156
+ be averaged if they have identical successive values of X.
157
+ EOH
158
+
159
+
160
+ SmoothOperation =
161
+ Cmd.new("smooth-last", nil, "--smooth-last",
162
+ [CmdArg.new('integer')], {}) do |plotmaker, number|
163
+ plotmaker.data_stack.last.naive_smooth!(number)
164
+ end
165
+
166
+ SmoothOperation.describe("Smooths data using a gaussian filter",
167
+ <<EOH, FiltersGroup)
168
+ Smooth the data using a simple (naive even) gaussian filter. Good for
169
+ producing 'lines to guide the eye'
170
+ EOH
171
+
172
+
173
+
174
+
127
175
 
128
176
  end
129
177
  end
@@ -0,0 +1,137 @@
1
+ # indexed-dtable.rb: A Dtable object with non-uniform XY values
2
+ # copyright (c) 2009 by Vincent Fourmond
3
+
4
+ # This program is free software; you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2 of the License, or
7
+ # (at your option) any later version.
8
+
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details (in the COPYING file).
13
+
14
+ require 'ctioga2/utils'
15
+
16
+ module CTioga2
17
+
18
+ Version::register_svn_info('$Revision: 181 $', '$Date: 2010-10-27 15:18:35 +0200 (Wed, 27 Oct 2010) $')
19
+
20
+
21
+ module Data
22
+
23
+ # An indexed Dtable.
24
+ #
25
+ # This object represents an indexed Dtable, that is a Dtable with
26
+ # given values of X and Y (not necessarily uniform). Its main use
27
+ # is to get back a uniform (non-indexed) Dtable, for use with
28
+ # create_image
29
+ #
30
+ # An important information is that places where there was no data
31
+ # is implicitly represented as NaN
32
+ class IndexedDTable
33
+
34
+ # The underlying Dtable
35
+ attr_accessor :table
36
+
37
+ # X values
38
+ attr_accessor :x_values
39
+
40
+ # Y values
41
+ attr_accessor :y_values
42
+
43
+ def initialize(x, y, t)
44
+ @table = t
45
+ @x_values = x
46
+ @y_values = y
47
+ end
48
+
49
+ # Returns the XY boundaries of the object
50
+ def xy_boundaries
51
+ return Graphics::Types::Boundaries.bounds(@x_values, @y_values)
52
+ end
53
+
54
+ # Returns the value by which one should shift the X and Y
55
+ # positions of the borders of the images in order to get the
56
+ # points centered on their pixel (for a *uniform* grid !).
57
+ #
58
+ # While this correction looks better on non-uniform grids, it
59
+ # does not guarantee that it places all the points int the
60
+ # middle of their pixel, but that is still true for the ones at
61
+ # the border.
62
+ def xy_correction
63
+ return [(@x_values.last - @x_values.first)/ (2 * @x_values.size),
64
+ (@y_values.last - @y_values.first)/ (2 * @y_values.size)]
65
+ end
66
+
67
+ # Returns the coordinates of the lower-left XY values
68
+ def ll
69
+ return [@x_values.first, @y_values.first]
70
+ end
71
+
72
+ # Returns the coordinates of the lower-left XY values
73
+ def lr
74
+ return [@x_values.last, @y_values.first]
75
+ end
76
+
77
+ # Returns the coordinates of the upper-right XY values
78
+ def ur
79
+ return [@x_values.last, @y_values.last]
80
+ end
81
+
82
+ # Returns the coordinates of the upper-right XY values
83
+ def ul
84
+ return [@x_values.first, @y_values.last]
85
+ end
86
+
87
+ # Returns a hash ul,ll,lr with the corresponding values of the
88
+ # the points, with the correction applied if correction is true
89
+ def corner_positions(correction = true)
90
+ dict = {
91
+ 'll' => ll,
92
+ 'lr' => lr,
93
+ 'ul' => ul
94
+ }
95
+ if correction
96
+ dx, dy = *xy_correction
97
+ # This isn't really beautiful, but it just works.
98
+ dict['ll'][0] -= dx
99
+ dict['lr'][0] += dx
100
+ dict['ul'][0] -= dx
101
+
102
+ dict['ll'][1] -= dy
103
+ dict['lr'][1] -= dy
104
+ dict['ul'][1] += dy
105
+ end
106
+ return dict
107
+ end
108
+
109
+ def width
110
+ return @x_values.size
111
+ end
112
+
113
+ def height
114
+ return @y_values.size
115
+ end
116
+
117
+ # Returns a [xs, ys, gaps] triplet suitable for use with
118
+ # t.append_points_with_gaps_to_path to show the given level.
119
+ #
120
+ # @todo add algorithm choice too
121
+ def make_contour(level)
122
+ gaps = []
123
+ # Requires Tioga r598
124
+ xs, ys = *Tioga::FigureMaker.make_contour('data' => @table,
125
+ 'xs' => @x_values,
126
+ 'ys' => @y_values,
127
+ 'gaps' => gaps,
128
+ 'level' => level)
129
+ return [xs, ys, gaps]
130
+ end
131
+
132
+ end
133
+
134
+ end
135
+
136
+ end
137
+
@@ -1,11 +1,11 @@
1
1
  # point.rb: a point in a given dataset
2
2
  # copyright (c) 2009 by Vincent Fourmond
3
-
3
+
4
4
  # This program is free software; you can redistribute it and/or modify
5
5
  # it under the terms of the GNU General Public License as published by
6
6
  # the Free Software Foundation; either version 2 of the License, or
7
7
  # (at your option) any later version.
8
-
8
+
9
9
  # This program is distributed in the hope that it will be useful,
10
10
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
11
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -17,7 +17,7 @@ require 'ctioga2/data/dataset'
17
17
 
18
18
  module CTioga2
19
19
 
20
- Version::register_svn_info('$Revision: 76 $', '$Date: 2009-06-03 01:44:44 +0200 (Wed, 03 Jun 2009) $')
20
+ Version::register_svn_info('$Revision: 112 $', '$Date: 2009-11-09 22:34:12 +0100 (Mon, 09 Nov 2009) $')
21
21
 
22
22
 
23
23
  module Data
@@ -33,7 +33,9 @@ module CTioga2
33
33
  attr_accessor :index
34
34
 
35
35
  # Creates a DataPoint with the given information.
36
- def initialize(index, dataset)
36
+ def initialize(dataset,index)
37
+ @dataset = dataset
38
+ @index = index
37
39
  end
38
40
 
39
41
  # Creates a DataPoint object based on the following _text_
@@ -50,6 +52,7 @@ module CTioga2
50
52
  idx = $3.to_i
51
53
  end
52
54
  dataset = plotmaker.data_stack.stored_dataset(which)
55
+
53
56
  if ! dataset
54
57
  raise "Invalid or empty dataset: #{which}"
55
58
  end
@@ -61,11 +64,99 @@ module CTioga2
61
64
  raise "Not a valid datapoint specification: '#{text}'"
62
65
  end
63
66
  end
67
+
68
+ # @todo functions returning xy values + slope for the given
69
+ # datapoint. For each, possibility to average over several points.
70
+
71
+
72
+ # Returns the averaged X value around the datapoint
73
+ def x_val(navg = 3)
74
+
75
+ xvect = @dataset.x.values
76
+ di = (navg-1)/2
77
+ navg = 2*di + 1
78
+
79
+ idx = usable_index(di, xvect.size)
80
+
81
+ xval = 0
82
+ (idx-di).upto(idx+di) do |i|
83
+ xval += xvect[i]
84
+ end
85
+ return xval/(navg)
86
+ end
87
+
88
+
89
+ # Returns the averaged Y value around the datapoint
90
+ def y_val(navg = 3)
91
+ yvect = @dataset.y.values
92
+ di = (navg-1)/2
93
+ navg = 2*di + 1
94
+
95
+ idx = usable_index(di, yvect.size)
96
+
97
+ yval = 0
98
+ (idx-di).upto(idx+di) do |i|
99
+ yval += yvect[i]
100
+ end
101
+ return yval/(navg)
102
+ end
103
+
104
+ # Returns the value of the slope around the datapoint. This is
105
+ # obtained using a linear regression, so it should be rather
106
+ # reliable.
107
+ def slope(navg = 3)
108
+ xvect = @dataset.x.values
109
+ yvect = @dataset.y.values
110
+ di = (navg-1)/2
111
+ navg = 2*di + 1
112
+
113
+ idx = usable_index(di, xvect.size)
114
+
115
+ sx = 0
116
+ sxx = 0
117
+ sxy = 0
118
+ sy = 0
119
+
120
+ (idx-di).upto(idx+di) do |i|
121
+ sx += xvect[i]
122
+ sy += yvect[i]
123
+ sxx += xvect[i]**2
124
+ sxy += xvect[i] * yvect[i]
125
+ end
126
+ if sxx*navg == sx*sx
127
+ return 1
128
+ else
129
+ return (sxy * navg - sx*sy)/(sxx * navg - sx*sx)
130
+ end
131
+ end
132
+
133
+ ## Returns the average value of the difference between two
134
+ # consecutive X values
135
+ def dx(navg = 3)
136
+ xvect = @dataset.x.values
137
+ di = (navg-1)/2
138
+ navg = 2*di + 1
139
+
140
+ idx = usable_index(di, xvect.size)
141
+ return (xvect[idx+di]-xvect[idx-di])/navg
142
+ end
143
+
144
+
145
+ protected
146
+ # Makes sure the boudaries for averaging are fine
147
+ def usable_index(di, size)
148
+ # Boundary checks
149
+ if @index - di < 0
150
+ return di
151
+ elsif @index + di >= size
152
+ return size - 1 - di
153
+ end
154
+ return @index
155
+ end
156
+
157
+
64
158
  end
65
159
 
66
- # TODO: functions returning xy values + slope for the given
67
- # datapoint. For each, possibility to average over several points.
68
-
69
160
  end
70
161
 
71
162
  end
@@ -25,7 +25,7 @@ require 'ctioga2/data/filters'
25
25
  # This module contains all the classes used by ctioga
26
26
  module CTioga2
27
27
 
28
- Version::register_svn_info('$Revision: 83 $', '$Date: 2009-06-11 23:18:35 +0200 (Thu, 11 Jun 2009) $')
28
+ Version::register_svn_info('$Revision: 233 $', '$Date: 2011-01-20 10:26:42 +0100 (Thu, 20 Jan 2011) $')
29
29
 
30
30
 
31
31
  module Data
@@ -33,7 +33,7 @@ module CTioga2
33
33
  # This is the central class for acquisition and handling of
34
34
  # Dataset objects, retrieved from from a Backends::BackendFactory.
35
35
  #
36
- # TODO: provide real stack manipulation functions such as
36
+ # \todo provide real stack manipulation functions such as
37
37
  #
38
38
  # * interpolation: pops the last object from the stack and add its
39
39
  # interpolated values on the element before.
@@ -55,7 +55,7 @@ module CTioga2
55
55
  # A hook executed every time a dataset is pushed unto the stack
56
56
  # using #add_dataset.
57
57
  #
58
- # TODO: this string is parsed for each call to
58
+ # \todo this string is parsed for each call to
59
59
  # #add_dataset. Perhaps it would be good to provide a way to
60
60
  # record a Command call, without parsing it from scratch ???
61
61
  #
@@ -77,35 +77,39 @@ module CTioga2
77
77
  # Performs expansion on the given _set_ with the current
78
78
  # backend, retrieves corresponding Dataset objects, pushes them
79
79
  # onto the stack and returns them.
80
- #
81
- # _options_ is a Hash that can contain the options available to the
82
- # 'load' command:
80
+ def get_datasets(set, options = {})
81
+ backend = @backend_factory.current
82
+ sets = backend.expand_sets(set)
83
+ datasets = sets.map do |s|
84
+ backend.dataset(s)
85
+ end
86
+ add_datasets(datasets, options)
87
+ return datasets
88
+ end
89
+
90
+ # Adds a series of datasets, and perform various operations
91
+ # according to the hash _options_:
83
92
  #
84
93
  # * 'name' to name each element added to the stack. A %d will be
85
94
  # replaced by the number of the dataset within the ones just
86
95
  # added.
87
96
  #
88
97
  # Additional members of the Hash are simply ignored.
89
- def get_datasets(set, options = {})
90
- backend = @backend_factory.current
91
- retval = []
98
+ def add_datasets(datasets, options = {})
92
99
  i = 0
93
- for s in backend.expand_sets(set)
94
- ds = backend.dataset(s)
95
- add_dataset(ds, options['ignore_hooks'])
100
+ for ds in datasets
101
+ store_dataset(ds, options['ignore_hooks'])
96
102
 
97
103
  # Selection
98
104
  if options['where']
99
105
  ds.select_formula!(options['where'])
100
106
  end
101
107
 
102
- retval << ds
103
108
  if options['name']
104
109
  @named_datasets[options['name'] % [i]] = ds
105
110
  end
106
111
  i += 1
107
112
  end
108
- return retval
109
113
  end
110
114
 
111
115
  # Returns the stored dataset, either using its index in the
@@ -139,16 +143,16 @@ module CTioga2
139
143
  # necessary.
140
144
  #
141
145
  # Makes use of Plotmaker.plotmaker
142
- def add_dataset(dataset, ignore_hooks = false)
146
+ def store_dataset(dataset, ignore_hooks = false)
143
147
  @stack << dataset
144
148
  if @dataset_hook && (! ignore_hooks)
145
- # TODO: error handling
149
+ # \todo error handling
146
150
  begin
147
151
  PlotMaker.plotmaker.interpreter.run_commands(@dataset_hook)
148
152
  rescue Exception => e
149
- error "There was a problem running the dataset hook '#{@dataset_hook}', disabling it"
153
+ error { "There was a problem running the dataset hook '#{@dataset_hook}', disabling it" }
150
154
  @dataset_hook = nil
151
- info "-> '#{format_exception e}'"
155
+ info { "-> '#{format_exception e}'" }
152
156
  end
153
157
  end
154
158
  end
@@ -172,7 +176,7 @@ module CTioga2
172
176
  end
173
177
  end
174
178
 
175
- # Pops the last _n_ datasets off the stack
179
+ # Pops the last _n_ datasets off the stack and pushes back the
176
180
  def concatenate_datasets(n = 2)
177
181
  ds = @stack.pop
178
182
  raise "Nothing on the stack" unless ds
@@ -184,6 +188,17 @@ module CTioga2
184
188
  @stack.push(ds)
185
189
  end
186
190
 
191
+ # Merges the last datasets into a new one.
192
+ #
193
+ # Over
194
+ def merge_datasets(n = 2, columns = [0], precision = nil)
195
+ ds = @stack.pop
196
+ raise "Nothing on the stack" unless ds
197
+ datasets = @stack[-1..-(n-1)]
198
+ ds.merge_datasets_in(datasets, columns, precision)
199
+ @stack.push(ds)
200
+ end
201
+
187
202
  # Returns the last Dataset pushed onto the stack.
188
203
  def last
189
204
  return @stack.last
@@ -223,12 +238,43 @@ number. See the type {type: stored-dataset} for more information.
223
238
 
224
239
  EOH
225
240
 
241
+ ContourOptions = LoadDatasetOptions.dup.update({
242
+ 'which' => CmdArg.new('stored-dataset'),
243
+ })
244
+
245
+
246
+
247
+ MakeContourCommand =
248
+ Cmd.new("make-contour", nil, "--make-contour",
249
+ [ CmdArg.new('float'), ],
250
+ ContourOptions) do |plotmaker, level, opts|
251
+ ds = plotmaker.data_stack.specified_dataset(opts)
252
+ f = ds.make_contour(level)
253
+ name = "Level #{level} for plot '#{ds.name}'"
254
+ newds = Dataset.new(name, [f.x, f.y])
255
+ plotmaker.data_stack.add_datasets([newds], opts)
256
+ end
257
+
258
+ MakeContourCommand.describe("Pushes a contour on the data stack",
259
+ <<EOH, DataStackGroup)
260
+ EOH
261
+
262
+
263
+
226
264
 
227
265
  PrintLastCommand =
228
266
  Cmd.new("print-dataset", '-P', "--print-dataset",
229
- [], {'which' => CmdArg.new('stored-dataset')}) do |plotmaker,opts|
267
+ [], {
268
+ 'which' => CmdArg.new('stored-dataset'),
269
+ 'save' => CmdArg.new('file'),
270
+ }) do |plotmaker,opts|
230
271
  ds = plotmaker.data_stack.specified_dataset(opts)
231
- plotmaker.data_stack.print_dataset(ds, STDOUT)
272
+ if opts['save']
273
+ out = open(opts['save'], 'w')
274
+ else
275
+ out = STDOUT
276
+ end
277
+ plotmaker.data_stack.print_dataset(ds, out)
232
278
  end
233
279
 
234
280
  PrintLastCommand.describe("Prints the dataset last pushed on the stack",
@@ -251,6 +297,37 @@ stack, concatenates them (older last) and push them back onto the
251
297
  stack.
252
298
  EOH
253
299
 
300
+
301
+ MergeToLastCommand =
302
+ Cmd.new("merge-datasets", nil, "--merge-datasets",
303
+ [], {'number' => CmdArg.new('integer')}) do |plotmaker, opts|
304
+ nb = opts['number'] || 2
305
+ ## @todo all
306
+ plotmaker.data_stack.merge_datasets(nb)
307
+ end
308
+
309
+ MergeToLastCommand.describe("....",
310
+ <<EOH, DataStackGroup)
311
+ ....
312
+ EOH
313
+
314
+ XYReglinCommand =
315
+ Cmd.new("xy-reglin", nil, "--xy-reglin", [], {
316
+ 'which' => CmdArg.new('stored-dataset'),
317
+ 'linear' => CmdArg.new('boolean'),
318
+ }) do |plotmaker,opts|
319
+ stack = plotmaker.data_stack
320
+ ds = stack.specified_dataset(opts)
321
+ coeffs, lines = ds.reglin(opts)
322
+ stack.store_dataset(lines, true)
323
+ stack.store_dataset(coeffs, true)
324
+ end
325
+
326
+ XYReglinCommand.describe("....",
327
+ <<EOH, DataStackGroup)
328
+ ....
329
+ EOH
330
+
254
331
  SetDatasetHookCommand =
255
332
  Cmd.new("dataset-hook", nil, "--dataset-hook",
256
333
  [CmdArg.new('commands')], {}) do |plotmaker, commands, opts|