Skip to content

Commit e3eec6f

Browse files
committed
Expand documentation.
1 parent 1c4f14c commit e3eec6f

File tree

4 files changed

+116
-2
lines changed

4 files changed

+116
-2
lines changed
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
.. _dataless-cubes:
2+
3+
==============
4+
Dataless Cubes
5+
==============
6+
It is possible for a cube to exist without a data payload.
7+
In this case ``cube.data`` is ``None``, instead of containing an array (real or lazy) as
8+
usual.
9+
10+
This can be useful when the cube is used purely as a placeholder for metadata, e.g. to
11+
represent a combination of coordinates.
12+
13+
Most notably, dataless cubes can be used as the target "grid cube" for most regridding
14+
schemes, since in that case the cube's coordinates are all that the method uses.
15+
See also :meth:`iris.util.make_gridcube`.
16+
17+
18+
Properties of dataless cubes
19+
----------------------------
20+
21+
* ``cube.shape`` is unchanged
22+
* ``cube.data`` == ``None``
23+
* ``cube.dtype`` == ``None``
24+
* ``cube.core_data()`` == ``cube.lazy_data()`` == ``None``
25+
* ``cube.is_dataless()`` == ``True``
26+
* ``cube.has_lazy_data()`` == ``False``
27+
28+
29+
Cube creation
30+
-------------
31+
You can create a dataless cube with the :meth:`~iris.cube.Cube` constructor
32+
(i.e. ``__init__`` call), by specifying the ``shape`` keyword in place of ``data``.
33+
If both are specified, an error is raised (even if data and shape are compatible).
34+
35+
36+
Data assignment
37+
---------------
38+
You can make an existing cube dataless, by setting ``cube.data = None``.
39+
The data array is simply discarded.
40+
41+
42+
Cube copy
43+
---------
44+
The syntax that allows you to replace data on copying,
45+
e.g. ``cube2 = cube.copy(new_data)``, has now extended to accept the special value
46+
:data:`iris.DATALESS`.
47+
48+
So, ``cube2 = cube.copy(iris.DATALESS)`` makes ``cube2`` a
49+
dataless copy of ``cube``.
50+
This is equivalent to ``cube2 = cube.copy(); cube2.data = None``.
51+
52+
53+
Save and Load
54+
-------------
55+
The netcdf file interface can save and re-load dataless cubes correctly.
56+
See : :ref:`netcdf_dataless`.
57+
58+
59+
.. _dataless_merge:
60+
61+
Merging
62+
-------
63+
Merging is fully supported for dataless cubes, including combining them with "normal"
64+
cubes.
65+
66+
* in all cases, the result has the same shape and metadata as if the same cubes had
67+
data.
68+
* Merging multiple dataless cubes produces a dataless result.
69+
* Merging dataless and non-dataless cubes results in a partially 'missing' data array,
70+
i.e. the relevant sections are filled with masked data.
71+
* Laziness is also preserved.
72+
73+
74+
Operations NOT supported
75+
-------------------------
76+
Dataless cubes are relatively new, and only partly integrated with Iris cube operations
77+
generally.
78+
79+
The following are some of the notable features which do *not* support dataless cubes,
80+
at least as yet :
81+
82+
* plotting
83+
84+
* cube arithmetic
85+
86+
* statistics
87+
88+
* concatenation
89+
90+
* :meth:`iris.cube.CubeList.realise_data`
91+
92+
* various :class:`~iris.cube.Cube` methods, including at least:
93+
94+
* :meth:`~iris.cube.Cube.convert_units`
95+
96+
* :meth:`~iris.cube.Cube.subset`
97+
98+
* :meth:`~iris.cube.Cube.intersection`
99+
100+
* :meth:`~iris.cube.Cube.slices`
101+
102+
* :meth:`~iris.cube.Cube.interpolate`
103+
104+
* :meth:`~iris.cube.Cube.regrid`
105+
Note: in this case the target ``grid`` can be dataless, but not the source
106+
(``self``) cube.

docs/src/further_topics/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Extra information on specific technical issues.
1515
lenient_maths
1616
um_files_loading
1717
missing_data_handling
18+
dataless_cubes
1819
netcdf_io
1920
dask_best_practices/index
2021
ugrid/index

docs/src/whatsnew/latest.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ This document explains the changes made to Iris for this release
4040
:func:`~iris.fileformats.netcdf.saver.save_mesh` also supports ``zlib``
4141
compression. (:issue:`6565`, :pull:`6728`)
4242

43+
#. `@pp-mo`_ added the ability to merge dataless cubes. This also means they can be
44+
re-loaded normally with :meth:`iris.load`. See: :ref:`dataless_merge`.
45+
(:issue:`5770`, :pull:`6581`)
46+
47+
#. `@pp-mo`_ added a documentation section on dataless cubes.
48+
See: :ref:`dataless-cubes`.
49+
(:issue:`XXX`, :pull:`XXX`)
50+
4351

4452
🐛 Bugs Fixed
4553
=============

lib/iris/tests/integration/merge/test_merge.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ def mangle_cubelist(cubelist, dataless_option):
5353
or dataless_option == "dataless_all"
5454
):
5555
# Make this one dataless
56-
cube = cube.copy()
57-
cube.data = None
56+
cube = cube.copy(iris.DATALESS)
5857

5958
result.append(cube)
6059

0 commit comments

Comments
 (0)