spectrochempy.simpson
- simpson(dataset, *args, **kwargs)[source]
Integrate using the composite Simpson’s rule.
Wrapper of
scpy.integrate.simpson.Performs the integration along the last or given dimension.
If there are an even number of samples,
N, then there are an odd number of intervals (N-1), but Simpson’s rule requires an even number of intervals. The parameter ‘even’ controls how this is handled.- Parameters:
dataset (
NDDataset) – Dataset to be integrated.**kwargs – Additional keywords parameters. See Other Parameters.
- Returns:
NDDataset– Definite integral as approximated using the composite Simpson’s rule.- Other Parameters:
dim (
intorstr, optional, default:"x") – Dimension along which to integrate. If an integer is provided, it is equivalent to thenumpy.axisparameter for `~numpy.ndarray`s.even (any of [
'avg','first','last'}, optional, default:'avg') –'avg': Average two results: 1) use the first N-2 intervals with a trapezoidal rule on the last interval and 2) use the lastN-2intervals with a trapezoidal rule on the first interval.'first': Use Simpson’s rule for the firstN-2intervals with a trapezoidal rule on the last interval.'last': Use Simpson’s rule for the lastN-2intervals with a trapezoidal rule on the first interval.
See also
simpsAn alias of simpson (Deprecated).
trapezoidIntegrate using the composite simpson rule.
Example
>>> dataset = scp.read('irdata/nh4y-activation.spg') >>> dataset[:,1250.:1800.].simpson() NDDataset: [float64] a.u..cm^-1 (size: 55)