trapz2d

mdtools.numpy_helper_functions.trapz2d(z, x=None, y=None, dx=1, dy=1, xlim=None, ylim=None)[source]

Integrate z(x,y) within the given limits using numpy.trapz twice, first in y and then in x direction.

Parameters:
  • z (array_like) – Input array to integrate.

  • x, y (array_like, optional) – The sample points corresponding to the z values. If None (default), the sample points are assumed to be evenly spaced dx and dy apart.

  • dx, dy (scalar, optional) – The spacing between sample points when x or y is None.

  • xlim (array_like, optional) – Array of length 2 containing an upper and a lower integration boundary for integration in x direction. If None (default), no limits are applied. If you only want to apply an upper (lower) limit, set the lower (upper) limit to -np.inf (np.inf).

  • ylim (array_like, optional) – Array of length 2 containing upper and lower integration boundaries for integration in y direction. The boundaries can be either constant scalars or arrays of the same shape as x. The possibility to parse arrays can e.g. be used to parse y limits that depend on x. If None (default), no limits are applied. If you only want to apply an upper (lower) limit, set the lower (upper) limit to -np.inf (np.inf).

Returns:

trapz (float) – Definite integral as approximated by trapezoidal rule.