cf.Domain.squeeze

Domain.squeeze(dims)[source]

Remove a size 1 dimension from the domain in place.

If the dimension has a dimension coordinate then it is removed, as are 1-d auxiliary coordinates and cell measures which span the dimension. The dimension is squeezed from multidimensional auxiliary coordinates and cell measures if they span it.

The dimension is not squeezed from the field’s data array if it spans it, therefore the field’s data array may need to be squeezed concurrently.

Parameters :
dims : str or sequence of strs

The identifier of the dimension to remove.

Returns :

None

Examples

>>> d.dimension_sizes
{'dim0': 12, 'dim1': 73, 'dim2': 1}
>>> d.dimensions
{'data': ['dim0', 'dim1', 'dim2'],
 'aux0': ['dim1', 'dim2'],
 'aux1': ['dim2', 'dim1'],
 'dim0': ['dim0'],
 'dim1': ['dim1'],
 'dim2': ['dim2'],
 'cm0' : ['dim1', 'dim2']}
>>> d.squeeze('dim2')
>>> d.dimension_sizes
{'dim0': 12, 'dim1': 73}
>>> d.dimensions
{'data': ['dim0', 'dim1', 'dim2'],
 'aux0': ['dim1'],
 'aux1': ['dim1'],
 'dim0': ['dim0'],
 'dim1': ['dim1'],
 'cm0' : ['dim1']}

Previous topic

cf.Domain.setdefault

Next topic

cf.Domain.update

This Page