cf.FieldList.unsqueeze

FieldList.unsqueeze(axes=None, i=False, **kwargs)[source]

For each field, insert size 1 axes into the data array.

By default all size 1 domain axes which are not spanned by the field’s data array are inserted, but existing size 1 axes may be selected for insertion.

For each field, the axes are selected with the axes parameter.

The axes are inserted into the slowest varying data array positions.

Examples 1:

Insert size all size 1 axes:

>>> g = f.unsqueeze()

Insert size 1 time axes:

>>> g = f.unsqueeze('T', size=1)
Parameters:
axes, kwargs : optional

Select axes. The axes parameter may be one, or a sequence, of:

  • None. If no kwargs arguments have been set then all axes are selected. This is the default.
  • An integer. Explicitly selects the axis corresponding to the given position in the list of axes of the field’s data array.

    Example:

    To select the third data array axis: axes=2. To select the last axis: axes=-1.

  • A slice object. Explicitly selects the axes corresponding to the given positions in the list of axes of the field’s data array.

    Example:

    To select the last three data array axes: axes=slice(-3, None)

  • A domain axis identifier. Explicitly selects this axis.

    Example:

    To select axis “dim1”: axes='dim1'.

  • Any value accepted by the items parameter of the field’s items method. Used in conjunction with the kwargs parameters to select the axes which span the items that would be identified by this call of the field’s items method: f.items(items=axes, axes=None, **kwargs). See cf.Field.items for details.

    Example:

    To select the axes spanned by one dimensionsal time coordinates: f.unsqueeze('T', ndim=1).

If axes is a sequence of any combination of the above then the selected axes are the union of those selected by each element of the sequence. If the sequence is empty then no axes are selected.

i : bool, optional

If True then update the field list in place. By default a new field list is created. In either case, a field list is returned.

Returns:
out : cf.FieldList

For each field, the unsqueezed field.

Examples 2:
>>> print f
Data            : air_temperature(time, latitude, longitude)
Cell methods    : time: mean
Dimensions      : time(1) = [15] days since 1860-1-1
                : latitude(73) = [-90, ..., 90] degrees_north
                : longitude(96) = [0, ..., 356.25] degrees_east
                : height(1) = [2] m
Auxiliary coords:
>>> f.unsqueeze()
>>> print f
Data            : air_temperature(height, time, latitude, longitude)
Cell methods    : time: mean
Dimensions      : time(1) = [15] days since 1860-1-1
                : latitude(73) = [-90, ..., 90] degrees_north
                : longitude(96) = [0, ..., 356.25] degrees_east
                : height(1) = [2] m
Auxiliary coords: