spectrochempy.sum¶
- sum(dataset, dim=None, dtype=None, keepdims=False)[source]¶
Sum of array elements over a given axis.
- Parameters
dataset (array_like) – Calculate the sum of these values.
dim (None or int or dimension name , optional) –
- Dimension or dimensions along which to operate. By default, flattened input
is used.
dtype (dtype, optional) – Type to use in computing the standard deviation. For arrays of integer type the default is float64, for arrays of float types it is the same as the array type.
keepdims (bool, optional) – If this is set to True, the dimensions which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.
- Returns
sum – A new array containing the sum.
See also
Examples
>>> nd = scp.read('irdata/nh4y-activation.spg') >>> nd NDDataset: [float64] a.u. (shape: (y:55, x:5549)) >>> scp.sum(nd) <Quantity(381755.783, 'absorbance')> >>> scp.sum(nd, keepdims=True) NDDataset: [float64] a.u. (shape: (y:1, x:1)) >>> m = scp.sum(nd, dim='y') >>> m NDDataset: [float64] a.u. (size: 5549) >>> m.data array([ 100.7, 100.7, ..., 74, 73.98])