Class: DataOutput::RegionOutput

Inherits:
BaseOutput show all
Defined in:
lib/output/data_output/region_output.rb

Overview

Output class to visualize the interpolation of a region

Instance Attribute Summary collapse

Attributes inherited from BaseOutput

#data_set, #legend, #with_extreme_values

Instance Method Summary collapse

Methods inherited from BaseOutput

#determine_output_type_and_print_value, #print_data, #print_data_and_get_extrema, #print_domain_information, #print_extreme_information, #print_extreme_values_for, #set_attributes

Constructor Details

#initialize(data, coordinates, data_series, values) ⇒ RegionOutput

singleton method to generate the output for the given region

Parameters:

  • data (DataSet)

    the data that should be visualized

  • coordinates (Hash)

    a hash containing the x and y coordinate of the central point of the region

  • data_series (DataSeries)

    the considered data series which is required for the extreme values

  • values (Hash)

    a hash containing all required values to interpolate the region



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/output/data_output/region_output.rb', line 19

def initialize(data, coordinates, data_series, values)
  set_attributes(data, values[:extreme_values])
  @legend = ColorLegend::ColorData.new(data_series.min_value,
                                       data_series.max_value)
  @domain_x = create_data_domain('X', coordinates[:x], values[:inter_x],
                                                      values[:delta_x])
  @domain_y = create_data_domain('Y', coordinates[:y], values[:inter_y],
                                                      values[:delta_y])

  print_output_head(coordinates, values)
  print_data(values[:legend], @domain_x, @domain_y)
end

Instance Attribute Details

#domain_xDataDomain (readonly, private)

Returns representing the section in the x-dimension.

Returns:

  • (DataDomain)

    representing the section in the x-dimension



34
35
36
# File 'lib/output/data_output/region_output.rb', line 34

def domain_x
  @domain_x
end

#domain_yDataDomain (readonly, private)

Returns representing the section in the y-dimension.

Returns:

  • (DataDomain)

    representing the section in the y-dimension



36
37
38
# File 'lib/output/data_output/region_output.rb', line 36

def domain_y
  @domain_y
end

Instance Method Details

#create_data_domain(label, coordinate, interval, delta) ⇒ DataDomain (private)

method to create the special MetaData::DataDomains for the x- and y-dimension

Parameters:

  • label (String)

    the name of the domain

  • coordinate (Float)

    the coordinate of the region center in the required dimension

  • interval (Float)

    the value to specify the value set in the considered dimension

  • delta (Float)

    the steprange in the considered dimension

Returns:

  • (DataDomain)

    the domain object based on the input parameter



47
48
49
50
51
52
# File 'lib/output/data_output/region_output.rb', line 47

def create_data_domain(label, coordinate, interval, delta)
  lower = (coordinate - interval).round(3)
  upper = (coordinate + interval).round(3)

  MetaData::DataDomain.new(label, lower, upper, delta)
end

prints the meta information consisting of dataset name and informations of the different dimensions



65
66
67
68
69
70
# File 'lib/output/data_output/region_output.rb', line 65

def print_meta_information
  puts "\nRegional interpolation with domain properties:"

  print_domain_information(@domain_x, "\nX")
  print_domain_information(@domain_y, 'Y')
end

method to print the output head

Parameters:

  • coordinates (Hash)

    a hash containing the coordinates of the origin

  • values (Hash)

    a hash containing the required values



57
58
59
60
61
# File 'lib/output/data_output/region_output.rb', line 57

def print_output_head(coordinates, values)
  puts "Printing interpolated region around (%.2f, %.2f) for data set %d" %
        [coordinates[:x], coordinates[:y], values[:index] + 1]
  puts "\n"
end