cf.Field.transpose¶
-
Field.
transpose
(axes=None, constructs=False, inplace=False, items=True, i=False, **kwargs)[source]¶ Permute the axes of the data array.
By default the order of the axes is reversed, but any ordering may be specified by selecting the axes of the output in the required order.
By default metadata constructs are not transposed, but they may be if the constructs parameter is set.
See also
domain_axis
,flatten
,insert_dimension
,flip
,squeeze
,unsqueeze
- Parameters
- axes: (sequence of)
str
orint
, optional 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'X'
, the domain axis construct returned byf.domain_axis('X')
is selected.Each dimension of the field construct’s data must be provided, or if no axes are specified then the axis order is reversed.
- constructs:
bool
, optional If True then metadata constructs are also transposed so that their axes are in the same relative order as in the transposed data array of the field. By default metadata constructs are not altered.
- inplace:
bool
, optional If True then do the operation in-place and return
None
.- items: deprecated at version 3.0.0
Use the constructs parameter instead.
- i: deprecated at version 3.0.0
Use the inplace parameter instead.
kwargs: deprecated at version 3.0.0
- axes: (sequence of)
- Returns
Examples
>>> f.ndim 3 >>> g = f.transpose() >>> g = f.transpose(['time', 1, 'dim2']) >>> f.transpose(['time', -2, 'dim2'], inplace=True)