NatPy
Convert the units of particle physics quantities
Packages needed:
- astropy
- numpy
- sympy
Basic Usage
Code levarages astropy.units.core.Unit and astropy.units.quantity.Quantity objects.
- Run
import numpyandfrom astropy import units as u. - Run
import natpy. - Access physical constants with symbol:
>>> natpy.c
<Quantity 2.99792458e+08 m / s>
>>> natpy.hbar
<Quantity 1.05457182e-34 J s>
-
Specify base of natural units with
natpy.set_active_units(). Pass a string corresponding to a list of default natural units, or a list of physical constants to set your own. List of default bases found innatpy/default_values.py. (will markdown later) -
Run
natpy.convert()to convert between units, including necessary factors of natural units. Pass just unit objects to obtain conversion factors. Pass quantity objects to perform conversions. E.g.
# kg to keV
>>> natpy.convert(u.kg, u.keV)
5.6173581670146864e+32
# Electron mass
>>> me = natpy.convert(9.11e-31 * u.kg, u.keV)
>>> me
<Quantity 511.74132902 keV>
# Energy of electron with momentum of 1 MeV
>>> p = 1 * u.MeV
>>> E = np.sqrt(p**2 + me**2)
# Convert to SI units
>>> natpy.convert(E,u.J)
<Quantity 1.79926309e-13 J>
Note: Summing quanties requires conventionally equivalent units.
- See
tests/convert_test.pyfor more examples.
Metadata
Release files for NatPy-andre-scaffidi 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| NatPy_andre_scaffidi-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for NatPy_andre_scaffidi-0.0.3-py3-none-any.whl |
Release files / NatPy_andre_scaffidi-0.0.3-py3-none-any.whl
| Download URL | NatPy_andre_scaffidi-0.0.3-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0e83943451e3179fdbe0e032f679b6e73288373c5ad29d33ea4e499823303cf6
|
|
BLAKE2b-256 checksum How to use checksums |
dd6cd2064495116a353b1796859215762e769ad5197dbd0e9439ff7ca74eb1e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.0.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
|
Security for NatPy-andre-scaffidi 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.