cf.Field.trunc

Field.trunc(i=False)

Truncate the data array.

The truncated value of the scalar x, is the nearest integer i which is closer to zero than x is. I.e. the fractional part of the signed number x is discarded.

New in version 1.0.

See also

ceil, floor, rint

Examples 1:
>>> g = f.trunc()
Parameters:
i : bool, optional

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

Returns:
out : cf.Field

The field with truncated data array values.

Examples 2:
>>> print f.array
[-1.9 -1.5 -1.1 -1.   0.   1.   1.1  1.5  1.9]
>>> print f.trunc().array
[-1. -1. -1. -1.  0.  1.  1.  1.  1.]
>>> print f.array
[-1.9 -1.5 -1.1 -1.   0.   1.   1.1  1.5  1.9]
>>> print f.trunc(i=True).array
[-1. -1. -1. -1.  0.  1.  1.  1.  1.]
>>> print f.array
[-1. -1. -1. -1.  0.  1.  1.  1.  1.]