cf.Data.square

Data.square(dtype=None, inplace=False)[source]

Calculate the element-wise square.

New in version 3.14.0.

See also

sqrt, sum_of_squares

Parameters
dtype: data-type, optional

Overrides the data type of the output arrays. A matching precision of the calculation should be chosen. For example, a dtype of 'int32' is only allowed when the input values are integers.

inplace: bool, optional

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

Returns
Data or None

The element-wise square of the data, or None if the operation was in-place.

Examples

>>> d = cf.Data([[0, 1, 2.5, 3, 4]], 'K', mask=[[0, 0, 0, 1, 0]])
>>> print(d.array)
[[0.0 1.0 2.5 -- 4.0]]
>>> e = d.square()
>>> e
<CF Data(1, 5): [[0.0, ..., 16.0]] K2>
>>> print(e.array)
[[0.0 1.0 6.25 -- 16.0]]