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;
selfis the first (zonal, u) component.scale_by_radius (bool, default=True) – Divide unit-sphere derivatives by
uxgrid.sphere_radius. WhenTrue(and the grid has asphere_radiusattribute) the result carries physical, per-meter units (e.g.1/sfor a velocity field); whenFalsethe result is left on the unit sphere (per radian).**kwargs – Additional keyword arguments.
unitsmay be passed to override the automatically inferred units.
- Returns:
divergence – UxDataArray containing the divergence of the vector field.
- Return type:
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; passscale_by_radius=Falsefor 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)