Class: NumRu::VArrayGtool3

Inherits:
VArray
  • Object
show all
Defined in:
lib/numru/gphys/varraygtool3.rb

Constant Summary

Constants inherited from VArray

NumRu::VArray::Binary_operators, NumRu::VArray::Binary_operatorsL, NumRu::VArray::Binary_operatorsL_comp, NumRu::VArray::Binary_operatorsL_other, NumRu::VArray::Binary_operators_Uconv, NumRu::VArray::Binary_operators_Unone, NumRu::VArray::Binary_operators_Uop, NumRu::VArray::Math_funcs, NumRu::VArray::Math_funcs_nondim, NumRu::VArray::Math_funcs_radian, NumRu::VArray::NArray_type1_methods, NumRu::VArray::NArray_type2_methods, NumRu::VArray::NArray_type2_methods1, NumRu::VArray::NArray_type2_methods2, NumRu::VArray::NArray_type2_methods3, NumRu::VArray::NArray_type3_methods, NumRu::VArray::Unary_operators

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from VArray

#+@, #[], #[]=, #att_names, #attr_copy, #axis_cyclic?, #axis_cyclic_extendible?, #axis_draw_positive, #axis_modulo, #bin_mean, #bin_sum, #coerce, #convert_units, #copy, #del_att, #get_att, #long_name, #long_name=, #mapped?, #marshal_dump, #marshal_load, #name, #name=, new2, #ntype, #rename, #rename!, #replace_val, #reshape, #reshape!, #set_att, #sqrt, #to_g1D, #transpose, #units, #units=

Constructor Details

#initialize(aGtool3Var) ⇒ VArrayGtool3

< initialization redefined > ##

Raises:

  • (ArgumentError)


31
32
33
34
35
36
37
38
# File 'lib/numru/gphys/varraygtool3.rb', line 31

def initialize(aGtool3Var)
  raise ArgumentError,"Not a Gtool3Var" if ! aGtool3Var.is_a?(Gtool3Var)
  @name = aGtool3Var.name
  @mapping = nil
  @varray = nil
  @ary = aGtool3Var
  @attr = _attr_conv_to_CF( aGtool3Var.attr )
end

Class Method Details

.coord_att_conv!(hash) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/numru/gphys/varraygtool3.rb', line 73

def coord_att_conv!(hash)
  hash.keys.each do |k|
    v = hash.delete(k)
    if (ck=ATTR_CF_CONV[k])   # substitution, not ==
      v = NArray[v] if v.is_a?(Numeric)
      if k=="UNIT"
        case v
        when "deg"
          v = "degrees"
        end
      end
      hash[ck] = v
    elsif k=="STYP" && v
      if v >= 0
        hash["positive"] = "up"
      else
        hash["positive"] = "down"
      end
    end
  end
  hash
end

.make_coord(hash) ⇒ Object

to make a varray from an axis (except for time)



66
67
68
69
70
71
# File 'lib/numru/gphys/varraygtool3.rb', line 66

def make_coord(hash)
  nary = hash.delete(:val)
  name = hash.delete("ITEM")
  coord_att_conv!(hash)
  VArray.new(nary, hash, name)
end

Instance Method Details

#dim_namesObject

< additional instance methods > ##



137
138
139
# File 'lib/numru/gphys/varraygtool3.rb', line 137

def dim_names
  @ary.dim_names
end

#fileObject



146
147
148
# File 'lib/numru/gphys/varraygtool3.rb', line 146

def file
  @ary.file
end

#inspectObject

# It is safer not to have the method “shape” to avoid misconfusion of # shape_ul0 and shape_current: def shape

raise "The shape method is not available. Use shape_ul0 or shape_current instead."

end



114
115
116
# File 'lib/numru/gphys/varraygtool3.rb', line 114

def inspect
  "<'#{@name}' in '#{@ary.file.path}' #{ntype}#{shape_current.inspect}>"
end

#rankObject



125
126
127
# File 'lib/numru/gphys/varraygtool3.rb', line 125

def rank
  shape_current.length
end

#shape_currentObject



143
144
145
# File 'lib/numru/gphys/varraygtool3.rb', line 143

def shape_current
  @ary.shape_current
end

#shape_ul0Object



140
141
142
# File 'lib/numru/gphys/varraygtool3.rb', line 140

def shape_ul0
  @ary.shape_ul0
end

#totalObject Also known as: length



118
119
120
121
122
# File 'lib/numru/gphys/varraygtool3.rb', line 118

def total
  len = 1
  @ary.shape_current.each{|i| len *= i}
  len
end

#valObject

< redefined instance methods > ##



99
100
101
# File 'lib/numru/gphys/varraygtool3.rb', line 99

def val
  v = @ary.get
end

#val=(narray) ⇒ Object



103
104
105
106
# File 'lib/numru/gphys/varraygtool3.rb', line 103

def val=(narray)
  @ary.put( __check_ary_class2(narray) )
  narray
end