cf.Field.squeeze

Field.squeeze(axes=None, domain=False)[source]

Remove size 1 dimensions from the field’s data array in place.

Parameters :

axes : (sequence of) str or int, optional

The size 1 axes to be removed. By default, all size 1 axes are removed. Size 1 axes for removal may be identified with one of, or a sequence of any combination of zero or more of:

  • A dimension’s standard name.
  • The integer position of a dimension in the data array.
  • The field’s domain’s internal name of a dimension

If an empty sequence is given then no dimensions are removed.

domain : bool, optional

If True then also remove the dimensions from the field’s domain.

Returns :

None

Examples

>>> f.squeeze()
>>> f.squeeze('time')
>>> f.squeeze(1)
>>> f.squeeze('dim2')
>>> f.squeeze([1, 'time', 'dim2'])
>>> f.squeeze('height', domain=True)
>>> f.squeeze([])

Previous topic

cf.Field.sin

Next topic

cf.Field.transpose

This Page