Field.axes(axes=None, size=None, ordered=False, **kwargs)[source]

Return domain axis identifiers from the field.

The output is a set of domain axis identifiers, which may be empty.

Axes are selected with the criteria specified by the keyword parameters. If no keyword parameters are specified then all axes are selected.

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.


    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.


    To select the last three data array axes: axes=slice(-3, None)

  • A domain axis identifier. Explicitly selects this axis.


    To select axis “dim1”: axes='dim1'.

  • Any value accepted by the description 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’s items method: f.items(items=axes, axes=None, **kwargs). See cf.Field.items for details.


    To select the axes spanned by one dimensionsal time coordinates: f.axes('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.


>>> x = f.axes(['dim2', 'time', {'units': 'degree_north'}])
>>> y = set()
>>> for axes in ['dim2', 'time', {'units': 'degree_north'}]:
...     y.update(f.axes(axes))
>>> x == y
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.


size=1 selects size 1 axes.

Example: selects axes with sizes greater than 1 (see

ordered: bool, optional

Return an ordered list of axes instead of an unordered set. The order of the list will reflect any ordering specified by the axes and kwargs parameters.


If the data array axes, as returned by the field’s data_axes method, are ['dim0', 'dim1', 'dim2'], then f.axes([2, 0, 1, 2]) will return set(['dim0', 'dim1', 'dim2']), but f.axes([2, 0, 1, 2], ordered=True) will return ['dim2', 'dim0', 'dim1', 'dim2'].

out: dict or OrderedDict

A dictionary of domain axis identifiers and their sizes, or an OrderedDict if ordered is True.


All axes and their identities:

>>> f.axes()
set(['dim0', 'dim1', 'dim2', 'dim3'])
>>> dict([(axis, f.domain.axis_name(axis)) for axis in f.axes()])
{'dim0': time(12)
 'dim1': height(19)
 'dim2': latitude(73)
 'dim3': longitude(96)}

Axes which are not spanned by the data array:

>>> f.axes().difference(f.data_axes())