Data.integrate

Data.integrate(xcol: str | int | ~re.Pattern | ~typing.Sequence[int | str | ~re.Pattern] | None = None, ycol: str | int | ~re.Pattern | ~typing.Sequence[int | str | ~re.Pattern] | None = None, result: bool | None = None, header: str | None = None, result_name: str | None = None, output: str = 'data', bounds: ~typing.Callable = <function <lambda>>, method: str = 'simpson', **kwargs: ~typing.Mapping[str, ~typing.Any]) Data

Integrate a column of data, optionally returning the cumulative integral.

Parameters:
  • datafile (Data) – If not being used as a bound menthod, specifies the instance of Data to work with.

  • xcol (index) – The X data column index (or header)

  • ycol (index) – The Y data column index (or header)

Keyword Arguments:
  • result (index or None) – Either a column index (or header) to overwrite with the cumulative data, or True to add a new column or None to not store the cumulative result.

  • result_name (str) – The metadata name for the final result

  • header (str) – The name of the header for the results column.

  • output (Str) – What to return - ‘data’ (default) - this object, ‘result’: final result

  • bounds (callable) – A function that evaluates for each row to determine if the data should be integrated over.

  • method (str) – Either “simpson” (default) or “trapezoid” to select the integration method. See Note.

  • **kwargs – Other keyword arguments are fed direct to the scipy.integrate.cumtrapz method

Returns:

(Stoner.Data) – The newly modified Data object.

Note

This is a pass through to the scipy.integrate.cumulative_simpson() or scipy.integrate.cumulative_trapezoid() function depending on the value of method and whether the x-data is monotonically increasing. If it isnot and simpson has been requested, a warning is issued and it falls back to trapezoidal integration.