@@ -488,7 +488,7 @@ def __init__(
488488 aggregation. Note that, it need not support all features of the
489489 main operation, but should raise an error in unhandled cases.
490490
491- Additional kwargs::
491+ Additional kwargs:
492492 Passed through to :data:`call_func`, :data:`lazy_func`, and
493493 :data:`units_func`.
494494
@@ -720,8 +720,9 @@ def __init__(self, units_func=None, **kwargs):
720720 Returns an :class:`cf_units.Unit`, or a
721721 value that can be made into one.
722722
723- Additional kwargs::
724- Passed through to :data:`call_func` and :data:`lazy_func`.
723+ Additional kwargs:
724+ Passed through to :data:`call_func`, :data:`lazy_func`, and
725+ :data:`units_func`.
725726
726727 This aggregator can used by cube aggregation methods such as
727728 :meth:`~iris.cube.Cube.collapsed` and
@@ -961,13 +962,24 @@ def __init__(self, units_func=None, lazy_func=None, **kwargs):
961962 Returns an :class:`cf_units.Unit`, or a
962963 value that can be made into one.
963964
965+ If the aggregator is used by a cube aggregation method (e.g.,
966+ :meth:`~iris.cube.Cube.collapsed`,
967+ :meth:`~iris.cube.Cube.aggregated_by`,
968+ :meth:`~iris.cube.Cube.rolling_window`), a keyword argument
969+ `_weights_units` is provided to this function to allow updating
970+ units based on the weights. `_weights_units` is determined from the
971+ `weights` given to the aggregator (``None`` if no weights are
972+ given). See :ref:`user guide <cube-statistics-collapsing-average>`
973+ for an example of weighted aggregation that changes units.
974+
964975 * lazy_func (callable or None):
965976 An alternative to :data:`call_func` implementing a lazy
966977 aggregation. Note that, it need not support all features of the
967978 main operation, but should raise an error in unhandled cases.
968979
969- Additional kwargs::
970- Passed through to :data:`call_func` and :data:`lazy_func`.
980+ Additional kwargs:
981+ Passed through to :data:`call_func`, :data:`lazy_func`, and
982+ :data:`units_func`.
971983
972984 This aggregator can used by cube aggregation methods such as
973985 :meth:`~iris.cube.Cube.collapsed` and
@@ -1090,7 +1102,7 @@ class WeightedAggregator(Aggregator):
10901102 def __init__ (
10911103 self , cell_method , call_func , units_func = None , lazy_func = None , ** kwargs
10921104 ):
1093- """
1105+ r """
10941106 Create a weighted aggregator for the given :data:`call_func`.
10951107
10961108 Args:
@@ -1099,20 +1111,38 @@ def __init__(
10991111 Cell method string that supports string format substitution.
11001112
11011113 * call_func (callable):
1102- Data aggregation function. Call signature `(data, axis, **kwargs)`.
1114+ Data aggregation function. Call signature `(data, axis,
1115+ \**kwargs)`.
11031116
11041117 Kwargs:
11051118
11061119 * units_func (callable):
1107- Units conversion function.
1120+ | *Call signature*: (units, \**kwargs)
1121+
1122+ If provided, called to convert a cube's units.
1123+ Returns an :class:`cf_units.Unit`, or a
1124+ value that can be made into one.
1125+ To ensure backwards-compatibility, also accepts a callable with
1126+ call signature (units).
1127+
1128+ If the aggregator is used by a cube aggregation method (e.g.,
1129+ :meth:`~iris.cube.Cube.collapsed`,
1130+ :meth:`~iris.cube.Cube.aggregated_by`,
1131+ :meth:`~iris.cube.Cube.rolling_window`), a keyword argument
1132+ `_weights_units` is provided to this function to allow updating
1133+ units based on the weights. `_weights_units` is determined from the
1134+ `weights` given to the aggregator (``None`` if no weights are
1135+ given). See :ref:`user guide <cube-statistics-collapsing-average>`
1136+ for an example of weighted aggregation that changes units.
11081137
11091138 * lazy_func (callable or None):
11101139 An alternative to :data:`call_func` implementing a lazy
11111140 aggregation. Note that, it need not support all features of the
11121141 main operation, but should raise an error in unhandled cases.
11131142
11141143 Additional kwargs:
1115- Passed through to :data:`call_func` and :data:`lazy_func`.
1144+ Passed through to :data:`call_func`, :data:`lazy_func`, and
1145+ :data:`units_func`.
11161146
11171147 """
11181148 Aggregator .__init__ (
0 commit comments