Skip to main content

natu

Natural units in Python

natu is a free, open-source package to represent physical quantities. There are many Python packages that deal with units and quantities, but natu is uniquely system-independent. The units are derived from physical constants with adjustable values and dimensions. The value of a unit is factored into a quantity so that the quantity is not “in” any particular unit. This has the following advantages:

  • Flexible: Different unit systems, including natural units (hence the name “natu”), can be represented by simply adjusting the base physical constants.

  • Simple: Unit conversion is inherent. This results in quick computations and a small code base (about 1500 lines). By default, dimensions and display units are tracked to catch errors and for string formatting. This can be disabled to nearly eliminate the computational overhead while still providing the core features.

  • Intuitive: Each unit is a fixed quantity that is treated as a mathematical entity. A variable quantity is expressed as the product of a number and a unit, as stated by BIPM.

  • Representative: The design reflects the way modern units are defined. Standards organizations such as NIST assign values to universal physical constants so that the values of units can be determined by physical experiments instead of prototypes.

  • Scalable: The values of the base physical constants can scaled to prevent exponent overflow, regardless of the units used.

For example, you can do this:

>>> from natu.units import degC, K
>>> 0*degC + 100*K
100.0 degC

Please see the main website and the tutorial for more examples.

Installation

The easiest way to install natu is to use pip:

> pip install natu

On Linux, it may be necessary to have root privileges:

$ sudo pip install natu

License terms and development

natu is published under a BSD-compatible license. Please share any improvements you make, preferably as a pull request to the master branch of the GitHub repository. There are useful development scripts in the hooks folder. If you find a bug, have a suggestion, or just want to leave a comment, please open an issue.

Metadata

Release files for natu 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for natu 0.1.1
File Size Uploaded
natu-0.1.1.tar.gz 166.5 kB Details

Release files / natu-0.1.1.tar.gz

Download URL natu-0.1.1.tar.gz
Size 166.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c9302d52d3c01a75c18ba74d80ab9dc2ede9bb159a5c014641da16c0d754f7cc
BLAKE2b-256 checksum
How to use checksums
4e3b31f25630043aeab35b6743581af811c321d268b328ea7f20e405754bcbfc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page