cf.Field.transpose

Field.transpose(axes=None, i=False, **kwargs)[source]

Permute the axes of the data array in place.

Parameters:
axes, kwargs : optional

Set the new axis order. By default the existing axis order is reversed.

If axes and/or kwargs are set then the new axis order is that which would be returned by this call of the field’s axes method: f.axes(axes, ordered=True, **kwargs). See cf.Field.axes for details.

i : bool, optional

If True then update the field in place. By default a new field is created.

Returns:

out : cf.Field

Examples:
>>> f.items()
{'dim0': <CF DimensionCoordinate: time(12) noleap>,
 'dim1': <CF DimensionCoordinate: latitude(64) degrees_north>,
 'dim2': <CF DimensionCoordinate: longitude(128) degrees_east>,
 'dim3': <CF DimensionCoordinate: height(1) m>}
>>> f.data_axes()
['dim0', 'dim1', 'dim2']
>>> f.transpose()
>>> f.transpose(['latitude', 'time', 'longitude'])
>>> f.transpose([1, 0, 2])
>>> f.transpose((1, 'time', 'dim2'))

Previous topic

cf.Field.sum

Next topic

cf.Field.trunc

This Page