Physical units library
Project description
Standard physical units are imported from intec.units.si
from intec.units.si import METER, MILLIMETER, NANOMETER, AMPERE, VOLT, OHM
A Quantity is created by multiplying a number (the magnitude) and a Unit
d = 1550*NANOMETER
print(d)
1550.000000 nm
d
LengthQuantity( 1.5500000000e+03, nm )
Quantities of the same physical dimension can be added or substracted
1*METER + 5*MILLIMETER
LengthQuantity( 1.0050000000e+00, m )
The resulting quantity gets the unit of the first term.
print(5*MILLIMETER + 1*METER)
1005.000000 mm
1*METER + 1*AMPERE
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-6-26114287a935> in <module>
----> 1 1*METER + 1*AMPERE
TypeError: Cannot convert unit [A] to unit [m]
Quantities of the same physical dimension can be compared
p = 1*VOLT*2*AMPERE
print(p)
2.000000 V.A
from intec.units.si import WATT, MILLIWATT, DBM
p == 2*WATT
True
3*VOLT/AMPERE > 2*OHM
True
Use the to member function to convert a quantity to a related unit.
print(p.to(MILLIWATT))
print(p.to(DBM))
2000.000000 mW
33.010300 dBm
from intec.units.si import METER, KILOMETER, SECOND
from intec.units.extra import HOUR
speed = 10*METER/SECOND
print(speed.to(KILOMETER/HOUR))
36.000000 km/h
Use the member magnitude or m to retrieve the numerical value of a quantity
speed.magnitude
10.0
speed.m
10.0
Use the member unit or u to retrieve the unit of a quantity
speed.unit
Unit( 'm/s' [m/s] )
speed.u
Unit( 'm/s' [m/s] )
For (wave)lengths there is a convenience function to convert to frequency.
from intec.units.si import NANOMETER,HERTZ
λ = 1550*NANOMETER
λ.to_frequency()
FrequencyQuantity( 1.9341448903e+02, THz )
λ.to_frequency(HERTZ)
FrequencyQuantity( 1.9341448903e+14, Hz )
For photonic experiments, use intec.units.photonic to import all common units in one fell swoop
from intec.units.photonic import *
from .si import METER, MILLIMETER, MICROMETER, NANOMETER, PICOMETER, FEMTOMETER
from .si import WATT, MILLIWATT, MICROWATT, DBM
from .si import VOLT, MILLIVOLT, MICROVOLT
from .si import AMPERE, MILLIAMPERE, MICROAMPERE
from .si import HERTZ, KILOHERTZ, MEGAHERTZ, GIGAHERTZ, TERAHERTZ
from .si import SECOND, MILLISECOND, MICROSECOND
from .si import KELVIN, CELCIUS
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file intec_units-0.0.5-cp38-cp38m-win_amd64.whl.
File metadata
- Download URL: intec_units-0.0.5-cp38-cp38m-win_amd64.whl
- Upload date:
- Size: 26.6 kB
- Tags: CPython 3.8m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.5.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
779d9f2c2040c390bfa73b9718c42fb69c306a421d68731825a78e511afa11a6
|
|
| MD5 |
49d0ff69c41cbebd8edcb2ae1cf3800a
|
|
| BLAKE2b-256 |
d78fb8d9828efda08a53781ae2716d1c3f8e945752cf544c4737dc0e4a85dbcc
|
File details
Details for the file intec_units-0.0.5-cp38-cp38m-win32.whl.
File metadata
- Download URL: intec_units-0.0.5-cp38-cp38m-win32.whl
- Upload date:
- Size: 24.7 kB
- Tags: CPython 3.8m, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.5.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36761f6b25e38d06cce69ffbc040809c9bbe1bfec2ff0694f1d52fed34628763
|
|
| MD5 |
314c23eb7c092305accb4a8c3578e46d
|
|
| BLAKE2b-256 |
834b3b58e43d429b4795004510756df2e3aacf64b407959e6dd1bcefa88638b2
|
File details
Details for the file intec_units-0.0.5-cp37-cp37m-win_amd64.whl.
File metadata
- Download URL: intec_units-0.0.5-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 26.6 kB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.5.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2fbb5bee0cef86a88cfbfbbbcc9ac6f6af8cbe4ef73cfeba3f84a91ef20f385e
|
|
| MD5 |
08d4196c637853a28ae8925a035c887c
|
|
| BLAKE2b-256 |
6fa23187f641373a1b025bd36662ed3e0955e1b454b94f5ee501f4b1d5d53360
|
File details
Details for the file intec_units-0.0.5-cp37-cp37m-win32.whl.
File metadata
- Download URL: intec_units-0.0.5-cp37-cp37m-win32.whl
- Upload date:
- Size: 24.8 kB
- Tags: CPython 3.7m, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.5.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0efb72a0fc086b406f8f27f4a5e1f85a1f6540831bc18537dc770be5e5355dec
|
|
| MD5 |
fd6eac05cf84849943543079fe076af9
|
|
| BLAKE2b-256 |
2ae197679d5265dd2313d7c51279ffbb1043434904f5b9191917487a3b230d81
|
File details
Details for the file intec_units-0.0.5-cp36-cp36m-win_amd64.whl.
File metadata
- Download URL: intec_units-0.0.5-cp36-cp36m-win_amd64.whl
- Upload date:
- Size: 26.6 kB
- Tags: CPython 3.6m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.5.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4f0df35f459cc0ffdf312783c24af1e3024491736a70b90c292326c1074c76d
|
|
| MD5 |
d958ce9e601fdfc3f836a03da60ee97a
|
|
| BLAKE2b-256 |
e10d9358414afbcc7a31f18e6f62de99bd6af213732aa9fdbab1082c94dd0640
|
File details
Details for the file intec_units-0.0.5-cp36-cp36m-win32.whl.
File metadata
- Download URL: intec_units-0.0.5-cp36-cp36m-win32.whl
- Upload date:
- Size: 24.8 kB
- Tags: CPython 3.6m, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.5.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ca61300a1fef2931c92d62c71a7f019acac0b588e0cc212a346cea7aa459957
|
|
| MD5 |
c9b0ae13898f3ba2e26be6acb74eb130
|
|
| BLAKE2b-256 |
013ea02781b2e7776455341d6c16bebb859d5bc2846344c127e4a4a5b1218eea
|
File details
Details for the file intec_units-0.0.5-cp35-cp35m-win_amd64.whl.
File metadata
- Download URL: intec_units-0.0.5-cp35-cp35m-win_amd64.whl
- Upload date:
- Size: 26.6 kB
- Tags: CPython 3.5m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.5.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50333cbcda09140c7c29f81128561d1f4f7a5c9de5cad8d584c98324f3d4387d
|
|
| MD5 |
5a5ac04fe1f531b3a9982dbf35d229a9
|
|
| BLAKE2b-256 |
2d4d8b84a6d4cdcbaa51100830d8e784e874ebc6f71982d1c3e114c3e778a946
|
File details
Details for the file intec_units-0.0.5-cp35-cp35m-win32.whl.
File metadata
- Download URL: intec_units-0.0.5-cp35-cp35m-win32.whl
- Upload date:
- Size: 24.8 kB
- Tags: CPython 3.5m, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.5.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eadb471ba6b08a1b3d16eb958cee7a1b79e9f8583c8e834f48731a2ba21a88c3
|
|
| MD5 |
d61df3aa3edfa947e4952a1d5d45fdc5
|
|
| BLAKE2b-256 |
16dfc7d12c7c4b705eda325107db059a2defe7072824b41dca52dba5aef2a034
|
File details
Details for the file intec_units-0.0.5-cp34-cp34m-win_amd64.whl.
File metadata
- Download URL: intec_units-0.0.5-cp34-cp34m-win_amd64.whl
- Upload date:
- Size: 26.6 kB
- Tags: CPython 3.4m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.5.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ebe6abd18d06becb365a04f1c9d8fa2b053a47677a5796da6ed16f3a8682f903
|
|
| MD5 |
8600c5967fd1114b91a7b60e15155453
|
|
| BLAKE2b-256 |
b5387333e2334d6c29c1a862458611e6c06ec40b730e8e6244c22aa3a31c321d
|
File details
Details for the file intec_units-0.0.5-cp34-cp34m-win32.whl.
File metadata
- Download URL: intec_units-0.0.5-cp34-cp34m-win32.whl
- Upload date:
- Size: 24.8 kB
- Tags: CPython 3.4m, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.5.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02bddfe4c953557a4753c0ae3be72d29a59268cfdd4b6c230a05de216e7fb757
|
|
| MD5 |
70201f35c44089b513d52eab36d3c699
|
|
| BLAKE2b-256 |
3d48556575a4db97bb2d58311235cec2f75109cc82acee3e7febfdf43c82b076
|