uxarray.UxDataArray.divergence

uxarray.UxDataArray.divergence#

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

Computes the divergence of the vector field defined by this UxDataArray and other, in the horizontal direction (i.e., along the unstructured grid dimension).

The formula is: div(u, v) = ∂u/∂x + ∂v/∂y - v·tan(φ)/a, where u, x correspond to the zonal direction; v, y the meridional direction; φ=latitude; and a=sphere radius.

Parameters:
  • self (UxDataArray) – The zonal (u) component of the vector field. Data must be face-centered.

  • other (UxDataArray) – The meridional (v) component of the vector field. Data must be face-centered, and must have other.uxgrid == self.uxgrid.

  • scale_by_radius (bool, default=True) –

    Whether to divide unit-sphere derivatives by uxgrid.sphere_radius. When True (and the grid’s sphere_radius is set correctly), the result carries physical units: [u units]/meter (e.g. result has units of 1/s if u represents velocity). When False (or if the grid’s sphere_radius is set to 1.0), the result caries per-radian units: [u units]/radian. (e.g. result has units of (m/s)/rad if u represents velocity).

    CAUTION: this scaling does not account for any radius increases due to vertical levels; it simply divides by uxgrid.sphere_radius.

  • **kw_unused – Currently unused; passing passing “units” will emit a DeprecationWarning, while passing anything else will raise a TypeError.

Returns:

divergence – The divergence of the vector field (self, other), as a UxDataArray. Units determined by scale_by_radius.

Return type:

UxDataArray

Notes

The divergence is computed using the finite volume method. 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)