This document explains the new/changed features of Iris in version 1.7. (View all changes.)
Release: | 1.7.4 |
---|---|
Date: | 15th April 2015 |
Showcase: Iris is making use of Biggus
Iris is now making extensive use of Biggus for virtual arrays and lazy array evaluation. In practice this means that analyses of cubes with data bigger than the available system memory are now possible.
Other than the improved functionality the changes are mostly transparent; for example, before the introduction of biggus, MemoryErrors were likely for very large datasets:
>>> result = extremely_large_cube.collapsed('time', iris.analyis.MEAN)
MemoryError
Now, for supported operations, the evaluation is lazy (i.e. it doesn’t take place until the actual data is subsequently requested) and can handle data larger than available system memory:
>>> result = extremely_large_cube.collapsed('time', iris.analyis.MEAN)
>>> print(type(result))
<class 'iris.cube.Cube'>
Memory is still a limiting factor if ever the data is desired as a NumPy array (e.g. via cube.data), but additional methods have been added to the Cube to support querying and subsequently accessing the “lazy” data form (see has_lazy_data() and lazy_data()).
Showcase: New interpolation and regridding API
New interpolation and regridding interfaces have been added which simplify and extend the existing functionality.
The interfaces are exposed on the cube in the form of the interpolate() and regrid() methods. Conceptually the signatures of the methods are:
interpolated_cube = cube.interpolate(interpolation_points, interpolation_scheme)
and:
regridded_cube = cube.regrid(target_grid_cube, regridding_scheme)
Whilst not all schemes have been migrated to the new interface, iris.analysis.Linear defines both linear interpolation and regridding, and iris.analysis.AreaWeighted defines an area weighted regridding scheme.
Showcase: Merge and concatenate reporting
Merge reporting is designed as an aid to the merge processes. Should merging a CubeList fail, merge reporting means that a descriptive error will be raised that details the differences between the cubes in the CubeList that prevented the merge from being successful.
A new CubeList method, called merge_cube(), has been introduced. Calling it on a CubeList will result in a single merged Cube being returned or an error message being raised that describes why the merge process failed.
The following example demonstrates the error message that describes a merge failure caused by cubes having differing attributes:
>>> cube_list = iris.cube.CubeList((c1, c2))
>>> cube_list.merge_cube()
Traceback (most recent call last):
...
raise iris.exceptions.MergeError(msgs)
iris.exceptions.MergeError: failed to merge into a single cube.
cube.attributes keys differ: 'foo'
The naming of this new method mirrors that of Iris load functions, where one would always expect a CubeList from iris.load() and a Cube from iris.load_cube().
Concatenate reporting is the equivalent process for concatenating a CubeList. It is accessed through the method concatenate_cube(), which will return a single concatenated cube or produce an error message that describes why the concatenate process failed.
Showcase: Cube broadcasting
When performing cube arithmetic, cubes now follow similar broadcasting rules as NumPy arrays.
However, the additional richness of Iris coordinate meta-data provides an enhanced capability beyond the basic broadcasting behaviour of NumPy.
This means that when performing cube arithmetic, the dimensionality and shape of cubes no longer need to match. For example, if the dimensionality of a cube is reduced by collapsing, then the result can be used to subtract from the original cube to calculate an anomaly:
>>> time_mean = original_cube.collapsed('time', iris.analysis.MEAN)
>>> mean_anomaly = original_cube - time_mean
Given both broadcasting and coordinate meta-data, Iris can now perform arithmetic with cubes that have similar but not identical shape:
>>> similar_cube = original_cube.copy()
>>> similar_cube.transpose()
>>> zero_cube = original_cube - similar_cube