class CTioga2::Data::IndexedDTable
An indexed Dtable.
This object represents an indexed Dtable, that is a Dtable with given values of X and Y (not necessarily uniform). Its main use is to get back a uniform (non-indexed) Dtable, for use with create_image
An important information is that places where there was no data is implicitly represented as NaN
Attributes
The underlying Dtable
X values
Y values
Public Class Methods
# File lib/ctioga2/data/indexed-dtable.rb, line 40 def initialize(x, y, t) @table = t @x_values = x @y_values = y end
Public Instance Methods
Returns a hash ul,ll,lr with the corresponding values of the the points, with the correction applied if correction is true
# File lib/ctioga2/data/indexed-dtable.rb, line 86 def corner_positions(correction = true) dict = { 'll' => ll, 'lr' => lr, 'ul' => ul } if correction dx, dy = *xy_correction # This isn't really beautiful, but it just works. dict['ll'][0] -= dx dict['lr'][0] += dx dict['ul'][0] -= dx dict['ll'][1] -= dy dict['lr'][1] -= dy dict['ul'][1] += dy end return dict end
# File lib/ctioga2/data/indexed-dtable.rb, line 110 def height return @y_values.size end
Returns the coordinates of the lower-left XY values
# File lib/ctioga2/data/indexed-dtable.rb, line 65 def ll return [@x_values.first, @y_values.first] end
Returns the coordinates of the lower-left XY values
# File lib/ctioga2/data/indexed-dtable.rb, line 70 def lr return [@x_values.last, @y_values.first] end
Makes a contour using the given level.
Depending on the value of opts, what is returned is:
-
if 'xyg', [xs, ys, gaps] triplet suitable for use with t.append_points_with_gaps_to_path to show the given level (default)
-
if 'func', a single function with nans inserted at the position of the gaps
-
if 'funcs', a function for each of the “continuous” segments
Anything else in opts is given directly to make_contour
# File lib/ctioga2/data/indexed-dtable.rb, line 125 def make_contour(level, opts = {}) gaps = [] # Requires Tioga r598 opts = {'data' => @table, 'xs' => @x_values, 'ys' => @y_values, 'gaps' => gaps, 'level' => level }.update(opts) ret = opts['ret'] || 'xyg' opts.delete('ret') xs, ys = *Tioga::FigureMaker.make_contour(opts) if ret == 'xyg' return [xs, ys, gaps] end gaps = opts['gaps'].dup gaps -= [xs.size] n = 0.0/0.0 gaps.sort.reverse.each do |i| xs.insert(i,n) ys.insert(i,n) end fnc = Dobjects::Function.new(xs,ys) if ret == 'func' return fnc else return fnc.split_on_nan(:x) end end
Returns the coordinates of the upper-right XY values
# File lib/ctioga2/data/indexed-dtable.rb, line 80 def ul return [@x_values.first, @y_values.last] end
Returns the coordinates of the upper-right XY values
# File lib/ctioga2/data/indexed-dtable.rb, line 75 def ur return [@x_values.last, @y_values.last] end
# File lib/ctioga2/data/indexed-dtable.rb, line 106 def width return @x_values.size end
Returns the XY boundaries of the object
# File lib/ctioga2/data/indexed-dtable.rb, line 47 def xy_boundaries return Graphics::Types::Boundaries.bounds(@x_values, @y_values) end
Returns the value by which one should shift the X and Y positions of the borders of the images in order to get the points centered on their pixel (for a uniform grid !).
While this correction looks better on non-uniform grids, it does not guarantee that it places all the points int the middle of their pixel, but that is still true for the ones at the border.
# File lib/ctioga2/data/indexed-dtable.rb, line 59 def xy_correction return [(@x_values.last - @x_values.first)/ (2 * @x_values.size), (@y_values.last - @y_values.first)/ (2 * @y_values.size)] end