cfdm.DimensionCoordinate.squeeze

DimensionCoordinate.squeeze(axes=None)[source]

Remove size one axes from the data array.

By default all size one axes are removed, but particular size one axes may be selected for removal. Corresponding axes are also removed from the bounds data array, if present.

New in version 1.7.0.

Parameters:
axes: (sequence of) int

The positions of the size one axes to be removed. By default all size one axes are removed. Each axis is identified by its original integer position. Negative integers counting from the last position are allowed.

Parameter example:

axes=0

Parameter example:

axes=-2

Parameter example:

axes=[2, 0]

Returns:

The new construct with removed data axes.

Examples:

>>> f.data.shape
(1, 73, 1, 96)
>>> f.squeeze().data.shape
(73, 96)
>>> f.squeeze(0).data.shape
(73, 1, 96)
>>> g = f.squeeze([-3, 2])
>>> g.data.shape
(73, 96)
>>> f.bounds.data.shape
(1, 73, 1, 96, 4)
>>> g.data.shape
(73, 96, 4)