cfdm.Data.insert_dimension

Data.insert_dimension(position=0)[source]

Expand the shape of the data array.

Inserts a new size 1 axis, corresponding to a given position in the data array shape.

New in version 1.7.0.

See also

squeeze, transpose

Parameters:
position: int, optional

Specify the position that the new axis will have in the data array. By default the new axis has position 0, the slowest varying position. Negative integers counting from the last position are allowed.

Parameter example:

position=2

Parameter example:

position=-1

Returns:
Data

The new data array with expanded data axes.

Examples:

>>> d.shape
(19, 73, 96)
>>> d.insert_dimension('domainaxis3').shape
(1, 96, 73, 19)
>>> d.insert_dimension('domainaxis3', position=3).shape
(19, 73, 96, 1)
>>> d.insert_dimension('domainaxis3', position=-1).shape
(19, 73, 1, 96)