Data.gradient(axis, *, channel=0)[source]

Compute the gradient along one axis.

New channels have names <channel name>_<axis name>_gradient.

  • axis (int or str) – The axis to differentiate along. If given as an integer, the axis in the underlying array is used, and unitary spacing is assumed. If given as a string, the axis must exist, and be a 1D array-aligned axis. (i.e. have a shape with a single value which is not 1) The axis to collapse along is inferred from the shape of the axis.

  • channel (int or str) – The channel to differentiate. Default is the first channel.