Skip to content

Commit bd4e3cb

Browse files
authored
docs: tighten temporal coordinates explanation (#7159)
* docs: tighten temporal coordinates explanation * mpl 3.11 fix * add whatnews entries
1 parent e7e3deb commit bd4e3cb

3 files changed

Lines changed: 25 additions & 20 deletions

File tree

docs/src/user_manual/explanation/temporal_coordinates.rst

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ Temporal Coordinates
1212

1313
.. readingtime::
1414

15-
Here we provide some handy patterns and tips for working with temporal
16-
coordinates i.e., ``time`` coordinates.
15+
This page provides practical patterns and tips for working with temporal
16+
coordinates, that is, ``time`` coordinates.
1717

1818

1919
Introduction
@@ -46,10 +46,10 @@ individual components:
4646
* ``time`` - This is the *name* of the coordinate. The name is derived firstly
4747
from the coordinate ``standard_name``. Failing that, the ``long_name`` is
4848
used, otherwise the ``var_name`` before defaulting to a value of ``unknown``.
49-
* ``hours since 1970-01-01 00:00:00`` - This tells us the coordinates temporal
49+
* ``hours since 1970-01-01 00:00:00`` - This tells us the coordinate's temporal
5050
units of measure (``hours``) relative to its epoch (``1970-01-01 00:00:00``).
5151
* ``[...]`` - Represents the temporal ``points``, the values of which are not
52-
displayed in this shortend summary. However, note that if the coordinate had
52+
displayed in this shortened summary. However, if the coordinate had
5353
``bounds`` this would be represented as ``[...]+bounds``.
5454
* ``shape(6,)`` - Tells us that the coordinate has one dimension containing
5555
``6`` points.
@@ -60,7 +60,7 @@ We can easily inspect the ``points`` contained within our ``tcoord``::
6060
array([347926.16666667, 347926.33333333, 347926.5 , 347926.66666667,
6161
347926.83333333, 347927. ])
6262

63-
However, these raw values are pretty meaningless on their own. As hinted to above,
63+
However, these raw values are difficult to interpret on their own. As noted above,
6464
these ``points`` are measured in units of ``hours`` relative to the epoch
6565
``1970-01-01 00:00:00``. The metadata defining all this information is available
6666
from the ``units`` attribute of the :class:`coordinate <iris.coords.Coord>`::
@@ -74,7 +74,7 @@ from the ``units`` attribute of the :class:`coordinate <iris.coords.Coord>`::
7474
their ``units``.
7575

7676
In this case our ``tcoord`` has a ``standard`` (or ``gregorian``) calendar and
77-
we can convert its hard to understand raw values into meaningful **date**/**time**
77+
we can convert its hard-to-interpret raw values into meaningful **date**/**time**
7878
(``YYYY-MM-DD HH:MM:SS``) representations relative to its ``calendar`` and
7979
epoch::
8080

@@ -87,8 +87,8 @@ epoch::
8787
dtype: float64
8888
standard_name: 'time'
8989

90-
Now we can clearly see that our ``tcoord`` time interval commences on ``2009-09-09``
91-
at ``22:10:00`` with samples that are each ``10`` minutes apart.
90+
Now we can clearly see that the ``tcoord`` interval starts on ``2009-09-09`` at
91+
``22:10:00`` with samples spaced ``10`` minutes apart.
9292

9393
Note that our ``tcoord`` does not have any ``bounds`` associated with it::
9494

@@ -127,7 +127,7 @@ its :meth:`~iris.coords.Coord.guess_bounds` method::
127127
Indexing
128128
--------
129129

130-
:class:`Coordinates <iris.coords.Coord>` are *first-class-citizens* and may be
130+
:class:`Coordinates <iris.coords.Coord>` are *first-class citizens* and may be
131131
indexed akin to other ``python`` built-in types such as `lists`_ or `tuples`_.
132132

133133
As an example, let's index the **last** sample of the ``tcoord``::
@@ -157,8 +157,8 @@ In the above example, indexing the ``tcoord`` yields a scalar
157157
A **lighter-weight** indexing solution is to leverage the :meth:`~iris.coords.Coord.cell`
158158
method instead::
159159

160-
>> tcell = tcoord.cell(-1)
161-
>> tcell
160+
>>> tcell = tcoord.cell(-1)
161+
>>> tcell
162162
Cell(point=cftime.DatetimeGregorian(2009, 9, 9, 23, 0, 0, 0, has_year_zero=False), bound=(cftime.DatetimeGregorian(2009, 9, 9, 22, 55, 0, 0, has_year_zero=False), cftime.DatetimeGregorian(2009, 9, 9, 23, 5, 0, 0, has_year_zero=False)))
163163

164164
This returns a :class:`~iris.coords.Cell` object rather than a
@@ -206,7 +206,7 @@ To convert these ``points`` and ``bounds`` into equivalent ``tcell``
206206
Iteration
207207
---------
208208

209-
Akin to :ref:`indexing <explanation-temporal-coordinates-indexing>`, we can also
209+
As with :ref:`indexing <explanation-temporal-coordinates-indexing>`, we can also
210210
iterate over :class:`coordinates <iris.coords.Coord>` just as you would naturally
211211
with other ``python`` built-in types such as `lists`_ or `tuples`_.
212212

@@ -302,15 +302,14 @@ Depending on your workflow, you may wish to deal directly with either
302302
:class:`~datetime.datetime` objects rather than raw temporal values within
303303
the ``points``/``bounds`` of a :class:`coordinate <iris.coords.Coord>`.
304304

305-
There are several different ways to convert raw temporal values, so let's
306-
consolidating our understanding and enumerate the various options
307-
available to us.
305+
There are several ways to convert raw temporal values, so let's consolidate
306+
our understanding and enumerate the options available to us.
308307

309308
``cftime``
310309
~~~~~~~~~~
311310

312-
The direct approach is to leverage either of the :meth:`~iris.coords.Coord.cell`
313-
or :meth:`~iris.coords.Coord.cells` methods. Both of which provide one or more
311+
The direct approach is to use either :meth:`~iris.coords.Coord.cell`
312+
or :meth:`~iris.coords.Coord.cells`. Both provide one or more
314313
:class:`~iris.coords.Cell` objects.
315314

316315
By default a temporal :class:`~iris.coords.Cell` will always contain
@@ -451,7 +450,7 @@ For example:
451450
Native ``matplotlib`` only supports ``python`` :class:`~datetime.datetime`
452451
compatible objects.
453452

454-
Note that, :mod:`iris.plot` and :mod:`iris.quickplot` provide the convenience
453+
Note that :mod:`iris.plot` and :mod:`iris.quickplot` provide the convenience
455454
of also understanding ``iris`` objects, such as coordinates and cubes. However
456455
they also use the `nc-time-axis`_ package, which provides support for a `cftime`_
457456
axis in `matplotlib`_.

docs/src/user_manual/tutorial/plotting_examples/cube_brewer_contourf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Plot a cube with a Brewer colour palette using iris.quickplot.contourf()."""
22

3-
import matplotlib.cm as mpl_cm
3+
import matplotlib as mpl
44
import matplotlib.pyplot as plt
55

66
import iris
@@ -10,7 +10,7 @@
1010
temperature_cube = iris.load_cube(fname)
1111

1212
# Load a Cynthia Brewer palette.
13-
brewer_cmap = mpl_cm.get_cmap("brewer_OrRd_09")
13+
brewer_cmap = mpl.colormaps["brewer_OrRd_09"]
1414

1515
# Draw the contours, with n-levels set for the map colours (9).
1616
# NOTE: needed as the map is non-interpolated, but matplotlib does not provide

docs/src/whatsnew/latest.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,16 @@ This document explains the changes made to Iris for this release
132132
:func:`iris.analysis.cartography.area_weights` requires 1-dimensional lat and lon
133133
coordinates on the input :class:`~iris.cube.Cube`. (:pull:`7118`)
134134

135+
#. :user:`bjlittle` Added an explanation section for :ref:`explanation-temporal-coordinates`.
136+
(:pull:`7131`)
137+
135138
#. :user:`bjlittle` Added the custom `sphinx`_ ``readingtime`` directive to
136139
automatically estimate the audiance reading time of a page and render a
137140
branded banner in-situ. (:pull:`7150`)
138141

142+
#. :user:`bjlittle` Updated the :ref:`explanation-temporal-coordinates` section.
143+
(:pull:`7159`)
144+
139145

140146
💼 Internal
141147
===========

0 commit comments

Comments
 (0)