cf.Field.insert_dimension

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

Insert a size 1 axis into the data array.

New in version 3.0.0.

Parameters:
axis:

Select the domain axis to, defined by that which would be selected by passing the given axis description to a call of the field construct’s domain_axis method. For example, for a value of 'X', the domain axis construct returned by f.domain_axis('X')) is selected.

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.

inplace: bool, optional

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

Returns:
Field, or None

The field construct with expanded data, or None of the operation was in-place.

Examples:

>>> g = f.insert_dimension('time')
>>> g = f.insert_dimension('time', 2)
>>> g = f.insert_dimension(1)
>>> g = f.insert_dimension('domainaxis2', -1)
>>> f.insert_dimension('Z', inplace=True)