uxarray.UxDataArray.divergence

uxarray.UxDataArray.divergence#

UxDataArray.divergence(other, scale_by_radius=True, **kwargs)#

Computes the divergence of the vector field defined by this UxDataArray and other.

Parameters:
  • other (UxDataArray) – The second (meridional, v) component of the vector field; self is the first (zonal, u) component.

  • scale_by_radius (bool, default=True) – Divide unit-sphere derivatives by uxgrid.sphere_radius. When True (and the grid has a sphere_radius attribute) the result carries physical, per-meter units (e.g. 1/s for a velocity field); when False the result is left on the unit sphere (per radian).

  • **kwargs – Additional keyword arguments. units may be passed to override the automatically inferred units.

Returns:

divergence – UxDataArray containing the divergence of the vector field.

Return type:

UxDataArray

Notes

The divergence is computed using the finite volume method. For a vector field V = (u, v), where u and v are the components represented by this UxDataArray and other respectively, the divergence is calculated as div(V) = ∂u/∂x + ∂v/∂y.

The implementation uses edge-centered gradients and face-centered divergence calculation following the discrete divergence theorem. By default the underlying gradients are divided by uxgrid.sphere_radius; pass scale_by_radius=False for per-radian (unit-sphere) output.

Example

>>> u_component = uxds["u_wind"]  # First component of vector field
>>> v_component = uxds["v_wind"]  # Second component of vector field
>>> div_field = u_component.divergence(v_component)