uxarray.UxDataArray.divergence

uxarray.UxDataArray.divergence#

UxDataArray.divergence(other, **kwargs)#

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

Parameters:
  • other (UxDataArray) – The second component of the vector field. This UxDataArray represents the first component.

  • **kwargs – Additional keyword arguments (reserved for future use).

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.

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)