Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: Note about collapsing multi-dimensional coordinates #1819

Merged
merged 2 commits into from
Nov 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions docs/iris/src/userguide/cube_statistics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ For an example of using this functionality, the
in the gallery takes a zonal mean of an ``XYT`` cube by using the
``collapsed`` method with ``latitude`` and ``iris.analysis.MEAN`` as arguments.

You cannot partially collapse a multi-dimensional coordinate. See
:ref:`cube.collapsed <partially_collapse_multi-dim_coord>` for more
information.

.. _cube-statistics-collapsing-average:

Expand Down
7 changes: 6 additions & 1 deletion lib/iris/coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -943,11 +943,16 @@ def cell(self, index):

def collapsed(self, dims_to_collapse=None):
"""
Returns a copy of this coordinate which has been collapsed along
Returns a copy of this coordinate, which has been collapsed along
the specified dimensions.

Replaces the points & bounds with a simple bounded region.

.. note::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this note is well targeted for coordinates.

You cannot partially collapse a multi-dimensional coordinate. See
:ref:`cube.collapsed <partially_collapse_multi-dim_coord>` for more
information.

"""
if isinstance(dims_to_collapse, (int, np.integer)):
dims_to_collapse = [dims_to_collapse]
Expand Down
15 changes: 15 additions & 0 deletions lib/iris/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -2945,6 +2945,21 @@ def collapsed(self, coords, aggregator, **kwargs):
cube.collapsed(['latitude', 'longitude'],
iris.analysis.VARIANCE)

.. _partially_collapse_multi-dim_coord:

.. note::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for more detail in here which we can cross reference.

You cannot partially collapse a multi-dimensional coordinate. Doing
so would result in a partial collapse of the multi-dimensional
coordinate. Instead you must either:
* collapse in a single operation all cube axes that the
multi-dimensional coordinate spans,
* remove the multi-dimensional coordinate from the cube before
performing the collapse operation, or
* not collapse the coordinate at all.

Multi-dimensional derived coordinates will not prevent a successful
collapse operation.

"""
# Convert any coordinate names to coordinates
coords = self._as_list_of_coords(coords)
Expand Down