Skip to content

Commit 7e541ec

Browse files
bjlittlepp-mostephenworsleytkknightjamesp
authored
Update mesh-data-model branch (#4009)
* Add abstract cube summary (#3987) Co-authored-by: stephen.worsley <[email protected]> * add nox session conda list (#3990) * Added text to state the Python version used to build the docs. (#3989) * Added text to state the Python version used to build the docs. * Added footer template that includes the Python version used to build. * added new line * Review actions * added whatsnew * Iris py38 (#3976) * support for py38 * update CI and noxfile * enforce alphabetical xml element attribute order * full tests for py38 + fix docs-tests * add whatsnew entry * update doc-strings + review actions * Alternate xml handling routine (#29) * all xml tests pass for nox tests-3.8 * restored docstrings * move sort_xml_attrs * make sort_xml_attrs a classmethod * update sort_xml_attr doc-string Co-authored-by: Bill Little <[email protected]> * add jamesp to whatsnew + minor tweak Co-authored-by: James Penn <[email protected]> * normalise version to implicit development release number (#3991) * Gallery: update COP maps example (#3934) * update cop maps example * comment tweaks * minor comment tweak + whatsnew * reinstate whatsnew addition * remove duplicate whatsnew * don't support mpl v1.2 (#3941) * Cubesummary tidy (#3988) * Extra tests; fix for array attributes. * Docstring for CubeSummary, and remove some unused parts. * Fix section name capitalisation, in line with existing cube summary. * Handle array differences; quote strings in extras and if 'awkward'-printing. * Ensure scalar string coord 'content' prints on one line. * update intersphinx mapping and matplotlib urls (#4003) * update intersphinx mapping and matplotlib urls * use matplotlib intersphinx where possible * review actions * review actions * update readme badges (#4004) * update readme badges * pimp twitter badge * update readme logo img src and href (#4006) * update setuptools description (#4008) Co-authored-by: Patrick Peglar <[email protected]> Co-authored-by: stephen.worsley <[email protected]> Co-authored-by: tkknight <[email protected]> Co-authored-by: James Penn <[email protected]> Co-authored-by: Ruth Comer <[email protected]>
1 parent e0fb557 commit 7e541ec

File tree

12 files changed

+307
-164
lines changed

12 files changed

+307
-164
lines changed

README.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<h1 align="center">
2-
<a href="https://scitools.org.uk/iris/docs/latest/">
3-
<img src="docs/src/_static/iris-logo-title.png" alt="Iris" width="300"></a><br>
2+
<a href="https://scitools-iris.readthedocs.io/en/latest/">
3+
<img src="https://scitools-iris.readthedocs.io/en/latest/_static/iris-logo-title.png" alt="Iris" width="300"></a><br>
44
</h1>
55

66

@@ -13,18 +13,24 @@
1313
<a href="https://cirrus-ci.com/github/SciTools/iris">
1414
<img src="https://api.cirrus-ci.com/github/SciTools/iris.svg?branch=master"
1515
alt="Cirrus-CI" /></a>
16-
<a href='https://scitools-iris.readthedocs.io/en/latest/?badge=latest'>
17-
<img src='https://readthedocs.org/projects/scitools-iris/badge/?version=latest'
18-
alt='Documentation Status' /></a>
16+
<a href="https://scitools-iris.readthedocs.io/en/latest/?badge=latest">
17+
<img src="https://readthedocs.org/projects/scitools-iris/badge/?version=latest"
18+
alt="Documentation Status" /></a>
1919
<a href="https://anaconda.org/conda-forge/iris">
2020
<img src="https://img.shields.io/conda/dn/conda-forge/iris.svg"
2121
alt="conda-forge downloads" /></a>
2222
<a href="https://github.com/SciTools/iris/graphs/contributors">
2323
<img src="https://img.shields.io/github/contributors/SciTools/iris.svg"
2424
alt="# contributors" /></a>
25+
<a href="https://anaconda.org/conda-forge/iris">
26+
<img src="https://img.shields.io/conda/v/conda-forge/iris?color=orange&label=conda-forge%7Ciris"
27+
alt="conda-forge" /></a>
28+
<a href="https://pypi.org/project/scitools-iris">
29+
<img src="https://img.shields.io/pypi/v/scitools-iris?color=orange&label=pypi%7Cscitools-iris"
30+
alt="pypi" /></a>
2531
<a href="https://github.com/SciTools/iris/releases">
26-
<img src="https://img.shields.io/github/tag/SciTools/iris.svg"
27-
alt="Latest version" /></a>
32+
<img src="https://img.shields.io/github/v/release/scitools/iris"
33+
alt="latest release" /></a>
2834
<a href="https://github.com/SciTools/iris/commits/master">
2935
<img src="https://img.shields.io/github/commits-since/SciTools/iris/latest.svg"
3036
alt="Commits since last release" /></a>
@@ -35,8 +41,8 @@
3541
<img src="https://img.shields.io/badge/code%20style-black-000000.svg"
3642
alt="black" /></a>
3743
<a href="https://twitter.com/scitools_iris">
38-
<img src="https://img.shields.io/twitter/follow/scitools_iris?style=social"
39-
alt="twitter" /></a>
44+
<img src="https://img.shields.io/twitter/follow/scitools_iris?color=yellow&label=twitter%7Cscitools_iris&logo=twitter&style=plastic"
45+
alt="twitter scitools_iris" /></a>
4046
</p>
4147

4248
<p align="center">

docs/gallery_code/general/plot_anomaly_log_colouring.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,15 @@
1212
"zero band" which is plotted in white.
1313
1414
To do this, we create a custom value mapping function (normalization) using
15-
the matplotlib Norm class `matplotlib.colours.SymLogNorm
16-
<https://matplotlib.org/api/_as_gen/matplotlib.colors.SymLogNorm.html#matplotlib.colors.SymLogNorm>`_.
17-
We use this to make a cell-filled pseudocolour plot with a colorbar.
15+
the matplotlib Norm class :obj:`matplotlib.colors.SymLogNorm`.
16+
We use this to make a cell-filled pseudocolor plot with a colorbar.
1817
1918
NOTE: By "pseudocolour", we mean that each data point is drawn as a "cell"
2019
region on the plot, coloured according to its data value.
2120
This is provided in Iris by the functions :meth:`iris.plot.pcolor` and
2221
:meth:`iris.plot.pcolormesh`, which call the underlying matplotlib
23-
functions of the same names (i.e. `matplotlib.pyplot.pcolor
24-
<http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.pcolor>`_
25-
and `matplotlib.pyplot.pcolormesh
26-
<http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.pcolormesh>`_).
22+
functions of the same names (i.e., :obj:`matplotlib.pyplot.pcolor`
23+
and :obj:`matplotlib.pyplot.pcolormesh`).
2724
See also: http://en.wikipedia.org/wiki/False_color#Pseudocolor.
2825
2926
"""
@@ -65,7 +62,7 @@ def main():
6562

6663
# Use a standard colour map which varies blue-white-red.
6764
# For suitable options, see the 'Diverging colormaps' section in:
68-
# http://matplotlib.org/examples/color/colormaps_reference.html
65+
# http://matplotlib.org/stable/gallery/color/colormap_reference.html
6966
anom_cmap = "bwr"
7067

7168
# Create a 'logarithmic' data normalization.

docs/gallery_code/meteorology/plot_COP_maps.py

Lines changed: 59 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -38,34 +38,32 @@ def cop_metadata_callback(cube, field, filename):
3838
filename.
3939
"""
4040

41-
# Extract the experiment name (such as a1b or e1) from the filename (in
42-
# this case it is just the parent folder's name)
43-
containing_folder = os.path.dirname(filename)
44-
experiment_label = os.path.basename(containing_folder)
41+
# Extract the experiment name (such as A1B or E1) from the filename (in
42+
# this case it is just the start of the file name, before the first ".").
43+
fname = os.path.basename(filename) # filename without path.
44+
experiment_label = fname.split(".")[0]
4545

46-
# Create a coordinate with the experiment label in it
46+
# Create a coordinate with the experiment label in it...
4747
exp_coord = coords.AuxCoord(
4848
experiment_label, long_name="Experiment", units="no_unit"
4949
)
5050

51-
# and add it to the cube
51+
# ...and add it to the cube.
5252
cube.add_aux_coord(exp_coord)
5353

5454

5555
def main():
56-
# Load e1 and a1 using the callback to update the metadata
57-
e1 = iris.load_cube(
58-
iris.sample_data_path("E1.2098.pp"), callback=cop_metadata_callback
59-
)
60-
a1b = iris.load_cube(
61-
iris.sample_data_path("A1B.2098.pp"), callback=cop_metadata_callback
62-
)
56+
# Load E1 and A1B scenarios using the callback to update the metadata.
57+
scenario_files = [
58+
iris.sample_data_path(fname) for fname in ["E1.2098.pp", "A1B.2098.pp"]
59+
]
60+
scenarios = iris.load(scenario_files, callback=cop_metadata_callback)
6361

64-
# Load the global average data and add an 'Experiment' coord it
65-
global_avg = iris.load_cube(iris.sample_data_path("pre-industrial.pp"))
62+
# Load the preindustrial reference data.
63+
preindustrial = iris.load_cube(iris.sample_data_path("pre-industrial.pp"))
6664

6765
# Define evenly spaced contour levels: -2.5, -1.5, ... 15.5, 16.5 with the
68-
# specific colours
66+
# specific colours.
6967
levels = np.arange(20) - 2.5
7068
red = (
7169
np.array(
@@ -147,81 +145,67 @@ def main():
147145
)
148146

149147
# Put those colours into an array which can be passed to contourf as the
150-
# specific colours for each level
151-
colors = np.array([red, green, blue]).T
148+
# specific colours for each level.
149+
colors = np.stack([red, green, blue], axis=1)
152150

153-
# Subtract the global
151+
# Make a wider than normal figure to house two maps side-by-side.
152+
fig, ax_array = plt.subplots(1, 2, figsize=(12, 5))
154153

155-
# Iterate over each latitude longitude slice for both e1 and a1b scenarios
156-
# simultaneously
157-
for e1_slice, a1b_slice in zip(
158-
e1.slices(["latitude", "longitude"]),
159-
a1b.slices(["latitude", "longitude"]),
154+
# Loop over our scenarios to make a plot for each.
155+
for ax, experiment, label in zip(
156+
ax_array, ["E1", "A1B"], ["E1", "A1B-Image"]
160157
):
161-
162-
time_coord = a1b_slice.coord("time")
163-
164-
# Calculate the difference from the mean
165-
delta_e1 = e1_slice - global_avg
166-
delta_a1b = a1b_slice - global_avg
167-
168-
# Make a wider than normal figure to house two maps side-by-side
169-
fig = plt.figure(figsize=(12, 5))
170-
171-
# Get the time datetime from the coordinate
172-
time = time_coord.units.num2date(time_coord.points[0])
173-
# Set a title for the entire figure, giving the time in a nice format
174-
# of "MonthName Year". Also, set the y value for the title so that it
175-
# is not tight to the top of the plot.
176-
fig.suptitle(
177-
"Annual Temperature Predictions for " + time.strftime("%Y"),
178-
y=0.9,
179-
fontsize=18,
158+
exp_cube = scenarios.extract_cube(
159+
iris.Constraint(Experiment=experiment)
180160
)
161+
time_coord = exp_cube.coord("time")
181162

182-
# Add the first subplot showing the E1 scenario
183-
plt.subplot(121)
184-
plt.title("HadGEM2 E1 Scenario", fontsize=10)
185-
iplt.contourf(delta_e1, levels, colors=colors, extend="both")
186-
plt.gca().coastlines()
187-
# get the current axes' subplot for use later on
188-
plt1_ax = plt.gca()
163+
# Calculate the difference from the preindustial control run.
164+
exp_anom_cube = exp_cube - preindustrial
189165

190-
# Add the second subplot showing the A1B scenario
191-
plt.subplot(122)
192-
plt.title("HadGEM2 A1B-Image Scenario", fontsize=10)
166+
# Plot this anomaly.
167+
plt.sca(ax)
168+
ax.set_title(f"HadGEM2 {label} Scenario", fontsize=10)
193169
contour_result = iplt.contourf(
194-
delta_a1b, levels, colors=colors, extend="both"
170+
exp_anom_cube, levels, colors=colors, extend="both"
195171
)
196172
plt.gca().coastlines()
197-
# get the current axes' subplot for use later on
198-
plt2_ax = plt.gca()
199173

200-
# Now add a colourbar who's leftmost point is the same as the leftmost
201-
# point of the left hand plot and rightmost point is the rightmost
202-
# point of the right hand plot
174+
# Now add a colourbar who's leftmost point is the same as the leftmost
175+
# point of the left hand plot and rightmost point is the rightmost
176+
# point of the right hand plot.
203177

204-
# Get the positions of the 2nd plot and the left position of the 1st
205-
# plot
206-
left, bottom, width, height = plt2_ax.get_position().bounds
207-
first_plot_left = plt1_ax.get_position().bounds[0]
178+
# Get the positions of the 2nd plot and the left position of the 1st plot.
179+
left, bottom, width, height = ax_array[1].get_position().bounds
180+
first_plot_left = ax_array[0].get_position().bounds[0]
208181

209-
# the width of the colorbar should now be simple
210-
width = left - first_plot_left + width
182+
# The width of the colorbar should now be simple.
183+
width = left - first_plot_left + width
211184

212-
# Add axes to the figure, to place the colour bar
213-
colorbar_axes = fig.add_axes([first_plot_left, 0.18, width, 0.03])
185+
# Add axes to the figure, to place the colour bar.
186+
colorbar_axes = fig.add_axes([first_plot_left, 0.18, width, 0.03])
214187

215-
# Add the colour bar
216-
cbar = plt.colorbar(
217-
contour_result, colorbar_axes, orientation="horizontal"
218-
)
188+
# Add the colour bar.
189+
cbar = plt.colorbar(
190+
contour_result, colorbar_axes, orientation="horizontal"
191+
)
219192

220-
# Label the colour bar and add ticks
221-
cbar.set_label(e1_slice.units)
222-
cbar.ax.tick_params(length=0)
193+
# Label the colour bar and add ticks.
194+
cbar.set_label(preindustrial.units)
195+
cbar.ax.tick_params(length=0)
196+
197+
# Get the time datetime from the coordinate.
198+
time = time_coord.units.num2date(time_coord.points[0])
199+
# Set a title for the entire figure, using the year from the datetime
200+
# object. Also, set the y value for the title so that it is not tight to
201+
# the top of the plot.
202+
fig.suptitle(
203+
f"Annual Temperature Predictions for {time.year}",
204+
y=0.9,
205+
fontsize=18,
206+
)
223207

224-
iplt.show()
208+
iplt.show()
225209

226210

227211
if __name__ == "__main__":

docs/gallery_code/meteorology/plot_deriving_phenomena.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,7 @@ def limit_colorbar_ticks(contour_object):
2626
number of ticks on the colorbar to 4.
2727
2828
"""
29-
# Under Matplotlib v1.2.x the colorbar attribute of a contour object is
30-
# a tuple containing the colorbar and an axes object, whereas under
31-
# Matplotlib v1.3.x it is simply the colorbar.
32-
try:
33-
colorbar = contour_object.colorbar[0]
34-
except (AttributeError, TypeError):
35-
colorbar = contour_object.colorbar
36-
29+
colorbar = contour_object.colorbar
3730
colorbar.locator = matplotlib.ticker.MaxNLocator(4)
3831
colorbar.update_ticks()
3932

docs/src/common_links.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
.. _issue: https://github.com/SciTools/iris/issues
1919
.. _issues: https://github.com/SciTools/iris/issues
2020
.. _legacy documentation: https://scitools.org.uk/iris/docs/v2.4.0/
21-
.. _matplotlib: https://matplotlib.org/
21+
.. _matplotlib: https://matplotlib.org/stable/
2222
.. _napolean: https://sphinxcontrib-napoleon.readthedocs.io/en/latest/sphinxcontrib.napoleon.html
2323
.. _nox: https://nox.thea.codes/en/stable/
2424
.. _New Issue: https://github.com/scitools/iris/issues/new/choose

docs/src/conf.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,18 +184,18 @@ def autolog(message):
184184
# -- intersphinx extension ----------------------------------------------------
185185
# See https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html
186186
intersphinx_mapping = {
187-
"cartopy": ("http://scitools.org.uk/cartopy/docs/latest/", None),
188-
"matplotlib": ("http://matplotlib.org/", None),
189-
"numpy": ("http://docs.scipy.org/doc/numpy/", None),
190-
"python": ("http://docs.python.org/2.7", None),
191-
"scipy": ("http://docs.scipy.org/doc/scipy/reference/", None),
187+
"cartopy": ("https://scitools.org.uk/cartopy/docs/latest/", None),
188+
"matplotlib": ("https://matplotlib.org/stable/", None),
189+
"numpy": ("https://numpy.org/doc/stable/", None),
190+
"python": ("https://docs.python.org/3/", None),
191+
"scipy": ("https://docs.scipy.org/doc/scipy/reference/", None),
192192
}
193193

194194
# The name of the Pygments (syntax highlighting) style to use.
195195
pygments_style = "sphinx"
196196

197197
# -- plot_directive extension -------------------------------------------------
198-
# See https://matplotlib.org/3.1.3/devel/plot_directive.html#options
198+
# See https://matplotlib.org/stable/api/sphinxext_plot_directive_api.html#options
199199
plot_formats = [
200200
("png", 100),
201201
]

docs/src/whatsnew/3.0.1.rst

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,12 @@ This document explains the changes made to Iris for this release
167167
``volume`` are the only accepted values. (:pull:`3533`)
168168

169169
#. `@trexfeathers`_ set **all** plot types in :mod:`iris.plot` to now use
170-
`matplotlib.dates.date2num`_ to format date/time coordinates for use on a plot
170+
:obj:`matplotlib.dates.date2num` to format date/time coordinates for use on a plot
171171
axis (previously :meth:`~iris.plot.pcolor` and :meth:`~iris.plot.pcolormesh`
172172
did not include this behaviour). (:pull:`3762`)
173173

174174
#. `@trexfeathers`_ changed date/time axis labels in :mod:`iris.quickplot` to
175-
now **always** be based on the ``epoch`` used in `matplotlib.dates.date2num`_
175+
now **always** be based on the ``epoch`` used in :obj:`matplotlib.dates.date2num`
176176
(previously would take the unit from a time coordinate, if present, even
177177
though the coordinate's value had been changed via ``date2num``).
178178
(:pull:`3762`)
@@ -189,7 +189,7 @@ This document explains the changes made to Iris for this release
189189

190190
#. `@stephenworsley`_ changed the way tick labels are assigned from string coords.
191191
Previously, the first tick label would occasionally be duplicated. This also
192-
removes the use of Matplotlib's deprecated ``IndexFormatter``. (:pull:`3857`)
192+
removes the use of the deprecated `matplotlib`_ ``IndexFormatter``. (:pull:`3857`)
193193

194194
#. `@znicholls`_ fixed :meth:`~iris.quickplot._title` to only check
195195
``units.is_time_reference`` if the ``units`` symbol is not used. (:pull:`3902`)
@@ -295,11 +295,11 @@ This document explains the changes made to Iris for this release
295295

296296
#. `@stephenworsley`_ and `@trexfeathers`_ pinned Iris to require
297297
`Cartopy`_ ``>=0.18``, in order to remain compatible with the latest version
298-
of `Matplotlib`_. (:pull:`3762`)
298+
of `matplotlib`_. (:pull:`3762`)
299299

300-
#. `@bjlittle`_ unpinned Iris to use the latest version of `Matplotlib`_.
300+
#. `@bjlittle`_ unpinned Iris to use the latest version of `matplotlib`_.
301301
Supporting ``Iris`` for both ``Python2`` and ``Python3`` had resulted in
302-
pinning our dependency on `Matplotlib`_ at ``v2.x``. But this is no longer
302+
pinning our dependency on `matplotlib`_ at ``v2.x``. But this is no longer
303303
necessary now that ``Python2`` support has been dropped. (:pull:`3468`)
304304

305305
#. `@stephenworsley`_ and `@trexfeathers`_ unpinned Iris to use the latest version
@@ -422,11 +422,11 @@ This document explains the changes made to Iris for this release
422422
grid-line spacing in `Cartopy`_. (:pull:`3762`) (see also `Cartopy#1117`_)
423423

424424
#. `@trexfeathers`_ added additional acceptable graphics test targets to account
425-
for very minor changes in `Matplotlib`_ version ``3.3`` (colormaps, fonts and
425+
for very minor changes in `matplotlib`_ version ``3.3`` (colormaps, fonts and
426426
axes borders). (:pull:`3762`)
427427

428-
#. `@rcomer`_ corrected the Matplotlib backend in Iris tests to ignore
429-
`matplotlib.rcdefaults`_, instead the tests will **always** use ``agg``.
428+
#. `@rcomer`_ corrected the `matplotlib`_ backend in Iris tests to ignore
429+
:obj:`matplotlib.rcdefaults`, instead the tests will **always** use ``agg``.
430430
(:pull:`3846`)
431431

432432
#. `@bjlittle`_ migrated the `black`_ support from ``19.10b0`` to ``20.8b1``.
@@ -470,7 +470,6 @@ This document explains the changes made to Iris for this release
470470
with `flake8`_ and `black`_. (:pull:`3928`)
471471

472472
.. _Read the Docs: https://scitools-iris.readthedocs.io/en/latest/
473-
.. _Matplotlib: https://matplotlib.org/
474473
.. _CF units rules: https://cfconventions.org/Data/cf-conventions/cf-conventions-1.8/cf-conventions.html#units
475474
.. _CF Ancillary Data: https://cfconventions.org/Data/cf-conventions/cf-conventions-1.8/cf-conventions.html#ancillary-data
476475
.. _Quality Flags: https://cfconventions.org/Data/cf-conventions/cf-conventions-1.8/cf-conventions.html#flags
@@ -480,7 +479,6 @@ This document explains the changes made to Iris for this release
480479
.. _Cartopy#1105: https://github.com/SciTools/cartopy/pull/1105
481480
.. _Cartopy#1117: https://github.com/SciTools/cartopy/pull/1117
482481
.. _Dask: https://github.com/dask/dask
483-
.. _matplotlib.dates.date2num: https://matplotlib.org/api/dates_api.html#matplotlib.dates.date2num
484482
.. _Proj: https://github.com/OSGeo/PROJ
485483
.. _black: https://black.readthedocs.io/en/stable/
486484
.. _Proj#1292: https://github.com/OSGeo/PROJ/pull/1292
@@ -510,7 +508,6 @@ This document explains the changes made to Iris for this release
510508
.. _numpy: https://github.com/numpy/numpy
511509
.. _xxHash: https://github.com/Cyan4973/xxHash
512510
.. _PyKE: https://pypi.org/project/scitools-pyke/
513-
.. _matplotlib.rcdefaults: https://matplotlib.org/3.1.1/api/matplotlib_configuration_api.html?highlight=rcdefaults#matplotlib.rcdefaults
514511
.. _@owena11: https://github.com/owena11
515512
.. _GitHub: https://github.com/SciTools/iris/issues/new/choose
516513
.. _readthedocs: https://readthedocs.org/

0 commit comments

Comments
 (0)