act.utils.convert_units#

act.utils.convert_units(data, in_units, out_units)[source]#

Wrapper function around library to convert data using unit strings. Currently using pint units library. Will attempt to preserve numpy data type, but will upconvert to numpy float64 if need to change data type for converted values.

Parameters:
  • data (list, tuple or numpy array) – Data array to be modified.

  • in_units (str) – Units scalar string of input data array.

  • out_units (str) – Units scalar string of desired output data array.

Returns:

data (numpy array) – Data array converted into new units.

Examples

> data = np.array([1,2,3,4,5,6]) > data = convert_units(data, ‘cm’, ‘m’) > data array([0.01, 0.02, 0.03, 0.04, 0.05, 0.06])