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.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 (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 ndarrays.

  • 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 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 (Deprecated).

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)