cf.Field.squeeze

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

Remove size 1 axes from the data array.

By default all size 1 axes are removed from the field’s data array, but particular axes may be selected with the keyword arguments.

Squeezed axes are not squeezed from the domain’s coordinate and cell measure objects, nor are they removed from the field. To completely remove axes, use the field’s remove_axes method.

Parameters :
axes, kwargs : optional

Select the axes. The axes are those which would be selected by this call of the field’s axes method: f.axes(axes, size=1, **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.squeeze()
>>> f.squeeze('time')
>>> f.squeeze(1)
>>> f.squeeze('dim2')
>>> f.squeeze([1, 'time', 'dim2'])
>>> f.squeeze({'units': 'Pa'})

Previous topic

cf.Field.sort

Next topic

cf.Field.subspace

This Page