Conform values in one unit to equivalent values in another, compatible unit. Returns the conformed values.
The values may either be a numpy array or a python numeric type. The returned value is of the same type, except that input integers are converted to floats (see the inplace keyword).
Parameters : | x : numpy.ndarray or python numeric
|
---|---|
Returns : |
|
Examples
>>> Units.conform(2, Units('km'), Units('m'))
2000.0
>>> import numpy
>>> a = numpy.arange(5.0)
>>> Units.conform(a, Units('minute'), Units('second'))
array([ 0., 60., 120., 180., 240.])
>>> a
array([ 0., 1., 2., 3., 4.])
>>> Units.conform(a,
Units('days since 2000-12-1'),
Units('days since 2001-1-1'), inplace=True)
array([-31., -30., -29., -28., -27.])
>>> a
array([-31., -30., -29., -28., -27.])
Warning
Do not change the calendar of reference time units in the current version. Whilst this is possible, it will almost certainly result in an incorrect interpretation of the data or an error. Allowing the calendar to be changed is under development and will be available soon.