xroms.vector#

Functions related to vectors.

Functions

rotate_vectors(x, y, angle[, isradians, ...])

Rotate vectors according to reference.

xroms.vector.rotate_vectors(x, y, angle, isradians=True, reference='xaxis', xgrid=None, hcoord='rho', attrs=None, **kwargs)[source]#

Rotate vectors according to reference.

Parameters:
  • x (Union[float, np.array, xr.DataArray]) – x component of vector to be rotated

  • y (Union[float, np.array, xr.DataArray]) – y component of vector to be rotated

  • angle (Union[float,np.array,xr.DataArray]) – Angle by which to rotate x and y.

  • isradians (bool, optional) – True if angle is in radians, False for degrees, by default True

  • reference (str, optional) – Which reference is angle coming from? “xaxis” if angle is the angle between the x-axis and x (positive going counter clockwise, 0 at the x axis), or “compass” if angle is 0 at north on a compass and is positive going clockwise, by default “xaxis”.

  • xgrid (Optional[xgcm.grid.Grid], optional) – xgcm grid, by default None. If not input, any grid changing using hcoord or kwargs is ignored.

  • hcoord (string, optional.) – Name of horizontal grid to interpolate output to. Options are ‘rho’, ‘psi’, ‘u’, ‘v’. Default ‘rho’.

  • attrs (Optional[dict], optional) – Dict containing two keys, “x” and “y”, each a dict of attributes, by default None. Attributes should include “name”, “standard_name”, “long_name”, “units”, if possible. “name” is required.

  • kwargs – will be passed on to xroms.to_grid().

Returns:

x and y, rotated by angle.

Return type:

Tuple[xr.DataArray]