Skip to content

Commit 8d09bc2

Browse files
committed
Review changes: docs improvements; docstrings for cubelist combine methods.
1 parent cc74cda commit 8d09bc2

File tree

4 files changed

+61
-7
lines changed

4 files changed

+61
-7
lines changed

docs/src/userguide/loading_iris_cubes.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ into a single multidimensional cube.
1717

1818
.. hint::
1919

20-
There are some hints at :class:`iris.CombineOptions` on how Iris works to load
21-
fewer and larger cubes, along with user options that can aid in controlling the
22-
process.
20+
There are details at :class:`iris.CombineOptions` on how Iris works to load
21+
fewer and larger cubes : The :data:`iris.COMBINE_POLICY` object allows the user to
22+
control how cubes are combined during the loading process. See the documentation
23+
of the :class:`iris.CombineOptions` class for details.
2324

2425
The :py:func:`iris.load` function automatically recognises the format
2526
of the given files and attempts to produce Iris Cubes from their contents.

lib/iris/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@
1616
The :func:`load` function provides a simple way to explore data from
1717
the interactive Python prompt. It will convert the source data into
1818
:class:`Cubes <iris.cube.Cube>`, and combine those cubes into
19-
higher-dimensional cubes where possible
20-
(for which, please see :class:`iris.CombineOptions`).
19+
higher-dimensional cubes where possible.
20+
21+
.. note::
22+
23+
User control of the 'combine' process is provided via a specific
24+
:class:`iris.CombineOptions` object called :data:`iris.COMBINE_POLICY`.
25+
See the :class:`iris.CombineOptions` class for details.
2126
2227
The :func:`load_cube` and :func:`load_cubes` functions are similar to
2328
:func:`load`, but they raise an exception if the number of cubes is not

lib/iris/_combine.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ class CombineOptions(threading.local):
3939
4040
The individual configurable options are :
4141
42-
* ``equalise_cubes_kwargs`` = (dict)
42+
* ``equalise_cubes_kwargs`` = (dict or None)
4343
Specifies keywords for an :func:`iris.util.equalise_cubes` call, to be applied
44-
before any merge/concatenate step.
44+
before any merge/concatenate step. If ``None``, or empty, no equalisation step
45+
is performed.
4546
4647
* ``merge_concat_sequence`` = "m" / "c" / "cm" / "mc"
4748
Specifies whether to apply :meth:`~iris.cube.CubeList.merge`, or
@@ -361,6 +362,7 @@ def _combine_cubes(cubes: List[Cube], options: dict) -> CubeList:
361362

362363
eq_args = options.get("equalise_cubes_kwargs", None)
363364
if eq_args:
365+
# Skip missing (or empty) arg, as no effect : see `equalise_cubes`.
364366
from iris.util import equalise_cubes
365367

366368
equalise_cubes(cubelist, **eq_args)

lib/iris/cube.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,11 +638,57 @@ def concatenate(
638638
)
639639

640640
def combine(self, options: str | dict | None = None, **kwargs) -> CubeList:
641+
"""Combine cubes, as with :func:`iris.util.combine_cubes`.
642+
643+
Parameters
644+
----------
645+
options : str or dict, optional
646+
Either a standard "combine settings" name, i.e. one of the
647+
:data:`iris.CombineOptions.SETTINGS_NAMES`, or a dictionary of
648+
settings options, as described for :class:`~iris.CombineOptions`.
649+
Defaults to the current :meth:`~iris.CombineOptions.settings` of the
650+
:data:`iris.COMBINE_POLICY`.
651+
652+
kwargs : dict
653+
Individual option setting values, i.e. values for keys named in
654+
:data:`iris.CombineOptions.OPTION_KEYS`, as described for
655+
:meth:`~iris.CombineOptions.set`.
656+
These take precedence over those set by the `options` arg.
657+
658+
Returns
659+
-------
660+
:class:`CubeList`
661+
662+
"""
641663
from iris.util import combine_cubes
642664

643665
return combine_cubes(self, options, **kwargs)
644666

645667
def combine_cube(self, options: str | dict | None = None, **kwargs) -> CubeList:
668+
"""Combine to a single cube, with :func:`iris.util.combine_cubes`.
669+
670+
As :meth:`combine`, but raises a ValueError if the result is not a single cube.
671+
672+
Parameters
673+
----------
674+
options : str or dict, optional
675+
Either a standard "combine settings" name, i.e. one of the
676+
:data:`iris.CombineOptions.SETTINGS_NAMES`, or a dictionary of
677+
settings options, as described for :class:`~iris.CombineOptions`.
678+
Defaults to the current :meth:`~iris.CombineOptions.settings` of the
679+
:data:`iris.COMBINE_POLICY`.
680+
681+
kwargs : dict
682+
Individual option setting values, i.e. values for keys named in
683+
:data:`iris.CombineOptions.OPTION_KEYS`, as described for
684+
:meth:`~iris.CombineOptions.set`.
685+
These take precedence over those set by the `options` arg.
686+
687+
Returns
688+
-------
689+
Cube
690+
691+
"""
646692
result = self.combine(options, **kwargs)
647693
n_cubes = len(result)
648694
if n_cubes != 1:

0 commit comments

Comments
 (0)