cfdm.Field.transpose

Field.transpose(axes=None, constructs=False, inplace=False)[source]

Permute the axes of the data array.

New in version (cfdm): 1.7.0

Parameters
axes: sequence or None

Select the domain axis order, defined by the domain axes that would be selected by passing each given axis description to a call of the field construct’s domain_axis method. For example, for a value of 'time', the domain axis construct returned by f.domain_axis('time') is selected.

Each dimension of the field construct’s data must be provided, or if axes is None (the default) then the axis order is reversed.

constructs: bool

If True then transpose the metadata constructs to have the same relative domain axis order as the data of transposed field construct. By default, metadata constructs are not changed.

inplace: bool, optional

If True then do the operation in-place and return None.

Returns
Field or None

The field construct with permuted data axes. If the operation was in-place then None is returned.

Examples

>>>
>>> f.data.shape
(19, 73, 96)
>>> f.transpose().data.shape
(96, 73, 19)
>>> f.transpose([1, 0, 2]).data.shape
(73, 19, 96)
>>> f.transpose(inplace=True)
>>> f.data.shape
(96, 19, 73)