VArray is a Virtual Array class, in which a multi-dimensional array data is stored on memory (NArray, NArrayMiss) or in file (NetCDFVar etc). The in-file data handling is left to subclasses such as VArrayNetCDF, and this base class handles the following two cases:
Perhaps the latter case needs more explanation. Here, a VArray is defined as a subset of another VArray, so the current VArray has only the link and info on how the subset is mapped to the other VArray.
A VArray behaves just like a NArray, i.e., a numeric multi-dimensional array. The important difference is that a VArray has a name and can have "attributes" like a NetCDF variable. Therefore, VArray can perfectly represent a NetCDFVar, which is realized by a sub-class VArrayNetCDF.
NOMENCLATURE
VArray.new(narray=nil, attr=nil, name=nil)
A constructor
ARGUMENTS
attribute object is created and stored.
RETURN VALUE
EXAMPLE
na = NArray.int(6,3).indgen! va1 = VArray.new( na, nil, "test" )
VArray.new2(ntype, shape, attr=nil, name=nil)
Another constructor. Uses parameters to initialize a NArray to hold.
ARGUMENTS
RETURN VALUE
val
Returns the values as a NArray (or NArrayMiss).
This is the case even when the VArray is a mapping to another. Also, this method is to be redefined in subclasses to do the same thing.
ARGUMENTS -- none
RETURN VALUE
val=(narray)
Set values.
The whole values are set. If you want to set partly, use []=. In this method, values are read from narray and set into the internal value holder. Thus, for exampled, the numeric type is not changed regardress the numeric type of narray. Use replace_val to replace entirely with narray.
ARGUMENTS
replace_val(narray)
Replace the internal array data with the object narray. Use val= if you want to copy the values of narray.
ARGUMENTS
RETURN VALUE
[]
[] =
attr
ntype
Returns the numeric type.
ARGUMENTS -- none
RETURN VALUE
rank
shape
shape_current
length
typecode
name
Returns the name
RETURN VALUE
name=(nm)
Changes the name.
ARGUMENTS
RETURN VALUE
rename!(nm)
Changes the name (Same as name=, but returns self)
ARGUMENTS
RETURN VALUE
rename(nm)
Same as rename! but duplicate the VArray object and set its name.
This method may not be supported in sub-classes, since it is sometimes problematic not to change the original.
copy(to=nil)
Copy a VArray. If to is nil, works as the deep cloning (duplication of the entire object).
Both the values and the attributes are copied.
ARGUMENTS
reshape!( *shape )
Changes the shape without changing the total size. May not be available in subclasses.
ARGUMENTS
RETURN VALUE
EXAMPLE
vary = VArray.new2( "float", [10,2]) vary.reshape!(5,4) # changes the vary vary.copy.reshape!(2,2,5) # make a deep clone and change it # This always works with a VArray subclass, since vary.copy # makes a deep clone to VArray with NArray.
file
Returns a file object if the data of the VArray is in a file, nil if it is on memory
ARGUMENTS
RETURN VALUE
transpose(*dims)
reshape(*shape)
axis_draw_positive
Returns the direction to plot the axis (meaningful only if self is a coordinate variable.)
The current implementation is based on NetCDF conventions, so REDEFINE IT IN SUBCLASSES if it is not appropriate.
RETURN VALUE
axis_cyclic?
Returns whether the axis is cyclic (meaningful only if self is a coordinate variable.)
The current implementation is based on NetCDF conventions, so REDEFINE IT IN SUBCLASSES if it is not appropriate.
RETURN VALUE
axis_modulo
Returns the modulo of a cyclic axis (meaningful only if self is a coordinate variable and it is cyclic.)
The current implementation is based on NetCDF conventions, so REDEFINE IT IN SUBCLASSES if it is not appropriate.
RETURN VALUE
axis_cyclic_extendible?
coerce(other)
VArray is a numeric multi-dimensional array, so it supports most of the methods and operators in NArray. Here, the name of those methods are just quoted. See the documentation of NArray for their usage.
These methods returns a NArray (not a VArray).