Getting started
This tutorial shows how to import units and perform basic calculations with them. It also demonstrates how the console output changes when using prefixes and composite units.
import numpy as np from qunits import u q = 2 * u.e # >>> 2.0 e v = 2e5 * u.m / u.s # >>> 200000.0 m/s B = 0.42 * u.mT # >>> 0.42 mT F = q * v * B # >>> 168000.0 e⋅m⋅mT/s F = F.to_base_units() # >>> 2.6916567451199998e-17 N F = F.to(u.e * u.V / u.m) # >>> 168.0 e⋅V/m omega = 2 * u.pi * u.kHz # >>> 2.0 pi⋅kHz T = np.linspace(0, 10, 6) * u.ms # >>> [ 0. 2. 4. 6. 8. 10.] ms Ft = F * np.sin(omega * T) # >>> [ 0. -127.14281921 ... 153.37480212] V⋅e/m