cf.Field.axis¶
-
Field.
axis
(axes=None, size=None, **kwargs)[source]¶ Return a domain axis identifier from the field.
Axes are selected with the criteria specified by the keyword parameters. If no keyword parameters are specified then all axes are selected.
See also
Examples 1: >>> a = f.axis('time')
Parameters: - axes, kwargs : optional
Select axes. The axes parameter may be one, or a sequence, of:
None
. If no kwargs arguments have been set then all axes are selected. This is the default.
An integer. Explicitly selects the axis corresponding to the given position in the list of axes of the field’s data array.
- Example:
To select the third data array axis:
axes=2
. To select the last axis:axes=-1
.
A
slice
object. Explicitly selects the axes corresponding to the given positions in the list of axes of the field’s data array.- Example:
To select the last three data array axes:
axes=slice(-3, None)
A domain axis identifier. Explicitly selects this axis.
- Example:
To select axis “dim1”:
axes='dim1'
.
Any value accepted by the items parameter of the field’s
items
method. Used in conjunction with the kwargs parameters to select the axes which span the items that would be identified by this call of the field’sitems
method:f.items(items=axes, axes=None, **kwargs)
. Seecf.Field.items
for details.- Example:
To select the axes spanned by one dimensionsal time coordinates:
f.axis('T', ndim=1)
.
If axes is a sequence of any combination of the above then the selected axes are the union of those selected by each element of the sequence. If the sequence is empty then no axes are selected.
- size : optional
Select axes whose sizes equal size. Axes whose sizes lie within a range sizes may be selected if size is a
cf.Query
object.- Example:
size=1
selects size 1 axes.- Example:
size=cf.ge(2)
selects axes with sizes greater than 1 (seecf.ge
).
Returns: - out : str or None
The domain identifier of the unique axis or, if there isn’t one,
None
.
Examples 2: >>> f <CF Field: air_temperature(time(12), latitude(64), longitude(128)) K> >>> f.data_axes() ['dim0', 'dim1', 'dim2'] >>> f.axis('time') 'dim0' >>> f.axis('Y') 'dim1' >>> f.axis(size=64) 'dim1' >>> f.axis('X', size=128) 'dim2' >>> print f.axis('foo') None >>> print f.axis('T', size=64) None