cf.DomainAncillary.round¶
-
DomainAncillary.
round
(decimals=0, bounds=True, i=False)[source]¶ Round the data array.
Data elements are evenly rounded to the given number of decimals.
Note
Values exactly halfway between rounded decimal values are rounded to the nearest even value. Thus 1.5 and 2.5 round to 2.0, -0.5 and 0.5 round to 0.0, etc. Results may also be surprising due to the inexact representation of decimal fractions in the IEEE floating point standard and errors introduced when scaling by powers of ten.
New in version 1.1.4.
Examples 1: >>> g = f.round(2)
Parameters: - decimals:
int
, optional Number of decimal places to round to (0 by default). If decimals is negative, it specifies the number of positions to the left of the decimal point.
- bounds: optional
Ignored.
- i:
bool
, optional If True then update the domain ancillary in place. By default a new domain ancillary is created. In either case, a domain ancillary is returned.
Returns: - out:
cf.DomainAncillary
The domain ancillary with rounded data array values.
Examples 2: >>> print f.array [-1.81, -1.41, -1.01, -0.91, 0.09, 1.09, 1.19, 1.59, 1.99]) >>> print f.round().array [-2., -1., -1., -1., 0., 1., 1., 2., 2.] >>> print f.round(1).array [-1.8, -1.4, -1. , -0.9, 0.1, 1.1, 1.2, 1.6, 2. ] >>> print f.round(-1).array [-0., -0., -0., -0., 0., 0., 0., 0., 0.]
- decimals: