@@ -376,26 +376,35 @@ def advection(
376376 parallel_scale = None ,
377377 meridional_scale = None
378378):
379- r"""Calculate the advection of a scalar field by the wind.
379+ r"""Calculate the advection of a scalar field by 1D, 2D, or 3D winds.
380+
381+ If ``scalar`` is a `xarray.DataArray`, only ``u``, ``v``, and/or ``w`` are required
382+ to compute advection. The horizontal and vertical spacing (``dx``, ``dy``, and ``dz``)
383+ and axis numbers (``x_dim``, ``y_dim``, and ``z_dim``) are automatically inferred from
384+ ``scalar``. But if ``scalar`` is a `pint.Quantity`, the horizontal and vertical
385+ spacing ``dx``, ``dy``, and ``dz`` needs to be provided, and each array should have one
386+ item less than the size of ``scalar`` along the applicable axis. Additionally, ``x_dim``,
387+ ``y_dim``, and ``z_dim`` are required if ``scalar`` does not have the default
388+ [..., Z, Y, X] ordering. ``dx``, ``dy``, ``dz``, ``x_dim``, ``y_dim``, and ``z_dim``
389+ are keyword-only arguments.
390+
391+ ``parallel_scale`` and ``meridional_scale`` specify the parallel and meridional scale of
392+ map projection at data coordinate, respectively. They are optional when (a)
393+ `xarray.DataArray` with latitude/longitude coordinates and MetPy CRS are used as input
394+ or (b) longitude, latitude, and crs are given. If otherwise omitted, calculation
395+ will be carried out on a Cartesian, rather than geospatial, grid. Both are keyword-only
396+ arguments.
380397
381398 Parameters
382399 ----------
383400 scalar : `pint.Quantity` or `xarray.DataArray`
384- Array (with N-dimensions) with the quantity to be advected. Use `xarray.DataArray` to
385- have dimension ordering automatically determined, otherwise, use default
386- [..., Z, Y, X] ordering or specify \*_dim keyword arguments.
387- u, v, w : `pint.Quantity` or `xarray.DataArray` or None
388- N-dimensional arrays with units of velocity representing the flow, with a component of
389- the wind in each dimension. For 1D advection, use 1 positional argument (with `dx` for
390- grid spacing and `x_dim` to specify axis if not the default of -1) or use 1 applicable
391- keyword argument (u, v, or w) for proper physical dimension (with corresponding `d\*`
392- for grid spacing and `\*_dim` to specify axis). For 2D/horizontal advection, use 2
393- positional arguments in order for u and v winds respectively (with `dx` and `dy` for
394- grid spacings and `x_dim` and `y_dim` keyword arguments to specify axes), or specify u
395- and v as keyword arguments (grid spacings and axes likewise). For 3D advection,
396- likewise use 3 positional arguments in order for u, v, and w winds respectively or
397- specify u, v, and w as keyword arguments (either way, with `dx`, `dy`, `dz` for grid
398- spacings and `x_dim`, `y_dim`, and `vertical_dim` for axes).
401+ The quantity (an N-dimensional array) to be advected.
402+ u : `pint.Quantity` or `xarray.DataArray` or None
403+ The wind component in the x dimension. An N-dimensional array.
404+ v : `pint.Quantity` or `xarray.DataArray` or None
405+ The wind component in the y dimension. An N-dimensional array.
406+ w : `pint.Quantity` or `xarray.DataArray` or None
407+ The wind component in the z dimension. An N-dimensional array.
399408
400409 Returns
401410 -------
@@ -404,27 +413,29 @@ def advection(
404413
405414 Other Parameters
406415 ----------------
407- dx, dy, dz: `pint.Quantity` or None, optional
408- Grid spacing in applicable dimension(s). If using arrays, each array should have one
409- item less than the size of `scalar` along the applicable axis. If `scalar` is an
410- `xarray.DataArray`, these are automatically determined from its coordinates, and are
411- therefore optional. Required if `scalar` is a `pint.Quantity`. These are keyword-only
412- arguments.
413- x_dim, y_dim, vertical_dim: int or None, optional
414- Axis number in applicable dimension(s). Defaults to -1, -2, and -3 respectively for
415- (..., Z, Y, X) dimension ordering. If `scalar` is an `xarray.DataArray`, these are
416- automatically determined from its coordinates. These are keyword-only arguments.
416+ dx: `pint.Quantity` or None, optional
417+ Grid spacing in the x dimension.
418+ dy: `pint.Quantity` or None, optional
419+ Grid spacing in the y dimension.
420+ dz: `pint.Quantity` or None, optional
421+ Grid spacing in the z dimension.
422+ x_dim: int or None, optional
423+ Axis number in the x dimension. Defaults to -1 for (..., Z, Y, X) dimension ordering.
424+ y_dim: int or None, optional
425+ Axis number in the y dimension. Defaults to -2 for (..., Z, Y, X) dimension ordering.
426+ vertical_dim: int or None, optional
427+ Axis number in the z dimension. Defaults to -3 for (..., Z, Y, X) dimension ordering.
417428 parallel_scale : `pint.Quantity`, optional
418- Parallel scale of map projection at data coordinate. Optional if `xarray.DataArray`
419- with latitude/longitude coordinates and MetPy CRS used as input. Also optional if
420- longitude, latitude, and crs are given. If otherwise omitted, calculation will be
421- carried out on a Cartesian, rather than geospatial, grid. Keyword-only argument.
429+ Parallel scale of map projection at data coordinate.
422430 meridional_scale : `pint.Quantity`, optional
423- Meridional scale of map projection at data coordinate. Optional if `xarray.DataArray`
424- with latitude/longitude coordinates and MetPy CRS used as input. Also optional if
425- longitude, latitude, and crs are given. If otherwise omitted, calculation will be
426- carried out on a Cartesian, rather than geospatial, grid. Keyword-only argument.
431+ Meridional scale of map projection at data coordinate.
432+
433+ Notes
434+ -----
435+ This implements the advection of a scalar quantity by wind:
427436
437+ .. math:: \mathbf{u} \cdot \nabla = u \frac{\partial}{\partial x}
438+ + v \frac{\partial}{\partial y} + w \frac{\partial}{\partial z}
428439
429440 .. versionchanged:: 1.0
430441 Changed signature from ``(scalar, wind, deltas)``
0 commit comments