Skip to content

Commit

Permalink
Cubeprinter adopt (#4206)
Browse files Browse the repository at this point in the history
* Adopt new-style Cube printout.

* Fix some import orderings.

* Replace old cube summary code with new CubeSummary-based implementation.

* Removed additional colons.

* Slightly altered behaviour + specific test fixes.

* Test result changes.

* Code standard fixes.

* More test fixes.

* Doctest fixes.

* Fix doctest output for python 3.8.

* Fix merged docs test.

* Make cube-summary list attributes last.

* Fix affected tests.

* Another test fix.

* Reformat TODO string to aid IDE recognition.

* CubePrinter tab size constants.

* CubePrinter don't bother assigning cube_summary on ingestion.

* cube_printout docstring fixes.

* Cube summary align cell methods with other tabbed content.

* Remove CubePrinter TODO.

* Remove CubeSummary TODO.

* Remove commented cube summary code.

* Cube summary what's new entries.

Co-authored-by: Martin Yeo <martin.yeo@metoffice.gov.uk>
  • Loading branch information
pp-mo and trexfeathers authored Aug 10, 2021
1 parent 4abaa8f commit d4d0514
Show file tree
Hide file tree
Showing 44 changed files with 1,956 additions and 1,290 deletions.
126 changes: 63 additions & 63 deletions docs/src/further_topics/lenient_maths.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,26 +68,26 @@ represents the output of an low-resolution global atmospheric ``experiment``,
.. doctest:: lenient-example

>>> print(experiment)
air_potential_temperature / (K) (model_level_number: 15; grid_latitude: 100; grid_longitude: 100)
Dimension coordinates:
model_level_number x - -
grid_latitude - x -
grid_longitude - - x
Auxiliary coordinates:
atmosphere_hybrid_height_coordinate x - -
sigma x - -
surface_altitude - x x
Derived coordinates:
altitude x x x
Scalar coordinates:
forecast_period: 0.0 hours
forecast_reference_time: 2009-09-09 17:10:00
time: 2009-09-09 17:10:00
Attributes:
Conventions: CF-1.5
STASH: m01s00i004
experiment-id: RT3 50
source: Data from Met Office Unified Model 7.04
air_potential_temperature / (K) (model_level_number: 15; grid_latitude: 100; grid_longitude: 100)
Dimension coordinates:
model_level_number x - -
grid_latitude - x -
grid_longitude - - x
Auxiliary coordinates:
atmosphere_hybrid_height_coordinate x - -
sigma x - -
surface_altitude - x x
Derived coordinates:
altitude x x x
Scalar coordinates:
forecast_period 0.0 hours
forecast_reference_time 2009-09-09 17:10:00
time 2009-09-09 17:10:00
Attributes:
Conventions CF-1.5
STASH m01s00i004
experiment-id RT3 50
source Data from Met Office Unified Model 7.04

Consider also the following :class:`~iris.cube.Cube`, which has the same global
spatial extent, and acts as a ``control``,
Expand All @@ -96,41 +96,41 @@ spatial extent, and acts as a ``control``,

>>> print(control)
air_potential_temperature / (K) (grid_latitude: 100; grid_longitude: 100)
Dimension coordinates:
grid_latitude x -
grid_longitude - x
Scalar coordinates:
model_level_number: 1
time: 2009-09-09 17:10:00
Attributes:
Conventions: CF-1.7
STASH: m01s00i004
source: Data from Met Office Unified Model 7.04
Dimension coordinates:
grid_latitude x -
grid_longitude - x
Scalar coordinates:
model_level_number 1
time 2009-09-09 17:10:00
Attributes:
Conventions CF-1.7
STASH m01s00i004
source Data from Met Office Unified Model 7.04

Now let's subtract these cubes in order to calculate a simple ``difference``,

.. doctest:: lenient-example

>>> difference = experiment - control
>>> print(difference)
unknown / (K) (model_level_number: 15; grid_latitude: 100; grid_longitude: 100)
Dimension coordinates:
model_level_number x - -
grid_latitude - x -
grid_longitude - - x
Auxiliary coordinates:
atmosphere_hybrid_height_coordinate x - -
sigma x - -
surface_altitude - x x
Derived coordinates:
altitude x x x
Scalar coordinates:
forecast_period: 0.0 hours
forecast_reference_time: 2009-09-09 17:10:00
time: 2009-09-09 17:10:00
Attributes:
experiment-id: RT3 50
source: Data from Met Office Unified Model 7.04
unknown / (K) (model_level_number: 15; grid_latitude: 100; grid_longitude: 100)
Dimension coordinates:
model_level_number x - -
grid_latitude - x -
grid_longitude - - x
Auxiliary coordinates:
atmosphere_hybrid_height_coordinate x - -
sigma x - -
surface_altitude - x x
Derived coordinates:
altitude x x x
Scalar coordinates:
forecast_period 0.0 hours
forecast_reference_time 2009-09-09 17:10:00
time 2009-09-09 17:10:00
Attributes:
experiment-id RT3 50
source Data from Met Office Unified Model 7.04

Note that, cube maths automatically takes care of broadcasting the
dimensionality of the ``control`` up to that of the ``experiment``, in order to
Expand Down Expand Up @@ -204,21 +204,21 @@ time perform **strict** cube maths instead,
... difference = experiment - control
...
>>> print(difference)
unknown / (K) (model_level_number: 15; grid_latitude: 100; grid_longitude: 100)
Dimension coordinates:
model_level_number x - -
grid_latitude - x -
grid_longitude - - x
Auxiliary coordinates:
atmosphere_hybrid_height_coordinate x - -
sigma x - -
surface_altitude - x x
Derived coordinates:
altitude x x x
Scalar coordinates:
time: 2009-09-09 17:10:00
Attributes:
source: Data from Met Office Unified Model 7.04
unknown / (K) (model_level_number: 15; grid_latitude: 100; grid_longitude: 100)
Dimension coordinates:
model_level_number x - -
grid_latitude - x -
grid_longitude - - x
Auxiliary coordinates:
atmosphere_hybrid_height_coordinate x - -
sigma x - -
surface_altitude - x x
Derived coordinates:
altitude x x x
Scalar coordinates:
time 2009-09-09 17:10:00
Attributes:
source Data from Met Office Unified Model 7.04

Although the numerical result of this strict cube maths operation is identical,
it is not as rich in metadata as the :ref:`lenient alternative <lenient example>`.
Expand Down
32 changes: 16 additions & 16 deletions docs/src/further_topics/metadata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,22 @@ For example, given the following :class:`~iris.cube.Cube`,

>>> print(cube)
air_temperature / (K) (time: 240; latitude: 37; longitude: 49)
Dimension coordinates:
time x - -
latitude - x -
longitude - - x
Auxiliary coordinates:
forecast_period x - -
Scalar coordinates:
forecast_reference_time: 1859-09-01 06:00:00
height: 1.5 m
Attributes:
Conventions: CF-1.5
Model scenario: A1B
STASH: m01s03i236
source: Data from Met Office Unified Model 6.05
Cell methods:
mean: time (6 hour)
Dimension coordinates:
time x - -
latitude - x -
longitude - - x
Auxiliary coordinates:
forecast_period x - -
Scalar coordinates:
forecast_reference_time 1859-09-01 06:00:00
height 1.5 m
Cell methods:
mean time (6 hour)
Attributes:
Conventions CF-1.5
Model scenario A1B
STASH m01s03i236
source Data from Met Office Unified Model 6.05

We can easily get all of the associated metadata of the :class:`~iris.cube.Cube`
using the ``metadata`` property:
Expand Down
20 changes: 10 additions & 10 deletions docs/src/userguide/cube_maths.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ but with the data representing their difference:

>>> print(t_last - t_first)
unknown / (K) (latitude: 37; longitude: 49)
Dimension coordinates:
latitude x -
longitude - x
Scalar coordinates:
forecast_reference_time: 1859-09-01 06:00:00
height: 1.5 m
Attributes:
Conventions: CF-1.5
Model scenario: E1
source: Data from Met Office Unified Model 6.05
Dimension coordinates:
latitude x -
longitude - x
Scalar coordinates:
forecast_reference_time 1859-09-01 06:00:00
height 1.5 m
Attributes:
Conventions CF-1.5
Model scenario E1
source Data from Met Office Unified Model 6.05


.. note::
Expand Down
Loading

0 comments on commit d4d0514

Please sign in to comment.