class NumRu::GPhys

Class Methods

GPhys.new(grid, data)

Constructor.

ARGUMENTS

RETURN VALUE

NOTE

GPhys.each_along_dims(gphyses, *loopdims){...} # a block is expected

Iterator to process GPhys objects too big to read on memory at once.

Makes a loop (loops) by dividing the GPhys object(s) (gphyses) with the dimension(s) specified by loopdims. If the return value of the block is an Array, it is assumed to consist of GPhys objects, and the return value of this method is an Array in which the whole of the results are reconstructed as if no iteration is made, which is the same behavior as GPhys::IO.each_along_dims_write. If the return value of the block is not an Array, this methods returns nil.

WARNING: Unlike GPhys::IO.each_along_dims_write, the results of this method is NOT written in file(s), so be careful about memory usage if you put an Array of GPhys as the return value of the block. You will probably need to have the size of them smaller than input data.

ARGUMENTS

RETURN VALUE

ERRORS

The following raise exceptions (in addition to errors in arguments).

USAGE

See the manual of GPhys::IO.each_along_dims_write.

GPhys.join_md_nocheck(gpnary)

Join multiple GPhys objects that are ordered perfectly in a NArray.

LIMITATION (as of 2013-03-04)

ARGUMENT

RETURN VALUE

GPhys.join_md(gpnary)

Join multiple GPhys objects (ordered in a NArray).

Like GPhys.join_md_nocheck but it supports insersion of omitted 1-element dimensions and transpose for gpnary (the input NArray). It means that the rank of gpnary can be smaller than that of its compoent GPhys objects, and the order of dimensions can be arbitrary. Also, the order of coordinate values along each dimension does not have to be monotonic; the method supports sorting and spliting along dimensions. For example, if gpnary == NArray.object(2):[gp0, gp1], where the first object gp0 has the 1st coordinate [0,1,7,8] and the second object gp1 has the 1st coordinate [3,4,5,6], gpnary is restructured as [ gp0[0..1,false], gp1, gp0[2..3,false] ], and join is made by using GPhys.join_md_nocheck.

This method is generally faster than GPhys.join unless the split is one-dimensional.

ARGUMENT

RETURN VALUE

GPhys.join(gpary)

Join multiple GPhys objects (no need for any pre-ordering).

ARGUMENT

RETURN VALUE

GPhys.concat(gpary, axis_or_ary, name=nil, attr=nil)

Concatenate an Array (or 1D NArray) of GPhys objects along the new dimension specified by the 2nd to 4th arguments. The rank of the result (a GPhys) is one plus the rank of the GPhys objects.

ARGUMENTS

RETURN VALUE

Instance Methods

data

Returns the data object

RETURN VALUE

NOTE

grid_copy

Returns a copy (deep clone) of the grid object.

RETURN VALUE

NOTE

grid

Returns the grid object without copying.

RETURN VALUE

NOTE

copy

Make a deep clone onto memory

RETURN VALUE

name

Returns the name of the GPhys object, which is equal to the name of the data object in the GPhys object.

RETURN VALUE

name=(nm)

Set the name of the GPhys object.

ARGUMENTS

RETURN VALUE

rename(nm)

Same as name=, but self is returned.

ARGUMENTS

RETURN VALUE

val

Returns data values

RETURN VALUE

val=(v)

Writes in data values.

ARGUMENTS

RETURN VALUE

NOTE

replace_val(v)

Replace the data values.

ARGUMENTS

RETURN VALUE

NOTE

att_names

Returns attribute names of the data object.

RETURN VALUE

get_att(name)

Get the value of the attribute named name.

ARGUMENTS

RETURN VALUE

set_att(name, val)

put_att(name, val)

Set an attribute of the data object

ARGUMENTS

RETURN VALUE

del_att(name)

Delete an attribute of the data object.

ARGUMENTS

RETURN VALUE

ntype

Returns the numeric type of the data object.

RETURN VALUE

NOTE

typecode

Returns the numeric type of the data object.

RETURN VALUE

NOTE

units

Returns the units of the data object

RETURN VALUE

units=(units)

Changes the units of the data object

ARGUMENTS

RETURN VALUE

convert_units(to)

Convert the units of the data object

ARGUMENTS

RETURN VALUE

long_name

Returns the "long_name" attribute the data object

RETURN VALUE

long_name=(to)

Changes/sets the "long_name" attribute the data object

ARGUMENTS

RETURN VALUE

[]

Returns a subset.

ARGUMENTS

RETURN VALUE

[] =

Sets values of a subset

RETURN VALUE

cut

Similar to [], but the subset is specified by physical coordinate.

ARGUMENTS

EXAMPLES

RETURN VALUE

cut_rank_conserving

Similar to cut, but the rank is conserved by not eliminating any dimension (whose length could be one).

axnames

Returns the names of the axes

RETURN VALUE

rank

Returns the rank

RETURN VALUE

axis(dim)

Returns the Axis object of a dimension.

ARGEMENTS

RETURN VALUE

coord(dim)

coordinate(dim)

Returns the coordinate variable

ARGUMENTS

RETURN VALUE

NOTE

lost_axes

Returns info on axes eliminated during operations.

Useful for annotation in plots, for example (See the code of GGraph for an application).

RETURN VALUE

dim_index( dimname )

Returns the integer id (count from zero) of the dimension

ARGUMENT

RETURN VALUE

integrate(dim)

Integration along a dimension.

RETURN VALUE

NOTE

average(dim)

Averaging along a dimension.

RETURN VALUE

NOTE

eddy(*dim)

Deviation from mean

ARGUMENT

RETURN VALUE

NOTE

first1D

Returns a 1D subset selecting the first elements of 2nd, 3rd, .. dimensions, i.e., self[true, 0, 0, ...]. (For graphics)

ARGUMENTS

RETURN VALUE

first2D

Returns a 2D subset selecting the first elements of 3rd, 4th, .. dimensions, i.e., self[true, true, 0, 0, ...]. (For graphics)

ARGUMENTS

RETURN VALUE

first3D

Returns a 3D subset selecting the first elements of 4th, 5th, .. dimensions, i.e., self[true, true, true, 0, ...]. (For graphics)

ARGUMENTS

RETURN VALUE

coerce(other)

You know what it is.

shape_coerce(other)

Like coerce, but just changes shape without changing numeric type by possibly inserting dimensions whose lengths are one (i.e., without changeing the total length of data).

shape_coerce_full(other)

Similar to shape_coerce but to return the gphyses having really the same shape with possible expansion by replication.

transpose(*dims)

Transpose.

ARGUMENTS

RETURN VALUE

shape_current

Returns the current shape of the GPhys object.

RETURN VALUE

shape

Aliased to shape_current

cyclic_ext(dim_or_dimname)

Extend a dimension cyclically.

The extension is done only when adding one grid point makes a full circle. Thus, data at coordinate values [0,90,180,270] with modulo 360 are extended (to at [0,90,180,270,360]), but data at [0,90,180] are not extended with the same modulo: in this case, self is returned.

ARGUMENTS

RETURN VALUE

Math functions (instance methods)

sqrt, exp, log, log10, log2, sin, cos, tan, sinh, cosh, tanh, asin, acos, atan, asinh, acosh, atanh, csc, sec, cot, csch, sech, coth, acsc, asec, acot, acsch, asech, acoth

Binary operators

-, +, *, /, %, **, .add!, .sub!, .mul!, .div!, mod!, >, >=, <, <=, &, |, ^, .eq, .ne, .gt, .ge, .lt, .le, .and, .or, .xor, .not

Unary operators

~ - +

Mean etc (instance methods)

mean, sum, stddev, min, max, median

Other instance methods

These methods returns a NArray (not a GPhys).

all?, any?, none?, where, where2, floor, ceil, round, to_f, to_i, to_a

gp00.set_assoc_coords([GPhys.new(Grid.new(xax0,yax0),VArray.new(x,nil,"A"))])
gp10.set_assoc_coords([GPhys.new(Grid.new(xax1,yax0),VArray.new(x,nil,"A"))])
gp01.set_assoc_coords([GPhys.new(Grid.new(xax0,yax1),VArray.new(x,nil,"A"))])
gp11.set_assoc_coords([GPhys.new(Grid.new(xax1,yax1),VArray.new(x,nil,"A"))])