Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f16409f
Remove unused 'unique' option from load collections and combine methods.
pp-mo Feb 20, 2025
2ff233c
Reinstate 'unique=False' in combine merges to fix load().
pp-mo Feb 20, 2025
713ed1b
Fix typing for combine submodule.
pp-mo Feb 24, 2025
797f698
More typing and other small improvements to combine code.
pp-mo Feb 24, 2025
97e3bd1
Move loading-specific parts from CombineOptions to LoadPolicy.
pp-mo Feb 24, 2025
7358b25
Fix LoadPolicy error handling + test.
pp-mo Feb 24, 2025
220180d
Properly support merge_unique, and add equalise_cubes.
pp-mo Feb 24, 2025
78a041d
Allow LoadPolicy.context with no settings arg.
pp-mo Feb 24, 2025
45e2944
Turn off varying-reference support for 'legacy' load setting only.
pp-mo Feb 24, 2025
3769b17
Implement combine_cube as util, and redirect test.
pp-mo Feb 24, 2025
63a2478
Small docs fixes.
pp-mo Feb 24, 2025
c313f94
Add functioning doctest example for combine_cubes.
pp-mo Feb 25, 2025
a79ea9d
Further doctest fixes.
pp-mo Feb 25, 2025
4c11653
Add cubelist combine methods.
pp-mo Feb 26, 2025
d2f4733
Better documentation of CombineOptions and LoadPolicy settings.
pp-mo Feb 26, 2025
ea9d82f
Recombine LoadPolicy into CombineOptions.
pp-mo Feb 26, 2025
75929b4
Fix doctest.
pp-mo Feb 26, 2025
e92b6e0
Rework CombineOptions.set() tests to cover context() method also.
pp-mo Feb 27, 2025
923e2c8
Add tests for cubelist combine functions (and fix).
pp-mo Feb 27, 2025
c8823c8
Add tests for individual combine control keywords.
pp-mo Feb 27, 2025
cc74cda
Added whatsnew, and minimal links in other docs sections.
pp-mo Feb 27, 2025
8d09bc2
Review changes: docs improvements; docstrings for cubelist combine me…
pp-mo Mar 3, 2025
23cb498
Merge branch 'main' into combine_cubes_2
pp-mo Mar 3, 2025
7f14f68
Tiny formatting correction.
pp-mo Mar 3, 2025
58103ed
Merge branch 'main' into combine_cubes_2
pp-mo Mar 6, 2025
857a4f5
Review changes: docs explain not to assign to iris.COMBINE_POLICY.
pp-mo Mar 6, 2025
811168b
Review changes: fix obsolete comments + todos in testcode.
pp-mo Mar 6, 2025
0c11048
Review changes: add test for string arg + kwargs.
pp-mo Mar 7, 2025
cdb0d83
Merge branch 'main' into combine_cubes_2
pp-mo Mar 7, 2025
b7d30f2
Merge branch 'main' into combine_cubes_2
pp-mo Mar 7, 2025
44bb2c6
Review changes: remove obsolete TODO notes.
pp-mo Mar 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/src/userguide/loading_iris_cubes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ Iris will attempt to return **as few cubes as possible**
by collecting together multiple fields with a shared standard name
into a single multidimensional cube.

.. hint::

There are details at :class:`iris.CombineOptions` on how Iris works to load
fewer and larger cubes : The :data:`iris.COMBINE_POLICY` object allows the user to
control how cubes are combined during the loading process. See the documentation
of the :class:`iris.CombineOptions` class for details.

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

Expand Down
24 changes: 22 additions & 2 deletions docs/src/whatsnew/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@ This document explains the changes made to Iris for this release
✨ Features
===========

#. `@pp-mo`_ renamed the :class:`iris.LoadPolicy` as :class:`iris.CombineOptions` and
:data:`iris.LOAD_POLICY` as :data:`iris.COMBINE_POLICY`, though the original names
remain functional (and refer to the same things) for now.
(:issue:`6203`, :pull:`6334`)

#. `@pp-mo`_ added new :meth:`~iris.cube.CubeList.combine` and
:meth:`~iris.cube.CubeList.combine_cube` methods of a :class:`~iris.cube.CubeList`
as an alternative way of accessing the :func:`~iris.util.combine_cubes` mechanism.
(:issue:`6203`, :pull:`6334`)

#. `@pp-mo`_ added a new utility function :func:`~iris.util.combine_cubes`, to give
general public access to the combine merge/concatenate mechanism introduced for
generalised loading support via :class:`iris.LoadPolicy` in the Iris 3.11 release.
(:issue:`6203`, :pull:`6334`)

#. `@pp-mo`_ overhauled the :class:`iris.LoadPolicy` facility by adding a new
``equalise_cubes_kwarg`` keyword, enabling it to call the
:func:`~iris.util.equalise_cubes` utility function as one of its processing stages.
(:issue:`6203`, :pull:`6334`)

#. `@pp-mo`_ added a new utility function :func:`~iris.util.equalise_cubes`, to help
with aligning cubes so they can merge / concatenate.
(:issue:`6248`, :pull:`6257`)
Expand All @@ -48,11 +68,11 @@ This document explains the changes made to Iris for this release
However, :meth:`~iris.cube.Cube.transpose` will work, as will
:meth:`~iris.cube.Cube.copy`. Note that, ``cube.copy(data=iris.DATALESS)``
will provide a dataless copy of a cube. (:issue:`4447`, :pull:`6253`)

#. `@ESadek-MO`_ added the :mod:`iris.quickplot` ``footer`` kwarg to
render text in the bottom right of the plot figure.
(:issue:`6247`, :pull:`6332`)


🐛 Bugs Fixed
=============
Expand Down
22 changes: 17 additions & 5 deletions lib/iris/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
:class:`Cubes <iris.cube.Cube>`, and combine those cubes into
higher-dimensional cubes where possible.

.. note::

User control of the 'combine' process is provided via a specific
:class:`iris.CombineOptions` object called :data:`iris.COMBINE_POLICY`.
See the :class:`iris.CombineOptions` class for details.

The :func:`load_cube` and :func:`load_cubes` functions are similar to
:func:`load`, but they raise an exception if the number of cubes is not
what was expected. They are more useful in scripts, where they can
Expand Down Expand Up @@ -94,14 +100,13 @@ def callback(cube, field, filename):
import threading
from typing import Callable, Literal

from iris._combine import COMBINE_POLICY as _COMBINE_POLICY
from iris._combine import CombineOptions
import iris._constraints
import iris.config
import iris.io
from iris.io import save
from iris.loading import LOAD_POLICY as _LOAD_POLICY
from iris.loading import (
CombineOptions,
LoadPolicy,
load,
load_cube,
load_cubes,
Expand All @@ -111,8 +116,14 @@ def callback(cube, field, filename):
# NOTE: we make an independent local 'LOAD_POLICY' definition here, just so that we
# can ensure an entry for it in our API documentation page.

#: A control object containing the current file loading strategy options.
LOAD_POLICY = _LOAD_POLICY
#: An object to control default cube combination and loading options
COMBINE_POLICY = _COMBINE_POLICY

#: An alias for the :class:`~iris._combine.CombineOptions` class.
LoadPolicy = CombineOptions

#: An alias for the :data:`~iris.COMBINE_POLICY` object.
LOAD_POLICY = _COMBINE_POLICY


from ._deprecation import IrisDeprecation, warn_deprecated
Expand All @@ -132,6 +143,7 @@ def callback(cube, field, filename):
# Restrict the names imported when using "from iris import *"
__all__ = [
"AttributeConstraint",
"COMBINE_POLICY",
"CombineOptions",
"Constraint",
"DATALESS",
Expand Down
Loading
Loading