MetroloPy, the docs

tools for dealing with physical quantities: uncertainty propagation and unit conversion

getting started

MetroloPy is a pure python package and requires Python 3 and the SciPy stack (NumPy, SciPy, Pandas, and IPython). It looks best in a Jupyter notebook.

Install MetroloPy with pip install metrolopy or conda install -c conda-forge metrolopy.

Physical quantities can then be represented in Python as gummy objects with an uncertainty and (or) a unit:

>>> import metrolopy as uc
>>> a = uc.gummy(1.2345,u=0.0234,unit='cm')
>>> a
1.234(23) cm

>>> b = uc.gummy(3.034,u=0.174,unit='mm')
>>> f = uc.gummy(uc.UniformDist(center=0.9345,half_width=0.096),unit='N')
>>> p = f/(a*b)
>>> p
2.50(21) N/cm2

>>> p.unit = 'kPa'
>>> p.uunit = '%'
>>> p
25.0 kPa ± 8.5%

MetroloPy can do much more including Monte-Carlo uncertainty propagation, generating uncertainty budget tables, and curve fitting. It can also handle expanded uncertainties, degrees of freedom, correlated quantities, and complex valued quantities.

further reading

the auto-generated docs (indices and tables)

These pages were automatically generated from the doc strings in the source code. They are slightly more comprehensive but perhaps slightly more confusing than the handmade API docs referenced in the further reading section above.

Where did the name for the gummy class come from?

The name comes from the JGCM/ISO Guide to the Expression of Uncertainty in Measurement which is also known as the GUM. The GUM is the international standard used by metrology institutes and calibration labs for expressing and propagating measurement uncertainty. The gummy object implements many of the recommendations outlined in the GUM.

Other references of note are the draft 9th edition of the SI Brochure which contains the definitions of the SI units, and NIST Special Publication 1038 where many of the US customary units are defined. Some physical constants used for unit definitions are from the 2014 CODATA recommended values and the IAU 2009 system of astronomical constants.

version history

  • Version 0.5.0, built 26 March 2019, is the first public release.

  • Version 0.5.1, built 2 April 2019, fixed a major bug that generated negative uncertainties in some cases and fixed some other minor bugs. Improved support for fraction.Fraction and mpmath.mpf values.

  • Version 0.5.2, built 5 April 2019, fixed a major bug that propagated uncertainty incorrectly if a gummy was created with an uncertainty set with an integer data type. Fixed several other minor bugs.

  • Version 0.5.3, built 10 April 2019, minor bug fixes.

  • Version 0.5.4, built 15 April 2019, minor bug fixes.

  • Version 0.5.5, built 7 May 2020, minor bug fixes.

  • Version 0.5.6, built 24 September 2020, minor bug fixes.

  • Version 0.5.7, built 26 September 2020, minor change to setup.py.

  • Verison 0.6.0, built 19 October 2020, added the Quantity and immy classes as well as a library of physical constants.

  • Version 0.6.1 built 19 October 2020, bug fixes

  • Version 0.6.2 built 10 July 2021, bug fixes

  • Version 0.6.3 built 13 May 2022, bug fixes

author

Harold Parks, parksh@nrc.ca, National Research Council Canada

license

MetroloPy is distributed as free software under the terms of the GNU General Public License version 3. In practice, this license imposes no restriction on using MetroloPy. However, if you want to further convey verbatim or modified versions of the code you must do so under the same license terms. Please contact NRC if you wish to license MetroloPy under different terms.