diff

metpy.units.diff(x, **kwargs)[source]

Calculate the n-th discrete difference along given axis.

Wraps numpy.diff() to handle units.

Parameters:
  • x (array-like) – Input data
  • n (int, optional) – The number of times values are differenced.
  • axis (int, optional) – The axis along which the difference is taken, default is the last axis.
Returns:

diff (ndarray) – The n-th differences. The shape of the output is the same as a except along axis where the dimension is smaller by n. The type of the output is the same as that of the input.

See also

numpy.diff()