Unit types and unit conversions in AMUSE

Quick 'n' Dirty Example
cd to the directory where you checked out the amuse trunk and do this:

$ ./amuse.sh >>> from amuse.support.units.units import * >>> cm = named('centimeter', 'cm', 0.01 * m) >>> x = 1 | cm >>> x quantity >>> x.in_(m) quantity<0.01 m> >>> x.in_(AU) quantity<6.68458712267e-14 AU> >>>

The first thing above defines a new unit, the centimeter, as 0.01 meters. "m" is predefined in the units package, as is AU, parsec, and numerous other units. The construction "x = 1 | cm" creates a new "quantity", which is a number associated with a unit. The "in_(unit)" method called on a quantity converts that quantity to the same value with a different unit attached. The examples here convert the unit to meters and astronomical units.