to_nrv_unit
- nrv.utils.to_nrv_unit(value, unit)[source]
Convert a quantity
valuefrom unit to the default nrvunit.- Parameters:
- Returns:
rounded value or values, with the same type and shape than
value.- Return type:
Example
Here are three ways of converting 0.12 MHz into the default unit of the corresponding nrv (kHz):
>>> import nrv >>> val_MHz = 0.12 # MHz >>> val_MHz * nrv.MHz 120.0 >>> nrv.to_nrv_unit(val_MHz, nrv.MHz) 120.0 >>> nrv.to_nrv_unit(val_MHz, "MHz") 120.0
Here is how to convert a
listornp.arrayof values in seconds to milliseconds (nrv’s default unit):