UxDataArray.gradient(normalize=False, use_magnitude=True)#

Computes the horizontal gradient of a data variable residing on an unstructured grid.

Currently only supports gradients of face-centered data variables, with the resulting gradient being stored on each edge. The gradient of a node-centered data variable can be approximated by computing the nodal average and then computing the gradient.

The aboslute value of the gradient is used, since UXarray does not yet support representing the direction of the gradient.

The expression for calculating the gradient on each edge comes from Eq. 22 in Ringler et al. (2010), J. Comput. Phys.

Code is adapted from theweathermanda/MPAS_utilities

  • use_magnitude (bool, default=True) – Whether to use the magnitude (aboslute value) of the resulting gradient

  • normalize (bool, default=None) – Whether to normalize (l2) the resulting gradient


Face-centered variable >>> uxds[‘var’].gradient() Node-centered variable >>> uxds[‘var’].nodal_average().gradient()