spectrochempy.simpson

simpson(dataset, *args, **kwargs)[source]

Integrate using the composite Simpson’s rule.

Wrapper of scpy.integrate.trapezoid.

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

integral – Definite integral as approximated using the composite Simpson’s rule.

Other Parameters
  • dim (int or str, optional, default: “x”) – Dimension along which to integrate. If an integer is provided, it is equivalent to the axis parameter for numpy arrays.

  • even (str {‘avg’, ‘first’, ‘last’}, optional, default is ‘avg’) –

    ‘avg’Average two results: 1) use the first N-2 intervals with

    a trapezoidal rule on the last interval and 2) use the last N-2 intervals with a trapezoidal rule on the first interval.

    ‘first’Use Simpson’s rule for the first N-2 intervals with

    a trapezoidal rule on the last interval.

    ‘last’Use Simpson’s rule for the last N-2 intervals with a

    trapezoidal rule on the first interval.

See also

simps

An alias of simpson.

trapezoid

Integrate using the composite simpson rule.

Example

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