Class: NumRu::VArrayHE5GdField
- Inherits:
-
VArray
- Object
- VArray
- NumRu::VArrayHE5GdField
show all
- Defined in:
- lib/numru/gphys/varrayhdfeos5.rb
Overview
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=, #rename, #rename!, #replace_val, #reshape, #reshape!, #set_att, #sqrt, #to_g1D, #transpose, #units, #units=
Constructor Details
< initialization redefined > ##
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
# File 'lib/numru/gphys/varrayhdfeos5.rb', line 157
def initialize(aHE5GdField)
@name = aHE5GdField.name
@mapping = nil
@varray = nil
if ! aHE5GdField.is_a?(HE5GdField)
raise ArgumentError,"Not a HE5GdField"
end
@ary = aHE5GdField
@attr = Attribute.new
aHE5GdField.att_names.each{|name|
@attr[name.downcase] = aHE5GdField.get_att(name).to_s
@attr["long_name"] = aHE5GdField.get_att(name).to_s if name == "Title" }
end
|
Class Method Details
.new2(grid, name, ntype, dimensions, vary = nil) ⇒ Object
Also known as:
def_var
178
179
180
181
182
183
184
185
186
|
# File 'lib/numru/gphys/varrayhdfeos5.rb', line 178
def new2(grid, name, ntype, dimensions, vary=nil)
dimensions = dimensions.join(',')
va = new( grid.def_var(name, ntype, dimensions) )
if vary
vary.att_names.each{|name| va.set_att(name, vary.get_att(name))}
end
va
end
|
.write(file, vary, rename = nil, dimnames = nil) ⇒ Object
< additional class methods > ##
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
# File 'lib/numru/gphys/varrayhdfeos5.rb', line 192
def write(file, vary, rename=nil, dimnames=nil)
raise ArgumentError, "1st arg: not a HE5Gd" if !file.is_a?(HE5Gd)
raise ArgumentError, "2nd arg: not a VArray" if !vary.is_a?(VArray)
rank=vary.rank
if dimnames == nil
if vary.is_a?(VArrayHE5GdField)
dimnames = vary.dim_names
else
dimnames=Array.new
for i in 0...rank
dimnames[i]='x'+i.to_s
end
end
elsif( rank != dimnames.length)
raise ArgumentError,
"# of dim names does not agree with the rank of the VArray"
end
fdimnms = file.dim_names
begin
shape = vary.shape
rescue StandardError, NameError
shape = vary.shape_ul0
end
dims = Array.new
for i in 0...rank
nm = dimnames[i]
if fdimnms.include?(nm)
dims[i] = nm
else
dims[i] = file.defdim(nm.name,shape[i])
end
end
nm = ( rename || vary.name )
val = vary.val
newvary = new2(file, nm, vary.typecode, dims, vary)
newvary.val = val
return newvary
end
|
Instance Method Details
#dim_names ⇒ Object
281
282
283
|
# File 'lib/numru/gphys/varrayhdfeos5.rb', line 281
def dim_names
@ary.dim_names
end
|
#file ⇒ Object
285
286
287
|
# File 'lib/numru/gphys/varrayhdfeos5.rb', line 285
def file
@ary.grid
end
|
#inspect ⇒ Object
172
173
174
|
# File 'lib/numru/gphys/varrayhdfeos5.rb', line 172
def inspect
"<'#{@name}' in '#{@ary.grid.file.path}' #{@ary.ntype}#{shape_current.inspect}>"
end
|
#ntype ⇒ Object
256
257
258
|
# File 'lib/numru/gphys/varrayhdfeos5.rb', line 256
def ntype
@ary.ntype
end
|
#rank ⇒ Object
275
276
277
|
# File 'lib/numru/gphys/varrayhdfeos5.rb', line 275
def rank
@ary.rank
end
|
#shape ⇒ Object
251
252
253
|
# File 'lib/numru/gphys/varrayhdfeos5.rb', line 251
def shape
raise "The shape method is not available. Use shape_ul0 or shape_current instead."
end
|
#shape_current ⇒ Object
264
265
266
|
# File 'lib/numru/gphys/varrayhdfeos5.rb', line 264
def shape_current
@ary.shape_current
end
|
#shape_ul0 ⇒ Object
260
261
262
|
# File 'lib/numru/gphys/varrayhdfeos5.rb', line 260
def shape_ul0
@ary.shape_ul0
end
|
#total ⇒ Object
Also known as:
length
268
269
270
271
272
|
# File 'lib/numru/gphys/varrayhdfeos5.rb', line 268
def total
len = 1
@ary.shape_current.each{|i| len *= i}
len
end
|
#val ⇒ Object
< redefined instance methods > ##
234
235
236
|
# File 'lib/numru/gphys/varrayhdfeos5.rb', line 234
def val
return @ary.get
end
|
#val=(narray) ⇒ Object
238
239
240
241
242
243
244
245
246
247
248
249
|
# File 'lib/numru/gphys/varrayhdfeos5.rb', line 238
def val=(narray)
if narray.is_a?(Numeric)
@ary.put( narray )
else
narray = __check_ary_class(narray)
slicer = (0...rank).collect{|i|
(shape_ul0[i] != 0) ? true : 0...narray.shape[i]
}
@ary[*slicer] = narray
narray
end
end
|