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 1 commit
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
16 changes: 16 additions & 0 deletions docs/iris/src/userguide/cube_statistics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,22 @@ in the gallery takes a zonal mean of an ``XYT`` cube by using the
``collapsed`` method with ``latitude`` and ``iris.analysis.MEAN`` as arguments.


.. note::
You cannot partially collapse a multi-dimensional coordinate. Thus in the
Copy link
Member

Choose a reason for hiding this comment

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

Action: make into a single sentence and cross reference "reference docs".

above example you would not be able to collapse the cube along either of
the axes described by the ``grid_latitude`` or ``grid_longitude``
coordinates individually. Doing so would result in a partial collapse of
the 2D ``surface_altitude`` coordinate.

Instead you must either fully collapse the coordinate (in this case
requiring that both ``grid_latitude`` or ``grid_longitude`` coordinates be
collapsed together in a single collapse operation) or not collapse the
Copy link
Member

Choose a reason for hiding this comment

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

Third option - remove the surface altitude.

coordinate at all.

Multi-dimensional derived coordinates (such as ``altitude`` in the above
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps too much detail for the userguide.

example) will not prevent a successful collapse operation across a
cube dimension that the multi-dimensional derived coordinate spans.

.. _cube-statistics-collapsing-average:

Area averaging
Expand Down
12 changes: 11 additions & 1 deletion lib/iris/coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -943,11 +943,21 @@ 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. To
successfully collapse a multi-dimensional coordinate (i.e. a
coordinate that describes more than one of a cube's axes) you
must collapse all cube axes that the multi-dimensional coordinate
spans in a single collapse operation.

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

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

.. 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. To
successfully collapse a multi-dimensional coordinate (i.e. a
coordinate that describes more than one of a cube's axes) you
must collapse all cube axes that the multi-dimensional coordinate
spans in a single collapse operation.

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