SciTools/iris — pull request #320 by esc24 (2013-01-22 16:16:30+00:00)
Title: Changing units

This is a replacement for PR #284.

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

This pull request adds two methods to cubes and coords:
1. ```change_units()``` to change from one unit to another modifying the data e.g. celsius to kelvin.
2. ```replace_units()``` to change the units attribute, but leave the data untouched.

Assigning to the ```units``` attribute will now raise an exception if the object already has known units unless assigning None to remove those units.

(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.)