first_derivative#

rojak.core.derivatives.first_derivative(array, grid_spacing_in_meters, axis)[source]#

First derivative of array along axis, with respect to physical distance

The (possibly irregular) grid spacing along axis is used to build the coordinate values that the central difference derivative (numpy.gradient()/dask.array.gradient()) is taken with respect to, so the result is a derivative with respect to true distance (in meters) rather than grid index.

Parameters:
  • array (DataArray) – Array to differentiate

  • grid_spacing_in_meters (NDArray | DataArray) – Spacing (in meters) between adjacent points along axis, of length array.shape[axis] - 1

  • axis (int) – Axis of array to differentiate along

Returns:

Derivative of array along axis, with the same shape as array

Return type:

DataArray