ctioga 1.11.1
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/COPYING +340 -0
- data/ctioga/bin/ctable +28 -0
- data/ctioga/bin/ctioga +37 -0
- data/ctioga/doc/ctable.1 +156 -0
- data/ctioga/doc/ctioga.1 +2363 -0
- data/ctioga/examples/README +46 -0
- data/ctioga/examples/ctioga.gnuplot +4 -0
- data/ctioga/examples/ctioga_within_tioga.rb +53 -0
- data/ctioga/examples/ctiogarc.rb +24 -0
- data/ctioga/examples/include_1.rb +15 -0
- data/ctioga/examples/noise.dat +100 -0
- data/ctioga/examples/noise.rb +13 -0
- data/ctioga/examples/trig.csv +100 -0
- data/ctioga/examples/trig.dat +100 -0
- data/ctioga/examples/trig.rb +14 -0
- data/ctioga/examples/trigh.dat +100 -0
- data/ctioga/examples/trigh.rb +10 -0
- data/ctioga/examples/tutorial +763 -0
- data/ctioga/examples/tutorial.sh +269 -0
- data/ctioga/tests/README +14 -0
- data/ctioga/tests/axes.sh +40 -0
- data/ctioga/tests/basic.sh +11 -0
- data/ctioga/tests/draw.sh +24 -0
- data/ctioga/tests/histograms.sh +14 -0
- data/ctioga/tests/insets.sh +41 -0
- data/ctioga/tests/layouts.sh +29 -0
- data/ctioga/tests/legends.sh +113 -0
- data/ctioga/tests/styles.sh +43 -0
- data/ctioga/tests/test_style.sh +8 -0
- data/ctioga/tests/tests.sh +24 -0
- data/ctioga/tests/text_backend.sh +83 -0
- data/ctioga/tests/tioga_defaults.rb +18 -0
- data/lib/CTioga/axes.rb +904 -0
- data/lib/CTioga/backends.rb +88 -0
- data/lib/CTioga/boundaries.rb +224 -0
- data/lib/CTioga/ctable.rb +134 -0
- data/lib/CTioga/curve_style.rb +246 -0
- data/lib/CTioga/debug.rb +199 -0
- data/lib/CTioga/dimension.rb +133 -0
- data/lib/CTioga/elements.rb +17 -0
- data/lib/CTioga/elements/base.rb +84 -0
- data/lib/CTioga/elements/containers.rb +578 -0
- data/lib/CTioga/elements/curves.rb +368 -0
- data/lib/CTioga/elements/tioga_primitives.rb +440 -0
- data/lib/CTioga/layout.rb +595 -0
- data/lib/CTioga/legends.rb +29 -0
- data/lib/CTioga/legends/cmdline.rb +187 -0
- data/lib/CTioga/legends/item.rb +164 -0
- data/lib/CTioga/legends/style.rb +257 -0
- data/lib/CTioga/log.rb +73 -0
- data/lib/CTioga/movingarrays.rb +131 -0
- data/lib/CTioga/partition.rb +271 -0
- data/lib/CTioga/plot_style.rb +230 -0
- data/lib/CTioga/plotmaker.rb +1677 -0
- data/lib/CTioga/shortcuts.rb +69 -0
- data/lib/CTioga/structures.rb +82 -0
- data/lib/CTioga/styles.rb +140 -0
- data/lib/CTioga/themes.rb +581 -0
- data/lib/CTioga/themes/classical.rb +82 -0
- data/lib/CTioga/themes/demo.rb +63 -0
- data/lib/CTioga/themes/fits.rb +91 -0
- data/lib/CTioga/themes/mono.rb +33 -0
- data/lib/CTioga/tioga.rb +32 -0
- data/lib/CTioga/utils.rb +173 -0
- data/lib/MetaBuilder/Parameters/dates.rb +38 -0
- data/lib/MetaBuilder/Parameters/lists.rb +132 -0
- data/lib/MetaBuilder/Parameters/numbers.rb +69 -0
- data/lib/MetaBuilder/Parameters/strings.rb +86 -0
- data/lib/MetaBuilder/Parameters/styles.rb +75 -0
- data/lib/MetaBuilder/Qt4/Parameters/dates.rb +51 -0
- data/lib/MetaBuilder/Qt4/Parameters/numbers.rb +65 -0
- data/lib/MetaBuilder/Qt4/Parameters/strings.rb +106 -0
- data/lib/MetaBuilder/Qt4/parameter.rb +172 -0
- data/lib/MetaBuilder/Qt4/parameters.rb +9 -0
- data/lib/MetaBuilder/descriptions.rb +603 -0
- data/lib/MetaBuilder/factory.rb +101 -0
- data/lib/MetaBuilder/group.rb +57 -0
- data/lib/MetaBuilder/metabuilder.rb +10 -0
- data/lib/MetaBuilder/parameter.rb +374 -0
- data/lib/MetaBuilder/parameters.rb +11 -0
- data/lib/MetaBuilder/qt4.rb +8 -0
- data/lib/SciYAG/Backends/backend.rb +379 -0
- data/lib/SciYAG/Backends/binner.rb +168 -0
- data/lib/SciYAG/Backends/cache.rb +102 -0
- data/lib/SciYAG/Backends/dataset.rb +158 -0
- data/lib/SciYAG/Backends/descriptions.rb +469 -0
- data/lib/SciYAG/Backends/filters.rb +25 -0
- data/lib/SciYAG/Backends/filters/average.rb +134 -0
- data/lib/SciYAG/Backends/filters/cumulate.rb +37 -0
- data/lib/SciYAG/Backends/filters/filter.rb +70 -0
- data/lib/SciYAG/Backends/filters/norm.rb +39 -0
- data/lib/SciYAG/Backends/filters/smooth.rb +63 -0
- data/lib/SciYAG/Backends/filters/sort.rb +43 -0
- data/lib/SciYAG/Backends/filters/strip.rb +34 -0
- data/lib/SciYAG/Backends/filters/trim.rb +64 -0
- data/lib/SciYAG/Backends/gnuplot.rb +131 -0
- data/lib/SciYAG/Backends/math.rb +108 -0
- data/lib/SciYAG/Backends/mdb.rb +462 -0
- data/lib/SciYAG/Backends/multitext.rb +96 -0
- data/lib/SciYAG/Backends/source.rb +64 -0
- data/lib/SciYAG/Backends/text.rb +339 -0
- data/lib/SciYAG/backends.rb +16 -0
- metadata +191 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# filters.rb : include file for filters
|
|
2
|
+
# Copyright (C) 2007 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.
|
|
13
|
+
|
|
14
|
+
# You should have received a copy of the GNU General Public License
|
|
15
|
+
# along with this program; if not, write to the Free Software
|
|
16
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17
|
+
|
|
18
|
+
require 'SciYAG/Backends/filters/filter'
|
|
19
|
+
require 'SciYAG/Backends/filters/smooth'
|
|
20
|
+
require 'SciYAG/Backends/filters/average'
|
|
21
|
+
require 'SciYAG/Backends/filters/sort'
|
|
22
|
+
require 'SciYAG/Backends/filters/trim'
|
|
23
|
+
require 'SciYAG/Backends/filters/cumulate'
|
|
24
|
+
require 'SciYAG/Backends/filters/norm'
|
|
25
|
+
require 'SciYAG/Backends/filters/strip'
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# smooth.rb : A simple averageing filter
|
|
2
|
+
# Copyright (C) 2006 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.
|
|
13
|
+
|
|
14
|
+
# You should have received a copy of the GNU General Public License
|
|
15
|
+
# along with this program; if not, write to the Free Software
|
|
16
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17
|
+
|
|
18
|
+
module SciYAG
|
|
19
|
+
|
|
20
|
+
module Backends
|
|
21
|
+
|
|
22
|
+
# A filter that sorts data and then averages the Y values of all the
|
|
23
|
+
# elements which have the same X value.
|
|
24
|
+
class AverageDupFilter < Filter
|
|
25
|
+
include Dobjects
|
|
26
|
+
|
|
27
|
+
describe "avgdup", "Average duplicates",
|
|
28
|
+
"Sorts the points according to the X values and average successive "+
|
|
29
|
+
"points with identical X values"
|
|
30
|
+
|
|
31
|
+
def initialize
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# There you go: a simple sorting/averaging filter.
|
|
35
|
+
def apply(f)
|
|
36
|
+
h = {}
|
|
37
|
+
for x,y in f
|
|
38
|
+
if h.key? x
|
|
39
|
+
h[x] << y
|
|
40
|
+
else
|
|
41
|
+
h[x] = [y]
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
nx = Dvector.new
|
|
46
|
+
ny = Dvector.new
|
|
47
|
+
for x in h.keys.sort
|
|
48
|
+
nx << x
|
|
49
|
+
y = 0
|
|
50
|
+
for a in h[x]
|
|
51
|
+
y += a
|
|
52
|
+
end
|
|
53
|
+
y/= h[x].size
|
|
54
|
+
ny << y
|
|
55
|
+
end
|
|
56
|
+
return Function.new(nx,ny)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# We simply replace the old vectors by the new ones.
|
|
60
|
+
def apply!(f)
|
|
61
|
+
new_f = apply(f)
|
|
62
|
+
f.x.replace(new_f.x)
|
|
63
|
+
f.y.replace(new_f.y)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
class StandardDeviationFilter < Filter
|
|
68
|
+
include Dobjects
|
|
69
|
+
|
|
70
|
+
describe "stddev", "Compute standard deviation",
|
|
71
|
+
"Averages successive elements with the same X value and compute standard deviation"
|
|
72
|
+
|
|
73
|
+
def initialize
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def apply(f)
|
|
77
|
+
last_x = nil
|
|
78
|
+
current_y = []
|
|
79
|
+
x_values = Dvector.new
|
|
80
|
+
y_values = []
|
|
81
|
+
f.x.size.times do |i|
|
|
82
|
+
xval = f.x[i]
|
|
83
|
+
if (last_x && xval == last_x)
|
|
84
|
+
current_y << f.y[i]
|
|
85
|
+
else
|
|
86
|
+
if last_x
|
|
87
|
+
y_values << current_y
|
|
88
|
+
x_values << last_x
|
|
89
|
+
end
|
|
90
|
+
current_y = [f.y[i]]
|
|
91
|
+
last_x = f.x[i]
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
if last_x
|
|
95
|
+
y_values << current_y
|
|
96
|
+
x_values << last_x
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
target_y = Dvector.new(x_values.size)
|
|
100
|
+
ymin = target_y.dup
|
|
101
|
+
ymax = target_y.dup
|
|
102
|
+
x_values.size.times do |i|
|
|
103
|
+
sum = 0.0
|
|
104
|
+
sq_sum = 0.0
|
|
105
|
+
for y in y_values[i]
|
|
106
|
+
sum += y
|
|
107
|
+
sq_sum += y**2
|
|
108
|
+
end
|
|
109
|
+
nb = y_values[i].size
|
|
110
|
+
target_y[i] = sum/nb
|
|
111
|
+
stddev = Math::sqrt((sq_sum/nb) - target_y[i]**2)
|
|
112
|
+
ymin[i] = target_y[i] - stddev
|
|
113
|
+
ymax[i] = target_y[i] + stddev
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
errors = f.errors.dup.merge!({:ymin => ymin, :ymax => ymax,
|
|
117
|
+
:x => x_values, :y => target_y})
|
|
118
|
+
|
|
119
|
+
return DataSet2D.new(f.creation_context,
|
|
120
|
+
Function.new(x_values, target_y),
|
|
121
|
+
errors, f.meta_data)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# We simply replace the old vectors by the new ones.
|
|
125
|
+
def apply!(f)
|
|
126
|
+
new_f = apply(f)
|
|
127
|
+
f.x.replace(new_f.x)
|
|
128
|
+
f.y.replace(new_f.y)
|
|
129
|
+
f.errors = new_f.errors
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
end
|
|
134
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# cumulate.rb : A simple cumulative filter
|
|
2
|
+
# Copyright (C) 2007 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.
|
|
13
|
+
|
|
14
|
+
# You should have received a copy of the GNU General Public License
|
|
15
|
+
# along with this program; if not, write to the Free Software
|
|
16
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17
|
+
|
|
18
|
+
module SciYAG
|
|
19
|
+
|
|
20
|
+
module Backends
|
|
21
|
+
|
|
22
|
+
# Removes a given ratio of points
|
|
23
|
+
class CumulateFilter < Filter
|
|
24
|
+
include Dobjects
|
|
25
|
+
|
|
26
|
+
describe "cumulate", "Cumulate", "Cumulate the Y values of the points"
|
|
27
|
+
|
|
28
|
+
def apply!(f)
|
|
29
|
+
y = 0
|
|
30
|
+
f.y.size.times do |i|
|
|
31
|
+
y += f.y[i]
|
|
32
|
+
f.y[i] = y
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# filter.rb : The base class for filters
|
|
2
|
+
# Copyright (C) 2006 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.
|
|
13
|
+
|
|
14
|
+
# You should have received a copy of the GNU General Public License
|
|
15
|
+
# along with this program; if not, write to the Free Software
|
|
16
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
module SciYAG
|
|
20
|
+
|
|
21
|
+
module Backends
|
|
22
|
+
|
|
23
|
+
# The base class for filters. Just an interface, in the java meaning of
|
|
24
|
+
# the term. A filter just provides a function to apply itself.
|
|
25
|
+
class Filter
|
|
26
|
+
# Import the main description functions into the appropriate
|
|
27
|
+
# namespaces
|
|
28
|
+
extend Descriptions::DescriptionExtend
|
|
29
|
+
include Descriptions::DescriptionInclude
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def initialize
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Creates a description object with the given texts and associates
|
|
36
|
+
# it with the class. To be used in Filter subclasses, simply this way:
|
|
37
|
+
#
|
|
38
|
+
# describe "biniou", "Biniou filter", "A filter to take out Binious"
|
|
39
|
+
#
|
|
40
|
+
# Please remember also that if you don't set a description for
|
|
41
|
+
# your Filter, it will most likely be of no use to anyone...
|
|
42
|
+
|
|
43
|
+
def Filter.describe(name, longname, desc)
|
|
44
|
+
d = FilterDescription.new(self,name, longname, desc)
|
|
45
|
+
set_description(d)
|
|
46
|
+
register_description(d)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Gets a Function (or assimilate ?) and applies the filter on them.
|
|
50
|
+
# The functions *should not modify any data in ary*.
|
|
51
|
+
# By default, the mechanism is to make a copy of the data and apply
|
|
52
|
+
# apply! on it.
|
|
53
|
+
def apply(a)
|
|
54
|
+
f = Dobjects::Function.new(a.x.dup, a.y.dup)
|
|
55
|
+
apply!(f)
|
|
56
|
+
return f
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# This version modifies directly the Function inside the +f+.
|
|
60
|
+
def apply!(func)
|
|
61
|
+
return func
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Specializes Descriptions for filters
|
|
66
|
+
class FilterDescription < Descriptions::Description
|
|
67
|
+
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# norm.rb : normalizing data to 1
|
|
2
|
+
# Copyright (C) 2006 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.
|
|
13
|
+
|
|
14
|
+
# You should have received a copy of the GNU General Public License
|
|
15
|
+
# along with this program; if not, write to the Free Software
|
|
16
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17
|
+
|
|
18
|
+
module SciYAG
|
|
19
|
+
|
|
20
|
+
module Backends
|
|
21
|
+
|
|
22
|
+
# A filter that sorts data according to their X values.
|
|
23
|
+
class NormalizeFilter < Filter
|
|
24
|
+
include Dobjects
|
|
25
|
+
|
|
26
|
+
describe "norm", "Normalize",
|
|
27
|
+
"Normalize so that maximum absolute value is 1 " +
|
|
28
|
+
"(keeping the original sign)"
|
|
29
|
+
|
|
30
|
+
def initialize
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def apply!(f)
|
|
34
|
+
y_abs_max = Dvector[f.y.min.abs, f.y.max.abs].max
|
|
35
|
+
f.y.div!(y_abs_max)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# smooth.rb : A simple averageing filter
|
|
2
|
+
# Copyright (C) 2006 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.
|
|
13
|
+
|
|
14
|
+
# You should have received a copy of the GNU General Public License
|
|
15
|
+
# along with this program; if not, write to the Free Software
|
|
16
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17
|
+
|
|
18
|
+
module SciYAG
|
|
19
|
+
|
|
20
|
+
module Backends
|
|
21
|
+
|
|
22
|
+
# A simple gaussian filter. You'd better give it an odd number.
|
|
23
|
+
class SmoothFilter < Filter
|
|
24
|
+
include Dobjects
|
|
25
|
+
|
|
26
|
+
describe "smooth", "Smooth", "Simple gaussian-like convolution filter"
|
|
27
|
+
|
|
28
|
+
init_param 'nb', "Number", Integer,
|
|
29
|
+
"The number of points over which to average"
|
|
30
|
+
|
|
31
|
+
def initialize(nb)
|
|
32
|
+
nb = nb.to_i
|
|
33
|
+
if nb < 2
|
|
34
|
+
warn "Invalid parameter nb #{nb}, using 5"
|
|
35
|
+
nb = 5
|
|
36
|
+
end
|
|
37
|
+
# initializes to binomial coefficients
|
|
38
|
+
@kernel = Dvector.new(nb) { |i|
|
|
39
|
+
SmoothFilter.cnk(nb,i)
|
|
40
|
+
}
|
|
41
|
+
@mid = nb - nb/2 - 1
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
# Binomial coefficients.
|
|
46
|
+
def SmoothFilter.cnk(n,k)
|
|
47
|
+
res = 1.0
|
|
48
|
+
n.downto(n - k) { |i| res *= i}
|
|
49
|
+
k.downto(1) {|i| res = res/i }
|
|
50
|
+
return res
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# There you go: a simple averageing filter.
|
|
54
|
+
def apply(f)
|
|
55
|
+
return Function.new(f.x, f.y.convolve(@kernel, @mid))
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def apply!(f)
|
|
59
|
+
f.y.replace(f.y.convolve(@kernel, @mid))
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# sort.rb : A simple sorting filter
|
|
2
|
+
# Copyright (C) 2006 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.
|
|
13
|
+
|
|
14
|
+
# You should have received a copy of the GNU General Public License
|
|
15
|
+
# along with this program; if not, write to the Free Software
|
|
16
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17
|
+
|
|
18
|
+
module SciYAG
|
|
19
|
+
|
|
20
|
+
module Backends
|
|
21
|
+
|
|
22
|
+
# A filter that sorts data according to their X values.
|
|
23
|
+
class XsortFilter < Filter
|
|
24
|
+
include Dobjects
|
|
25
|
+
|
|
26
|
+
describe "sort", "Sort", "Sorts the points according to the X values"
|
|
27
|
+
|
|
28
|
+
def initialize
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# There you go: a simple averageing filter.
|
|
32
|
+
def apply(f)
|
|
33
|
+
a = Function.new(f.x.dup, f.y.dup)
|
|
34
|
+
a.sort
|
|
35
|
+
return a
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def apply!(f)
|
|
39
|
+
f.sort!
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# strip.rb : remove all NaN before processing any further
|
|
2
|
+
# Copyright (C) 2006 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.
|
|
13
|
+
|
|
14
|
+
# You should have received a copy of the GNU General Public License
|
|
15
|
+
# along with this program; if not, write to the Free Software
|
|
16
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17
|
+
|
|
18
|
+
module SciYAG
|
|
19
|
+
|
|
20
|
+
module Backends
|
|
21
|
+
|
|
22
|
+
# A filter that sorts data according to their X values.
|
|
23
|
+
class StripNanFilter < Filter
|
|
24
|
+
include Dobjects
|
|
25
|
+
|
|
26
|
+
describe "strip", "Strip",
|
|
27
|
+
"Removes all NaN from the input"
|
|
28
|
+
|
|
29
|
+
def apply!(f)
|
|
30
|
+
f.strip_nan
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|