Variable Querying Routines

Operations that retrieve information about the variable.

Var.whichaxis(iaxis)[source]

Locates a particular Axis associated with this variable.

Parameters
iaxisstring, Axis class, or int

The search criteria for finding the class.

Returns
iThe index of the matching Axis. Raises KeyError if there is no match.

See also

getaxis, hasaxis, Axis

Examples

>>> from pygeode.tutorial import t1
>>> T = t1.Temp
>>> print(T.axes)
(<Lat>, <Lon>)
>>> print(T.whichaxis('lat'))
0
>>> print(T.whichaxis('lon'))
1
>>> print(T.whichaxis('time'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.6/dist-packages/pygeode/var.py", line 352, in whichaxis
    raise KeyError, "axis %s not found in %s"%(repr(iaxis),self.axes)
KeyError: "axis 'time' not found in (<Lat>, <Lon>)"
Var.hasaxis(iaxis)[source]

Determines if a particular Axis is associated with this variable.

Parameters
iaxisstring, Axis class, or int

The search criteria for finding the class.

Returns
foundboolean. True if found, otherwise False

See also

getaxis, whichaxis, Axis
Var.getaxis(iaxis)[source]

Grabs a reference to a particular Axis associated with this variable.

Parameters
iaxisstring, Axis class, or int

The search criteria for finding the class.

Returns
axisAxis object that matches. Raises KeyError if there is no match.

See also

whichaxis, hasaxis, Axis
Var.getweights(iaxes=None)[source]

Returns weights associated with the axes of this variable.

Parameters
iaxeslist of axis identifiers (string, Axis, or int) (optional)

Axes over which to compute the weights

Returns
weightsVar

defined on the subgrid of this variable on which weights are defined.

See also

Axis.__init__
See Also:

Var class overview