ctioga2 0.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.
Files changed (82) hide show
  1. data/COPYING +339 -0
  2. data/Changelog +6 -0
  3. data/bin/ctioga2 +26 -0
  4. data/lib/ctioga2/commands/arguments.rb +58 -0
  5. data/lib/ctioga2/commands/commands.rb +258 -0
  6. data/lib/ctioga2/commands/doc/doc.rb +118 -0
  7. data/lib/ctioga2/commands/doc/documentation-commands.rb +119 -0
  8. data/lib/ctioga2/commands/doc/help.rb +95 -0
  9. data/lib/ctioga2/commands/doc/html.rb +230 -0
  10. data/lib/ctioga2/commands/doc/introspection.rb +211 -0
  11. data/lib/ctioga2/commands/doc/man.rb +279 -0
  12. data/lib/ctioga2/commands/doc/markup.rb +359 -0
  13. data/lib/ctioga2/commands/general-commands.rb +119 -0
  14. data/lib/ctioga2/commands/general-types.rb +118 -0
  15. data/lib/ctioga2/commands/groups.rb +73 -0
  16. data/lib/ctioga2/commands/interpreter.rb +257 -0
  17. data/lib/ctioga2/commands/parsers/command-line.rb +187 -0
  18. data/lib/ctioga2/commands/parsers/file.rb +186 -0
  19. data/lib/ctioga2/commands/strings.rb +303 -0
  20. data/lib/ctioga2/commands/type.rb +100 -0
  21. data/lib/ctioga2/commands/variables.rb +101 -0
  22. data/lib/ctioga2/data/backends/backend.rb +260 -0
  23. data/lib/ctioga2/data/backends/backends.rb +39 -0
  24. data/lib/ctioga2/data/backends/backends/gnuplot.rb +140 -0
  25. data/lib/ctioga2/data/backends/backends/math.rb +121 -0
  26. data/lib/ctioga2/data/backends/backends/text.rb +335 -0
  27. data/lib/ctioga2/data/backends/description.rb +405 -0
  28. data/lib/ctioga2/data/backends/factory.rb +73 -0
  29. data/lib/ctioga2/data/backends/parameter.rb +109 -0
  30. data/lib/ctioga2/data/datacolumn.rb +245 -0
  31. data/lib/ctioga2/data/dataset.rb +233 -0
  32. data/lib/ctioga2/data/filters.rb +131 -0
  33. data/lib/ctioga2/data/merge.rb +43 -0
  34. data/lib/ctioga2/data/point.rb +72 -0
  35. data/lib/ctioga2/data/stack.rb +294 -0
  36. data/lib/ctioga2/graphics/coordinates.rb +73 -0
  37. data/lib/ctioga2/graphics/elements.rb +111 -0
  38. data/lib/ctioga2/graphics/elements/containers.rb +111 -0
  39. data/lib/ctioga2/graphics/elements/curve2d.rb +155 -0
  40. data/lib/ctioga2/graphics/elements/element.rb +90 -0
  41. data/lib/ctioga2/graphics/elements/primitive.rb +256 -0
  42. data/lib/ctioga2/graphics/elements/subplot.rb +140 -0
  43. data/lib/ctioga2/graphics/generator.rb +68 -0
  44. data/lib/ctioga2/graphics/legends.rb +108 -0
  45. data/lib/ctioga2/graphics/legends/area.rb +199 -0
  46. data/lib/ctioga2/graphics/legends/items.rb +183 -0
  47. data/lib/ctioga2/graphics/legends/provider.rb +58 -0
  48. data/lib/ctioga2/graphics/legends/storage.rb +65 -0
  49. data/lib/ctioga2/graphics/root.rb +209 -0
  50. data/lib/ctioga2/graphics/styles.rb +30 -0
  51. data/lib/ctioga2/graphics/styles/axes.rb +247 -0
  52. data/lib/ctioga2/graphics/styles/background.rb +122 -0
  53. data/lib/ctioga2/graphics/styles/base.rb +115 -0
  54. data/lib/ctioga2/graphics/styles/carrays.rb +53 -0
  55. data/lib/ctioga2/graphics/styles/curve.rb +101 -0
  56. data/lib/ctioga2/graphics/styles/drawable.rb +87 -0
  57. data/lib/ctioga2/graphics/styles/factory.rb +351 -0
  58. data/lib/ctioga2/graphics/styles/legend.rb +63 -0
  59. data/lib/ctioga2/graphics/styles/plot.rb +410 -0
  60. data/lib/ctioga2/graphics/styles/sets.rb +64 -0
  61. data/lib/ctioga2/graphics/styles/texts.rb +277 -0
  62. data/lib/ctioga2/graphics/subplot-commands.rb +141 -0
  63. data/lib/ctioga2/graphics/types.rb +188 -0
  64. data/lib/ctioga2/graphics/types/bijection.rb +79 -0
  65. data/lib/ctioga2/graphics/types/boundaries.rb +170 -0
  66. data/lib/ctioga2/graphics/types/boxes.rb +157 -0
  67. data/lib/ctioga2/graphics/types/dimensions.rb +157 -0
  68. data/lib/ctioga2/graphics/types/point.rb +247 -0
  69. data/lib/ctioga2/log.rb +97 -0
  70. data/lib/ctioga2/metabuilder/type.rb +316 -0
  71. data/lib/ctioga2/metabuilder/types.rb +39 -0
  72. data/lib/ctioga2/metabuilder/types/coordinates.rb +124 -0
  73. data/lib/ctioga2/metabuilder/types/dates.rb +43 -0
  74. data/lib/ctioga2/metabuilder/types/lists.rb +188 -0
  75. data/lib/ctioga2/metabuilder/types/numbers.rb +97 -0
  76. data/lib/ctioga2/metabuilder/types/strings.rb +93 -0
  77. data/lib/ctioga2/metabuilder/types/styles.rb +178 -0
  78. data/lib/ctioga2/plotmaker.rb +677 -0
  79. data/lib/ctioga2/postprocess.rb +115 -0
  80. data/lib/ctioga2/utils.rb +120 -0
  81. data/setup.rb +1586 -0
  82. metadata +144 -0
@@ -0,0 +1,131 @@
1
+ # stack.rb: the data stack
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
+ require 'ctioga2/data/datacolumn'
16
+ require 'ctioga2/data/backends/backends'
17
+ require 'ctioga2/data/backends/factory'
18
+
19
+ # This module contains all the classes used by ctioga
20
+ module CTioga2
21
+
22
+ Version::register_svn_info('$Revision: 82 $', '$Date: 2009-06-11 22:28:14 +0200 (Thu, 11 Jun 2009) $')
23
+
24
+
25
+ module Data
26
+
27
+ # A series of commands that can be used as "filters", as they act
28
+ # upon the last Dataset pushed unto the stack.
29
+ module Filters
30
+
31
+ FiltersGroup =
32
+ CmdGroup.new('filter', "Filters",
33
+ "The commands in this group act upon the last
34
+ dataset pushed unto the data stack: they can be viewed as filters.",
35
+ 101)
36
+
37
+ SortOperation =
38
+ Cmd.new("sort-last", nil, "--sort-last",
39
+ [], {}) do |plotmaker, opts|
40
+ plotmaker.data_stack.last.sort!
41
+ end
42
+
43
+ SortOperation.describe("Sorts the last dataset according to X values",
44
+ <<EOH, FiltersGroup)
45
+ Sorts the last dataset pushed unto the stack according to X values. Can be
46
+ used as a filter.
47
+
48
+ See also {command: sort}.
49
+ EOH
50
+
51
+ SortFilter =
52
+ Cmd.new("sort", nil, "--sort",
53
+ [], {}) do |plotmaker, opts|
54
+ plotmaker.data_stack.add_to_dataset_hook('sort-last()')
55
+ end
56
+
57
+ SortFilter.describe("Systematically sort subsequent datasets",
58
+ <<EOH, FiltersGroup)
59
+ Install the {command: sort-last} command as a dataset hook (see {command:
60
+ dataset-hook}): all subsequent datasets will be sorted according to
61
+ their X values.
62
+ EOH
63
+
64
+ TrimOperation =
65
+ Cmd.new("trim-last", nil, "--trim-last",
66
+ [CmdArg.new('integer')], {}) do |plotmaker, number, opts|
67
+ plotmaker.data_stack.last.trim!(number)
68
+ end
69
+
70
+ TrimOperation.describe("Only keeps every n points in the last dataset",
71
+ <<EOH, FiltersGroup)
72
+ Only keeps one every ? data point on the last dataset pushed unto the
73
+ data stack. Useful when data have too many points to avoid creating
74
+ heavy PDF files that take ages to display with no additional benefits.
75
+
76
+ This operation is very crude and does not average data.
77
+
78
+ See also {command: trim}.
79
+ EOH
80
+
81
+ TrimFilter =
82
+ Cmd.new("trim", nil, "--trim",
83
+ [CmdArg.new('integer')], {}) do |plotmaker, number, opts|
84
+ plotmaker.data_stack.add_to_dataset_hook("trim-last(#{number})")
85
+ end
86
+
87
+ TrimFilter.describe("Systematically trim subsequent datasets",
88
+ <<EOH, FiltersGroup)
89
+ Install the {command: trim-last} command as a dataset hook (see {command:
90
+ dataset-hook}): all subsequent datasets will be trimmed to keep only
91
+ every n point.
92
+ EOH
93
+
94
+
95
+ CherryPickOperation =
96
+ Cmd.new("cherry-pick-last", nil, "--cherry-pick-last",
97
+ [CmdArg.new('text')], {}) do |plotmaker, formula|
98
+ plotmaker.data_stack.last.select_formula!(formula)
99
+ end
100
+
101
+ CherryPickOperation.describe("Removes data from the last dataset for which the formula is false",
102
+ <<EOH, FiltersGroup)
103
+
104
+ Removes the data from the last dataset in the data stack for which the
105
+ formula returns false.
106
+
107
+ See also the {command: cherry-pick} command to apply the selection to
108
+ all datasets.
109
+
110
+ You might find it much easier to use the /where option of the
111
+ {command: plot} or {command: load} commands.
112
+ EOH
113
+
114
+ CherryPickFilter =
115
+ Cmd.new("cherry-pick", nil, "--cherry-pick",
116
+ [CmdArg.new('text')], {}) do |plotmaker, formula|
117
+ plotmaker.data_stack.add_to_dataset_hook("cherry-pick-last(#{formula})")
118
+ end
119
+
120
+ CherryPickFilter.describe("Systematicallly remove data for which the formula is false",
121
+ <<EOH, FiltersGroup)
122
+ Install the {command: cherry-pick-last} command as a dataset hook (see
123
+ {command: dataset-hook}): all points for which the formula returns
124
+ false for subsequent datasets will be removed.
125
+ EOH
126
+
127
+
128
+ end
129
+ end
130
+ end
131
+
@@ -0,0 +1,43 @@
1
+ # stack.rb: the data stack
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
+ require 'ctioga2/data/datacolumn'
16
+ require 'ctioga2/data/dataset'
17
+
18
+ # This module contains all the classes used by ctioga
19
+ module CTioga2
20
+
21
+ Version::register_svn_info('$Revision: 21 $', '$Date: 2009-04-30 14:11:53 +0200 (Thu, 30 Apr 2009) $')
22
+
23
+
24
+ module Data
25
+
26
+ # This module provides function to deal with the merging of
27
+ # several datasets.
28
+ module MergeDatasets
29
+
30
+ # Merges two or more datasets so that their X values match. If
31
+ # _prec_ isn't _nil_, it is a Float which must not be greater
32
+ # than the difference between two X values that should be
33
+ # regarded as equal.
34
+ #
35
+ # TODO !
36
+ def merge_datasets(prec, *datasets)
37
+
38
+ end
39
+
40
+ end
41
+ end
42
+ end
43
+
@@ -0,0 +1,72 @@
1
+ # point.rb: a point in a given dataset
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
+ require 'ctioga2/data/datacolumn'
16
+ require 'ctioga2/data/dataset'
17
+
18
+ module CTioga2
19
+
20
+ Version::register_svn_info('$Revision: 76 $', '$Date: 2009-06-03 01:44:44 +0200 (Wed, 03 Jun 2009) $')
21
+
22
+
23
+ module Data
24
+
25
+ # This class represents a datapoint, ie. an index in a given
26
+ # DataSet.
27
+ class DataPoint
28
+
29
+ # The Dataset object the point is in
30
+ attr_accessor :dataset
31
+
32
+ # The index of the data point within the Dataset
33
+ attr_accessor :index
34
+
35
+ # Creates a DataPoint with the given information.
36
+ def initialize(index, dataset)
37
+ end
38
+
39
+ # Creates a DataPoint object based on the following _text_
40
+ # specification. It needs a reference to a _plotmaker_, since it
41
+ # accesses the data stack.
42
+ #
43
+ # Specification: ({_dataset_})?(_relative_|@_index_)
44
+ def self.from_text(plotmaker, text)
45
+ if text =~ /^(?:\s*\{([^}]+)\})?\s*(?:([.\d]+)|@(\d+))\s*$/
46
+ which = $1 || -1
47
+ if $2
48
+ rel = Float($2)
49
+ else
50
+ idx = $3.to_i
51
+ end
52
+ dataset = plotmaker.data_stack.stored_dataset(which)
53
+ if ! dataset
54
+ raise "Invalid or empty dataset: #{which}"
55
+ end
56
+ if rel
57
+ idx = (rel * dataset.x.values.size).to_i
58
+ end
59
+ return DataPoint.new(dataset, idx)
60
+ else
61
+ raise "Not a valid datapoint specification: '#{text}'"
62
+ end
63
+ end
64
+ end
65
+
66
+ # TODO: functions returning xy values + slope for the given
67
+ # datapoint. For each, possibility to average over several points.
68
+
69
+ end
70
+
71
+ end
72
+
@@ -0,0 +1,294 @@
1
+ # stack.rb: the data stack
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
+ require 'ctioga2/data/datacolumn'
16
+ require 'ctioga2/data/dataset'
17
+ require 'ctioga2/data/backends/backends'
18
+ require 'ctioga2/data/backends/factory'
19
+
20
+ require 'ctioga2/data/point'
21
+
22
+
23
+ require 'ctioga2/data/filters'
24
+
25
+ # This module contains all the classes used by ctioga
26
+ module CTioga2
27
+
28
+ Version::register_svn_info('$Revision: 83 $', '$Date: 2009-06-11 23:18:35 +0200 (Thu, 11 Jun 2009) $')
29
+
30
+
31
+ module Data
32
+
33
+ # This is the central class for acquisition and handling of
34
+ # Dataset objects, retrieved from from a Backends::BackendFactory.
35
+ #
36
+ # TODO: provide real stack manipulation functions such as
37
+ #
38
+ # * interpolation: pops the last object from the stack and add its
39
+ # interpolated values on the element before.
40
+ # * mathematical functions on each column (DataColumn)
41
+ # * other stack-based operations.
42
+ class DataStack
43
+
44
+ include Log
45
+
46
+ # The array containing all the Dataset used so far.
47
+ attr_accessor :stack
48
+
49
+ # The BackendFactory used for retrieving data from named sets.
50
+ attr_accessor :backend_factory
51
+
52
+ # Named datasets
53
+ attr_accessor :named_datasets
54
+
55
+ # A hook executed every time a dataset is pushed unto the stack
56
+ # using #add_dataset.
57
+ #
58
+ # TODO: this string is parsed for each call to
59
+ # #add_dataset. Perhaps it would be good to provide a way to
60
+ # record a Command call, without parsing it from scratch ???
61
+ #
62
+ # Although, with variables, that could be interesting to reparse
63
+ # everytime, since any change in the variables would be taken
64
+ # into account.
65
+ attr_accessor :dataset_hook
66
+
67
+ # Creates a new DataStack object.
68
+ def initialize
69
+ @stack = Array.new
70
+
71
+ @named_datasets = Hash.new
72
+
73
+ # Defaults to the 'text' backend
74
+ @backend_factory = Data::Backends::BackendFactory.new('text')
75
+ end
76
+
77
+ # Performs expansion on the given _set_ with the current
78
+ # backend, retrieves corresponding Dataset objects, pushes them
79
+ # onto the stack and returns them.
80
+ #
81
+ # _options_ is a Hash that can contain the options available to the
82
+ # 'load' command:
83
+ #
84
+ # * 'name' to name each element added to the stack. A %d will be
85
+ # replaced by the number of the dataset within the ones just
86
+ # added.
87
+ #
88
+ # Additional members of the Hash are simply ignored.
89
+ def get_datasets(set, options = {})
90
+ backend = @backend_factory.current
91
+ retval = []
92
+ i = 0
93
+ for s in backend.expand_sets(set)
94
+ ds = backend.dataset(s)
95
+ add_dataset(ds, options['ignore_hooks'])
96
+
97
+ # Selection
98
+ if options['where']
99
+ ds.select_formula!(options['where'])
100
+ end
101
+
102
+ retval << ds
103
+ if options['name']
104
+ @named_datasets[options['name'] % [i]] = ds
105
+ end
106
+ i += 1
107
+ end
108
+ return retval
109
+ end
110
+
111
+ # Returns the stored dataset, either using its index in the
112
+ # stack, or its name in the dataset.
113
+ def stored_dataset(spec)
114
+ if spec.is_a? Numeric or spec =~ /^\s*-?\d+\s*$/
115
+ spec = spec.to_i
116
+ return @stack[spec]
117
+ else
118
+ if @named_datasets.key? spec
119
+ return @named_datasets[spec]
120
+ else
121
+ raise "Unkown named dataset from the stack: '#{spec}'"
122
+ end
123
+ end
124
+ end
125
+
126
+ # Gets a dataset from the given _options_ hash. If a 'which' key
127
+ # is present, it is used as an argument for #stored_dataset;
128
+ # else, -1 is used.
129
+ def specified_dataset(options)
130
+ spec = if options && options['which']
131
+ options['which']
132
+ else
133
+ -1
134
+ end
135
+ return stored_dataset(spec)
136
+ end
137
+
138
+ # Adds a Dataset object onto the stack, running hooks if
139
+ # necessary.
140
+ #
141
+ # Makes use of Plotmaker.plotmaker
142
+ def add_dataset(dataset, ignore_hooks = false)
143
+ @stack << dataset
144
+ if @dataset_hook && (! ignore_hooks)
145
+ # TODO: error handling
146
+ begin
147
+ PlotMaker.plotmaker.interpreter.run_commands(@dataset_hook)
148
+ rescue Exception => e
149
+ error "There was a problem running the dataset hook '#{@dataset_hook}', disabling it"
150
+ @dataset_hook = nil
151
+ info "-> '#{format_exception e}'"
152
+ end
153
+ end
154
+ end
155
+
156
+ # Appends a set of commands to the dataset hook
157
+ def add_to_dataset_hook(commands)
158
+ if @dataset_hook
159
+ @dataset_hook << "\n#{commands}"
160
+ else
161
+ @dataset_hook = commands
162
+ end
163
+ end
164
+
165
+ # Writes the contents of the the given _dataset_ (a DataSet
166
+ # object) to the given _io_ stream.
167
+ def print_dataset(dataset, io)
168
+ io.puts "# #{dataset.name}"
169
+ io.puts "# #{dataset.column_names.join("\t")}"
170
+ dataset.each_values do |i, *vals|
171
+ io.puts vals.join("\t")
172
+ end
173
+ end
174
+
175
+ # Pops the last _n_ datasets off the stack
176
+ def concatenate_datasets(n = 2)
177
+ ds = @stack.pop
178
+ raise "Nothing on the stack" unless ds
179
+ (n-1).times do
180
+ ds2 = @stack.pop
181
+ raise "Not enough datasets on the stack" unless ds2
182
+ ds << ds2
183
+ end
184
+ @stack.push(ds)
185
+ end
186
+
187
+ # Returns the last Dataset pushed onto the stack.
188
+ def last
189
+ return @stack.last
190
+ end
191
+
192
+
193
+ end
194
+
195
+ DataStackGroup =
196
+ CmdGroup.new('stack', "Data stack manipulation",
197
+ "Commands for manipulation of the data stack",
198
+ 100)
199
+
200
+ LoadDatasetOptions = {
201
+ 'name' => CmdArg.new('text'),
202
+ 'where' => CmdArg.new('text'),
203
+ 'ignore_hooks' => CmdArg.new('boolean')
204
+ }
205
+
206
+ LoadDataCommand =
207
+ Cmd.new("load", '-L', "--load",
208
+ [ CmdArg.new('dataset'), ],
209
+ LoadDatasetOptions) do |plotmaker, set, opts|
210
+ plotmaker.data_stack.get_datasets(set, opts)
211
+ end
212
+
213
+ LoadDataCommand.describe("Load given sets onto the data stack",
214
+ <<EOH, DataStackGroup)
215
+ Use the current backend to load the given dataset(s) onto the data stack.
216
+
217
+ If the name option is given, the last dataset loaded this way (if
218
+ dataset expansion occurs) gets named, or, if it contains a %d (or
219
+ similar construct), each dataset gets named with %d replace with the
220
+ number of the dataset within the expansion (starting at 0). This name
221
+ can be used to further use the dataset without remembering its
222
+ number. See the type {type: stored-dataset} for more information.
223
+
224
+ EOH
225
+
226
+
227
+ PrintLastCommand =
228
+ Cmd.new("print-dataset", '-P', "--print-dataset",
229
+ [], {'which' => CmdArg.new('stored-dataset')}) do |plotmaker,opts|
230
+ ds = plotmaker.data_stack.specified_dataset(opts)
231
+ plotmaker.data_stack.print_dataset(ds, STDOUT)
232
+ end
233
+
234
+ PrintLastCommand.describe("Prints the dataset last pushed on the stack",
235
+ <<EOH, DataStackGroup)
236
+ Prints to standard output data contained in the last dataset pushed
237
+ onto the stack, or the given stored dataset if the which option is given.
238
+ EOH
239
+
240
+ ConcatLastCommand =
241
+ Cmd.new("join-datasets", nil, "--join-datasets",
242
+ [], {'number' => CmdArg.new('integer')}) do |plotmaker, opts|
243
+ nb = opts['number'] || 2
244
+ plotmaker.data_stack.concatenate_datasets(nb)
245
+ end
246
+
247
+ ConcatLastCommand.describe("Concatenates the last datasets on the stack",
248
+ <<EOH, DataStackGroup)
249
+ Pops the last two (or number, if it is specified) datasets from the
250
+ stack, concatenates them (older last) and push them back onto the
251
+ stack.
252
+ EOH
253
+
254
+ SetDatasetHookCommand =
255
+ Cmd.new("dataset-hook", nil, "--dataset-hook",
256
+ [CmdArg.new('commands')], {}) do |plotmaker, commands, opts|
257
+ plotmaker.data_stack.dataset_hook = commands
258
+ end
259
+
260
+ SetDatasetHookCommand.describe("Sets the dataset hook",
261
+ <<EOH, DataStackGroup)
262
+ The dataset hook is a series of commands such as those in the command
263
+ files that are run every time after a dataset is added onto the data
264
+ stack. Its main use is to provide automatic filtering of data, but any
265
+ arbitrary command can be used, so enjoy !
266
+ EOH
267
+
268
+ ClearDatasetHookCommand =
269
+ Cmd.new("dataset-hook-clear", nil, "--dataset-hook-clear",
270
+ [], {}) do |plotmaker, opts|
271
+ plotmaker.data_stack.dataset_hook = nil
272
+ end
273
+
274
+ ClearDatasetHookCommand.describe("Clears the dataset hook",
275
+ <<EOH, DataStackGroup)
276
+ Clears the dataset hook. See {command: dataset-hook} for more information.
277
+ EOH
278
+
279
+ AddDatasetHookCommand =
280
+ Cmd.new("dataset-hook-add", nil, "--dataset-hook-add",
281
+ [CmdArg.new('commands')], {}) do |plotmaker, commands, opts|
282
+ plotmaker.data_stack.add_to_dataset_hook(commands)
283
+ end
284
+
285
+ AddDatasetHookCommand.describe("Adds commands to the dataset hook",
286
+ <<EOH, DataStackGroup)
287
+ Adds the given commands to the dataset hook. See {command: dataset-hook}
288
+ for more information about the dataset hook.
289
+ EOH
290
+
291
+ end
292
+
293
+ end
294
+