cfdm.Data.insert_dimension

Data.insert_dimension(position=0, inplace=False)[source]

Expand the shape of the data array in place.

New in version (cfdm): 1.7.0

Parameters
position: int, optional

Specify the position that the new axis will have in the data array axes. By default the new axis has position 0, the slowest varying position.

inplace: bool, optional

If True then do the operation in-place and return None.

Returns
Data or None

The new data with expanded data axes, or None if the operation was in-place.

Examples

>>>
>>> d.shape
(19, 73, 96)
>>> d.insert_dimension(0).shape
(1, 96, 73, 19)
>>> d.insert_dimension(3).shape
(19, 73, 96, 1)
>>> d.insert_dimension(-1, inplace=True)
>>> d.shape
(19, 73, 1, 96)