Warning

You are reading the documentation related to the development version. Go here if you are looking for the documentation of the stable release.

spectrochempy.cumsum

cumsum(dataset, dim=None, dtype=None)[source]

Return the cumulative sum of the elements along a given axis.

Parameters
  • dataset (array_like) – Calculate the cumulative 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.

Returns

sum – A new array containing the cumulative sum.

See also

sum

Sum array elements.

trapezoid

Integration of array values using the composite trapezoidal rule.

diff

Calculate the n-th discrete difference along given axis.

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])