Iris: A python package the for analysis and visualisation ... · A python package for the analysis...
Transcript of Iris: A python package the for analysis and visualisation ... · A python package for the analysis...
![Page 1: Iris: A python package the for analysis and visualisation ... · A python package for the analysis and visualisation of Meteorological data ... Biggus example: ... package the for](https://reader036.fdocuments.net/reader036/viewer/2022062504/5ae615517f8b9a8b2b8cc964/html5/thumbnails/1.jpg)
IrisA python package for the analysis and visualisation of Meteorological data
Philip Elson30th Sept 2015
![Page 2: Iris: A python package the for analysis and visualisation ... · A python package for the analysis and visualisation of Meteorological data ... Biggus example: ... package the for](https://reader036.fdocuments.net/reader036/viewer/2022062504/5ae615517f8b9a8b2b8cc964/html5/thumbnails/2.jpg)
Outline
What is Iris?
Iris demo
Using Iris for novel analysis
Opportunities for combining Iris with other tools
Audience of this talk:
Those who write code to do data analysis and visualisation
![Page 3: Iris: A python package the for analysis and visualisation ... · A python package for the analysis and visualisation of Meteorological data ... Biggus example: ... package the for](https://reader036.fdocuments.net/reader036/viewer/2022062504/5ae615517f8b9a8b2b8cc964/html5/thumbnails/3.jpg)
IrisWhat is ?
![Page 4: Iris: A python package the for analysis and visualisation ... · A python package for the analysis and visualisation of Meteorological data ... Biggus example: ... package the for](https://reader036.fdocuments.net/reader036/viewer/2022062504/5ae615517f8b9a8b2b8cc964/html5/thumbnails/4.jpg)
![Page 5: Iris: A python package the for analysis and visualisation ... · A python package for the analysis and visualisation of Meteorological data ... Biggus example: ... package the for](https://reader036.fdocuments.net/reader036/viewer/2022062504/5ae615517f8b9a8b2b8cc964/html5/thumbnails/5.jpg)
…PPGRIB
netCDF
SciPy
IrisWhat is ?
Iris
![Page 6: Iris: A python package the for analysis and visualisation ... · A python package for the analysis and visualisation of Meteorological data ... Biggus example: ... package the for](https://reader036.fdocuments.net/reader036/viewer/2022062504/5ae615517f8b9a8b2b8cc964/html5/thumbnails/6.jpg)
A simple example
![Page 7: Iris: A python package the for analysis and visualisation ... · A python package for the analysis and visualisation of Meteorological data ... Biggus example: ... package the for](https://reader036.fdocuments.net/reader036/viewer/2022062504/5ae615517f8b9a8b2b8cc964/html5/thumbnails/7.jpg)
>>> import iris
>>> air_temp = iris.load_cube(filename, 'air_temperature')
>>> print(air_temp)
air_temperature / (K) (latitude: 73; longitude: 96)Scalar coordinates:
pressure: 1000.0 hPa
time: 1998-12-01 00:00:00, bound=(1994-12-01 00:00:00,
1998-12-01 00:00:00)
Attributes:
STASH: m01s16i203
source: Data from Met Office Unified Model
Loading a cube
![Page 8: Iris: A python package the for analysis and visualisation ... · A python package for the analysis and visualisation of Meteorological data ... Biggus example: ... package the for](https://reader036.fdocuments.net/reader036/viewer/2022062504/5ae615517f8b9a8b2b8cc964/html5/thumbnails/8.jpg)
>>> import matplotlib.pyplot as plt>>> import iris.quickplot as qplt
>>> qplt.pcolormesh(air_temp, cmap='RdBu_r')>>> plt.gca().coastlines()
Plotting with matplotlib
Output:
PNG
PS
...
![Page 9: Iris: A python package the for analysis and visualisation ... · A python package for the analysis and visualisation of Meteorological data ... Biggus example: ... package the for](https://reader036.fdocuments.net/reader036/viewer/2022062504/5ae615517f8b9a8b2b8cc964/html5/thumbnails/9.jpg)
>>> from iris.analysis import Linear
>>> exeter = [('longitude', [-3.5]), ('latitude', [50.7])]
>>> exeter_temp = air_temp.interpolate(exeter, Linear())
Regridding and interpolation
>>> mslp_euro = iris.load_cube(filename2)
>>> air_temp_euro = air_temp.regrid(mslp_euro,Linear())
Typically, Iris takes cubes as input, and returns cubes as output.
![Page 10: Iris: A python package the for analysis and visualisation ... · A python package for the analysis and visualisation of Meteorological data ... Biggus example: ... package the for](https://reader036.fdocuments.net/reader036/viewer/2022062504/5ae615517f8b9a8b2b8cc964/html5/thumbnails/10.jpg)
>>> from cartopy.crs as ccrs
>>> ax = plt.axes(projection=ccrs.NorthPolarStereo())>>> qplt.pcolormesh(air_temp_euro, cmap='RdBu_r')
>>> ax.coastlines('50m')>>> ax.gridlines()
Maps with cartopy
Maps in Iris are drawn by cartopy, a
python package developed to solve
common dateline and pole
problems seen with traditional
mapping libraries.
![Page 11: Iris: A python package the for analysis and visualisation ... · A python package for the analysis and visualisation of Meteorological data ... Biggus example: ... package the for](https://reader036.fdocuments.net/reader036/viewer/2022062504/5ae615517f8b9a8b2b8cc964/html5/thumbnails/11.jpg)
A real-life example
![Page 12: Iris: A python package the for analysis and visualisation ... · A python package for the analysis and visualisation of Meteorological data ... Biggus example: ... package the for](https://reader036.fdocuments.net/reader036/viewer/2022062504/5ae615517f8b9a8b2b8cc964/html5/thumbnails/12.jpg)
MOGREPS-G Cyclone Database
An algorithm to identify and track fronts and cyclonic
features, based on:
Hewson, T.D. & H.A. Titley, 2010: Objective identification, typing
and tracking of the complete life-cycles of cyclonic features at
high spatial resolution. Meteorol. Appl., 17, 355-381.
![Page 13: Iris: A python package the for analysis and visualisation ... · A python package for the analysis and visualisation of Meteorological data ... Biggus example: ... package the for](https://reader036.fdocuments.net/reader036/viewer/2022062504/5ae615517f8b9a8b2b8cc964/html5/thumbnails/13.jpg)
Implementing the algorithm
• Load the phenomenon
• Regrid and interpolate data to specific to vertical levels
• Compute isolines for locating phenomenon + isosurfacesfor masking phenomenon, based on thresholds from paper
• Compute intersection of isosurfaces and isolines toidentify cyclonic features
Iris
Iris
![Page 14: Iris: A python package the for analysis and visualisation ... · A python package for the analysis and visualisation of Meteorological data ... Biggus example: ... package the for](https://reader036.fdocuments.net/reader036/viewer/2022062504/5ae615517f8b9a8b2b8cc964/html5/thumbnails/14.jpg)
• Classify cyclonic features based on phenomenon values
• Visualise cyclonic features and the underlying diagnostics
Barotropic Lows Frontal Waves Diminutive Waves
Iris
Iris
![Page 15: Iris: A python package the for analysis and visualisation ... · A python package for the analysis and visualisation of Meteorological data ... Biggus example: ... package the for](https://reader036.fdocuments.net/reader036/viewer/2022062504/5ae615517f8b9a8b2b8cc964/html5/thumbnails/15.jpg)
• Visualise fronts as a spaghetti plot
![Page 16: Iris: A python package the for analysis and visualisation ... · A python package for the analysis and visualisation of Meteorological data ... Biggus example: ... package the for](https://reader036.fdocuments.net/reader036/viewer/2022062504/5ae615517f8b9a8b2b8cc964/html5/thumbnails/16.jpg)
The Python ecosystem
![Page 17: Iris: A python package the for analysis and visualisation ... · A python package for the analysis and visualisation of Meteorological data ... Biggus example: ... package the for](https://reader036.fdocuments.net/reader036/viewer/2022062504/5ae615517f8b9a8b2b8cc964/html5/thumbnails/17.jpg)
Opportunities within Python
Recent GIS tools:
Shapely
Cartopy
Fiona
RasterIO
QGIS
http://scitools.org.uk/cartopy/docs/latest/examples/hurricane_katrina.html
Camp, J., Roberts, M., MacLachlan, C., Wallace, E., Hermanson, L., Brookshaw, A.,
Arribas, A., Scaife, A. A., Mar. 2015. Seasonal forecasting of tropical storms using the
Met Office GloSea5 seasonal forecast system. Quarterly Journal of the Royal
Meteorological Society
A recent publication combining shapely and Iris to assess the
skill of seasonal prediction of Hurricane landfall frequencies in
the North Atlantic:
![Page 18: Iris: A python package the for analysis and visualisation ... · A python package for the analysis and visualisation of Meteorological data ... Biggus example: ... package the for](https://reader036.fdocuments.net/reader036/viewer/2022062504/5ae615517f8b9a8b2b8cc964/html5/thumbnails/18.jpg)
Opportunities within Python
Large data manipulation:
Cython
Numba
Biggus
Dask
Tools to optimise slow for-loops
using static typing and JIT
compilation for C-like
performance
![Page 19: Iris: A python package the for analysis and visualisation ... · A python package for the analysis and visualisation of Meteorological data ... Biggus example: ... package the for](https://reader036.fdocuments.net/reader036/viewer/2022062504/5ae615517f8b9a8b2b8cc964/html5/thumbnails/19.jpg)
Opportunities within Python
Large data manipulation:
Cython
Numba
Biggus
Dask
>>> print(data)
<Array shape=(80640, 4, 144, 192)
dtype=dtype('float32') size=33.22 GiB>
>>> stats = [biggus.mean(data, axis=0),
biggus.max(data, axis=0),
biggus.min(data, axis=0)]
>>> biggus.ndarrays(stats)
Result in ~4m45s on an Intel Xeon E5520
with 8GiB memory, bound by I/O not CPU.
Biggus example:
Iris is using Biggus for many of it operations. This means that we
can load, analyse and save cubes way beyond the available
system memory.
![Page 20: Iris: A python package the for analysis and visualisation ... · A python package for the analysis and visualisation of Meteorological data ... Biggus example: ... package the for](https://reader036.fdocuments.net/reader036/viewer/2022062504/5ae615517f8b9a8b2b8cc964/html5/thumbnails/20.jpg)
Installing Iris
conda install iris --channel SciTools
Conda can be downloaded as part of “miniconda”: http://conda.pydata.org/miniconda.html
![Page 21: Iris: A python package the for analysis and visualisation ... · A python package for the analysis and visualisation of Meteorological data ... Biggus example: ... package the for](https://reader036.fdocuments.net/reader036/viewer/2022062504/5ae615517f8b9a8b2b8cc964/html5/thumbnails/21.jpg)
Questions
Github: github.com/pelson
Twitter: @pypelsonLinks from presentation:
github.com/pelson/ecmwf-vis-2015
Further reading:
github.com/scitools/courses