convert
- nrv.utils.convert(value, unitin, unitout)[source]
Convert a quantity
value
fromunitin
tounitout
.- Parameters:
value (int, float, list or np.ndarray) – value or values wich should be converted.
unit (int or str) – unit to which value should be converted, see examples.
- Returns:
rounded value or values, with the same type and shape than
value
.)- Return type:
int, float, list or np.ndarray
Example
Here are two ways of converting 0.2 S/m^{2} into S/cm^{2}:
>>> import nrv >>> val_S_m = 0.2 # S/m**2 >>> nrv.convert(val_S_m, nrv.S/nrv.m**2, nrv.S/nrv.cm**2) 2e-05 >>> nrv.convert(val_S_m, "S/m**2", "S/cm**2") 2e-05