|
| 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. |
0 commit comments