spectrochempy.trapezoid

trapezoid(dataset, **kwargs)[source]

Integrate using the composite trapezoidal rule.

Wrapper of scipy.integrate.trapezoid.

Performs the integration along the last or given dimension.

Parameters
  • dataset (NDDataset) – Dataset to be integrated.

  • **kwargs – Additional keywords parameters. See Other Parameters.

Returns

NDDataset – Definite integral as approximated by trapezoidal rule.

Notes

SpectroChemPy does not publish an integral for a slice whose contribution is incomplete. A masked point is a scientific exclusion: an output slice is integrated normally, and is not masked, when it was built without any masked point. A slice that used at least one masked point, including a fully masked slice, is instead published as a masked value with a raw numpy.nan.

No estimate of the missing area is made, so masked points are not replaced, removed or interpolated. The values hidden under the mask never reach the quadrature, so they cannot influence a result nor overflow it.

The result mask is always compatible with the result shape: a 1D input yields a zero-dimensional result with a scalar mask, and an unmasked input yields the canonical unmasked numpy.False_ mask.

Other Parameters

dim (int or str, optional, default: "x") – Dimension along which to integrate. If an integer is provided, it is equivalent to the numpy axis parameter for numpy.ndarray. The dims and axis keywords are accepted as equivalent synonyms of dim.

See also

simpson

Integrate using the composite simpson rule.

Example

>>> dataset = scp.read('irdata/nh4y-activation.spg')
>>> dataset[:,1250.:1800.].trapezoid()
NDDataset: [float64] a.u..cm^-1 (size: 55)