from_nrv_unit

nrv.utils.from_nrv_unit(value, unit)[source]

Convert a quantity value from the default nrv units to unit.

Parameters:
  • value (int, float, list or np.ndarray) – value or values wich should be converted.

  • unit (int or str) – unit from which value should be converted, see example.

Returns:

rounded value or values, with the same type and shape than value.

Return type:

int, float, list or np.ndarray

Example

Here are three ways of converting 4530um (default unit) into 4.53mm:

>>> import nrv
>>> val_default = 4530 # um
>>> val_default / nrv.mm
4.53
>>> nrv.from_nrv_unit(val_default, nrv.mm)
4.53
>>> nrv.from_nrv_unit(val_default, "mm")
4.53