Skip to content
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
581ac0e
Initial working.
pp-mo Jan 13, 2022
8dfa329
Temporary test exercising.
pp-mo Jan 13, 2022
a1745b6
Fix docstring, simplify.
pp-mo Jan 13, 2022
70ba216
Small mods.
pp-mo Jan 13, 2022
38ba475
Additional changes, with old+intermediate versions commented.
pp-mo Jan 17, 2022
9553d9b
Tidy, removing old commented forms.
pp-mo Jan 17, 2022
77fc1f6
Repr always has shape, except scalar cases.
pp-mo Jan 17, 2022
1a97a98
Don't print calendar in oneline summary.
pp-mo Jan 17, 2022
12f0be5
Initial working dim-meta printout tests.
pp-mo Jan 18, 2022
910f090
Printout features and all tests complete : existing tests *not* yet f…
pp-mo Jan 18, 2022
e85ba19
Fix existing connectivity print tests.
pp-mo Jan 18, 2022
d3eaf2f
Fix existing MeshCoord printout tests.
pp-mo Jan 18, 2022
881d7a0
Fix various str+repr changes in tests/test_coord_api.
pp-mo Jan 18, 2022
d7308b5
Fix various str+repr changes in tests/unit/coords/test_Coord.
pp-mo Jan 18, 2022
a68f31b
Fix existing printout tests for Ancils and CellMeasures.
pp-mo Jan 19, 2022
c82283b
Added new str and repr for Mesh.
pp-mo Jan 19, 2022
286565c
Doctest fixes.
pp-mo Jan 19, 2022
beba1f2
Tidy up unused methods, api and docstrings
pp-mo Jan 19, 2022
9a5d9d3
Add specific tests for 'summary' method.
pp-mo Jan 19, 2022
4e1867d
Tiny fixes.
pp-mo Jan 19, 2022
49bf0c3
Use UGRID term 'optional' connectivities instead of 'extra'.
pp-mo Jan 21, 2022
e8bef5f
Revise kwargs and clarify their relationship to numpy printoptions.
pp-mo Jan 21, 2022
a2a6015
More small cosmetic changes, plus minimal bounds in repr.
pp-mo Jan 21, 2022
0a56e37
Fix coord_api repr tests.
pp-mo Jan 21, 2022
2e82bba
Added whatsnew + fixed docstring formatting.
pp-mo Jan 24, 2022
fdb352f
Add summary section-location info for MeshCoord. Fix and test for bo…
pp-mo Jan 25, 2022
b868d40
Clarify text-output code.
pp-mo Jan 25, 2022
d6cf339
Remove obsolete comment.
pp-mo Jan 25, 2022
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
69 changes: 49 additions & 20 deletions docs/src/userguide/loading_iris_cubes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,21 @@ for ease of calendar-based testing.
>>> cube_all = iris.load_cube(filename, 'air_potential_temperature')
>>> print('All times :\n' + str(cube_all.coord('time')))
All times :
DimCoord([2009-11-19 10:00:00, 2009-11-19 11:00:00, 2009-11-19 12:00:00], standard_name='time', calendar='gregorian')
DimCoord : time / (hours since 1970-01-01 00:00:00, gregorian calendar)
points: [2009-11-19 10:00:00, 2009-11-19 11:00:00, 2009-11-19 12:00:00]
shape: (3,)
dtype: float64
standard_name: 'time'
>>> # Define a function which accepts a datetime as its argument (this is simplified in later examples).
>>> hour_11 = iris.Constraint(time=lambda cell: cell.point.hour == 11)
>>> cube_11 = cube_all.extract(hour_11)
>>> print('Selected times :\n' + str(cube_11.coord('time')))
Selected times :
DimCoord([2009-11-19 11:00:00], standard_name='time', calendar='gregorian')
DimCoord : time / (hours since 1970-01-01 00:00:00, gregorian calendar)
points: [2009-11-19 11:00:00]
shape: (1,)
dtype: float64
standard_name: 'time'

Secondly, the :class:`iris.time` module provides flexible time comparison
facilities. An :class:`iris.time.PartialDateTime` object can be compared to
Expand All @@ -335,7 +343,11 @@ The previous constraint example can now be written as:
>>> print(iris.load_cube(
... iris.sample_data_path('uk_hires.pp'),
... 'air_potential_temperature' & the_11th_hour).coord('time'))
DimCoord([2009-11-19 11:00:00], standard_name='time', calendar='gregorian')
DimCoord : time / (hours since 1970-01-01 00:00:00, gregorian calendar)
points: [2009-11-19 11:00:00]
shape: (1,)
dtype: float64
standard_name: 'time'

It is common that a cube will need to be constrained between two given dates.
In the following example we construct a time sequence representing the first
Expand All @@ -355,10 +367,13 @@ day of every week for many years:
:options: +NORMALIZE_WHITESPACE, +ELLIPSIS

>>> print(long_ts.coord('time'))
DimCoord([2007-04-09 00:00:00, 2007-04-16 00:00:00, 2007-04-23 00:00:00,
...
2010-02-01 00:00:00, 2010-02-08 00:00:00, 2010-02-15 00:00:00],
standard_name='time', calendar='gregorian')
DimCoord : time / (days since 2007-04-09, gregorian calendar)
points: [
2007-04-09 00:00:00, 2007-04-16 00:00:00, ...,
2010-02-08 00:00:00, 2010-02-15 00:00:00]
shape: (150,)
dtype: int64
standard_name: 'time'

Given two dates in datetime format, we can select all points between them.

Expand All @@ -371,9 +386,13 @@ Given two dates in datetime format, we can select all points between them.
... time=lambda cell: d1 <= cell.point < d2)
>>> within_st_swithuns_07 = long_ts.extract(st_swithuns_daterange_07)
>>> print(within_st_swithuns_07.coord('time'))
DimCoord([2007-07-16 00:00:00, 2007-07-23 00:00:00, 2007-07-30 00:00:00,
2007-08-06 00:00:00, 2007-08-13 00:00:00, 2007-08-20 00:00:00],
standard_name='time', calendar='gregorian')
DimCoord : time / (days since 2007-04-09, gregorian calendar)
points: [
2007-07-16 00:00:00, 2007-07-23 00:00:00, 2007-07-30 00:00:00,
2007-08-06 00:00:00, 2007-08-13 00:00:00, 2007-08-20 00:00:00]
shape: (6,)
dtype: int64
standard_name: 'time'

Alternatively, we may rewrite this using :class:`iris.time.PartialDateTime`
objects.
Expand All @@ -387,9 +406,13 @@ objects.
... time=lambda cell: pdt1 <= cell.point < pdt2)
>>> within_st_swithuns_07 = long_ts.extract(st_swithuns_daterange_07)
>>> print(within_st_swithuns_07.coord('time'))
DimCoord([2007-07-16 00:00:00, 2007-07-23 00:00:00, 2007-07-30 00:00:00,
2007-08-06 00:00:00, 2007-08-13 00:00:00, 2007-08-20 00:00:00],
standard_name='time', calendar='gregorian')
DimCoord : time / (days since 2007-04-09, gregorian calendar)
points: [
2007-07-16 00:00:00, 2007-07-23 00:00:00, 2007-07-30 00:00:00,
2007-08-06 00:00:00, 2007-08-13 00:00:00, 2007-08-20 00:00:00]
shape: (6,)
dtype: int64
standard_name: 'time'

A more complex example might require selecting points over an annually repeating
date range. We can select points within a certain part of the year, in this case
Expand All @@ -402,13 +425,19 @@ PartialDateTime this becomes simple:
... time=lambda cell: PartialDateTime(month=7, day=15) <= cell < PartialDateTime(month=8, day=25))
>>> within_st_swithuns = long_ts.extract(st_swithuns_daterange)
...
>>> print(within_st_swithuns.coord('time'))
DimCoord([2007-07-16 00:00:00, 2007-07-23 00:00:00, 2007-07-30 00:00:00,
2007-08-06 00:00:00, 2007-08-13 00:00:00, 2007-08-20 00:00:00,
2008-07-21 00:00:00, 2008-07-28 00:00:00, 2008-08-04 00:00:00,
2008-08-11 00:00:00, 2008-08-18 00:00:00, 2009-07-20 00:00:00,
2009-07-27 00:00:00, 2009-08-03 00:00:00, 2009-08-10 00:00:00,
2009-08-17 00:00:00, 2009-08-24 00:00:00], standard_name='time', calendar='gregorian')
>>> # Note: using summary(max_values) to show more of the points
>>> print(within_st_swithuns.coord('time').summary(max_values=100))
DimCoord : time / (days since 2007-04-09, gregorian calendar)
points: [
2007-07-16 00:00:00, 2007-07-23 00:00:00, 2007-07-30 00:00:00,
2007-08-06 00:00:00, 2007-08-13 00:00:00, 2007-08-20 00:00:00,
2008-07-21 00:00:00, 2008-07-28 00:00:00, 2008-08-04 00:00:00,
2008-08-11 00:00:00, 2008-08-18 00:00:00, 2009-07-20 00:00:00,
2009-07-27 00:00:00, 2009-08-03 00:00:00, 2009-08-10 00:00:00,
2009-08-17 00:00:00, 2009-08-24 00:00:00]
shape: (17,)
dtype: int64
standard_name: 'time'

Notice how the dates printed are between the range specified in the ``st_swithuns_daterange``
and that they span multiple years.
Expand Down
10 changes: 10 additions & 0 deletions docs/src/whatsnew/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ This document explains the changes made to Iris for this release
from `Metarelate`_. From now we intend to manage phenonemon translation
in Iris itself. (:pull:`4484`)

#. `@pp-mo`_ improved printout of various cube data component objects :
:class:`~iris.coords.Coord`, :class:`~iris.coords.CellMeasure`,
:class:`~iris.coords.AncillaryVariable`,
:class:`~iris.experimental.ugrid.mesh.MeshCoord` and
:class:`~iris.experimental.ugrid.mesh.Mesh`.
These now all provide a more controllable ``summary()`` method, and
more convenient and readable ``str()`` and ``repr()`` output in the style of
the :class:`iris.cube.Cube`.
They also no longer realise lazy data. (:pull:`4499`).


🐛 Bugs Fixed
=============
Expand Down
Loading