SciTools/iris — pull request #284 by esc24 (2012-12-21 15:11:16+00:00)
Title: Changing units

Converting a cube from one unit to another is a multistage process that involves modifying the cube's ```data``` and the updating the ```units``` attribute to match. This increases the likelihood that the two fall out of sync. I've see user code that subtracts 273.15 from temperature data and doesn't update the units.

This pull request implements conversion of a cube's units on assignment to the ```units``` attribute. For example, to convert a cube in kelvin to celsius currently requires:
```python
cube.data = cube.units.convert(cube.data, 'celsius')
cube.units = 'celsius'
```
This PR means the this could be achieved by simply:
```
cube.units = 'kelvin'
```
If the units are unknown no attempt to convert the data is made. To change the units without touching ```cube.data``` I've added a ```cube.replace_units()``` method. I've also added a ```cube.unit_converted()``` method that mirrors the behaviour of ```coord.unit_converted()``` allowing out of place conversion.

The changes have been made to the iris.coords.unit property as well.

In the process of development I've also extended iris.unit.convert to handle arrays of integers, and enabled the basic maths functions (add/subtract/multiple/divide) to better handle mixed but compatible units e.g. Pa and hPa.