class NumRu::Axis

A class of to handle a descretized physical coordinate.

Overview

An NumRu::Axis object is meant to represent a dimension in a NumRu::Grid object, which is used in NumRu::Grid (Hereafter, NumRu:: is omitted). An Axis has 1-dimensional data on grid-point posisions as a VArray. In addition, it can have supplementary data (as VArray objects).

Three types of axes are supported in this class:

1. Simple (mostly point-sampled) axes
2. Cell-type axes. In this case, grid points are either
   at cell boundaries or within the cells (oftern at the center).
3. Simple ("bare") indexing (without particular physical meaning)

In most applications, the 1st type would be enough, but the 2nd type would be useful for some type of numerical simulation. The 3rd is not physical and may not be considered as "axes", but this could be convenient for some practical applications.

Class Methods

Axis.new(cell=false,bare_index=false,name=nil)

Constructor. The first two arguments are to specify one of the types explained above.

ARGUMENTS

RETURN VALUE

Axis.defined_operations

Returns the name of the methods defined in Axis to do some operation along the axis.

RETURN VALUE

Axis.humane_messaging = t_or_f

If false is given, the [] method is changed to return a naive straightforward message if the axis is lost. -- By default, it returns a fancy but sometimes unwanted message if the axis is the time with since field in the form of yyyy-mm-dd....

Axis.join(ary)

Join multiple axis objects. (simple concatenation without sort)

ARGUMENTS

RETURN VALUE

Instance Methods

name=(nm)

Set a name.

ARGUMENTS

RETURN VALUE

name

Returns the name.

RETURN VALUE

cell?

Whether or not self is a cell-type axis.

RETURN VALUE

cell_center?

Whether or not self represents data points within the cells (which is often, but not necessarily, the centers of the cells).

RETURN VALUE

cell_bounds?

Whether or not self represents data points at the cell bondaries.

RETURN VALUE

bare_index?

Whether or not self is of the bare-index type.

RETURN VALUE

flatten

Returns the VArray objects in self as a flat Array. No cloning is made.

RETURN VALUE

each_varray

Iterator for each VArray object in self (dependent on flatten.

RETURN VALUE

copy

Make a deep clone onto memory. All the VArray objects in the return value will be of the root class of VArray.

RETURN VALUE

collect

This method is like copy, but it is the 'collect' iterator for each VArray in self (block required).

RETURN VALUE

pos=(pos)

Sets the grid-point positions (disretized coordinate values).

ARGUMENTS

RETURN VALUE

set_pos(pos)

Sets the grid-point positions (disretized coordinate values).

ARGUMENTS

RETURN VALUE

pos

Returns the grid-point positions (disretized coordinate values).

RETURN VALUE

cell_center

When cell-type, returns the positions of grid points at cell centers.

RETURN VALUE

cell_bounds

When cell-type, returns the positions of grid points at cell boundaries.

RETURN VALUE

length

Returns the length of the axis.

RETURN VALUE

set_cell(center, bounds, name=nil)

Set up cell-type axis, by giving both the cell centers and boundaries. Completion of the set up is deferred until one of set_pos_to_center and set_pos_to_bounds is called.

ARGUMENTS

RETURN VALUE

set_cell_guess_bounds(center, name=nil)

Set up cell-type axis, by specifing only the cell centers and deriving bounds with a naive assumption.

ARGUMENTS

RETURN VALUE

set_pos_to_center

Set the position of the current axis to the centers of the cells. This or set_pos_to_bounds is needed to complete the set up with set_cell_* methods.

set_pos_to_bounds

Set the position of the current axis to the cell bondaries. This or set_pos_to_center is needed to complete the set up with set_cell_* methods.

set_aux(name,vary)

Set auxiliary data

ARGUMENTS

RETURN VALUE

get_aux(name)

Returns auxiliary data

ARGUMENTS

RETURN VALUE

aux_names

Returns a list of the names of auxiliary data

RETURN VALUE

to_gphys(datavary1d=nil)

To construct a GPhys object from an Axis.

ARGUMENTS

RETURN VALUE

[slicer]

Returns a subset. Its specification is the same as in NArray.

RETURN VALUE

cut(coord_cutter)

Similar to [], but is based on the physical coordinate.

RETURN VALUE

cut_rank_conserving(coord_cutter)

Similar to cut, but is always rank-conserving. That is, a subset specification like [i] is treated as [i..i]

RETURN VALUE

integrate(ary,dim)

Does integration along the axis

ARGUMENTS

RETURN VALUE

integ_weight

Returns the integration weight (whose default is nil).

integ_weight=(wgt)

Sets the integration weight (whose default is nil).

average(ary,dim)

Similar to integrate, but does averaging

ARGUMENTS

RETURN VALUE

average_weight

Returns the integration weight (whose default is nil).

average_weight=(wgt)

Sets the integration weight (whose default is nil).

draw_positive

Returns the direction to plot the axis, which relies on the VArray#axis_draw_positive method.

RETURN VALUE

cyclic?

Returns whether the axis is cyclic. (Relies on the VArray#axis_cyclic? method.)

RETURN VALUE

modulo

Returns the modulo of a cyclic axis (Relies on the VArray#axis_modulo method.)

RETURN VALUE

cyclic_extendible?

Returns whether the axis is cyclic and appropriate to extend. (Relies on the VArray#axis_cyclic_extendible? method.)

RETURN VALUE