├── .gitignore ├── .nojekyll ├── CITATION.cff ├── LICENSE ├── README.md ├── dist ├── metrolopy-0.6.5-py3-none-any.whl └── metrolopy-0.6.5.tar.gz ├── docs ├── .nojekyll ├── Makefile ├── _build │ ├── doctrees │ │ ├── environment.pickle │ │ ├── hand_made_doc.doctree │ │ ├── index.doctree │ │ ├── metrolopy.doctree │ │ ├── metrolopy.tests.doctree │ │ ├── modules.doctree │ │ └── todo.doctree │ └── html │ │ ├── _downloads │ │ └── tutorial.ipynb │ │ ├── _sources │ │ ├── hand_made_doc.rst.txt │ │ ├── index.rst.txt │ │ ├── metrolopy.rst.txt │ │ ├── metrolopy.tests.rst.txt │ │ ├── modules.rst.txt │ │ └── todo.rst.txt │ │ ├── _static │ │ ├── ajax-loader.gif │ │ ├── basic.css │ │ ├── comment-bright.png │ │ ├── comment-close.png │ │ ├── comment.png │ │ ├── constants.html │ │ ├── doctools.js │ │ ├── down-pressed.png │ │ ├── down.png │ │ ├── file.png │ │ ├── jquery-3.1.0.js │ │ ├── jquery.js │ │ ├── minus.png │ │ ├── nature.css │ │ ├── plus.png │ │ ├── pygments.css │ │ ├── searchtools.js │ │ ├── tutorial.html │ │ ├── underscore-1.3.1.js │ │ ├── underscore.js │ │ ├── units.html │ │ ├── up-pressed.png │ │ ├── up.png │ │ └── websupport.js │ │ ├── genindex.html │ │ ├── hand_made_doc.html │ │ ├── index.html │ │ ├── metrolopy.html │ │ ├── metrolopy.tests.html │ │ ├── modules.html │ │ ├── objects.inv │ │ ├── py-modindex.html │ │ ├── search.html │ │ ├── searchindex.js │ │ └── todo.html ├── _static │ ├── .DS_Store │ ├── constants.html │ ├── tutorial.html │ └── units.html ├── conf.py ├── hand_made_doc.rst ├── index.html ├── index.rst ├── make.bat ├── metrolopy.rst ├── metrolopy.tests.rst ├── modules.rst ├── todo.rst └── tutorial.ipynb ├── metrolopy ├── __init__.py ├── budget.py ├── codata2018.py ├── constant.py ├── constcom.py ├── dfunc.py ├── distributions.py ├── exceptions.py ├── fit.py ├── functions.py ├── gummy.py ├── indexed.py ├── license.txt ├── logunit.py ├── mean.py ├── miscunits.py ├── nonlinearunit.py ├── nummy.py ├── offsetunit.py ├── pmethod.py ├── prefixedunit.py ├── printing.py ├── relunits.py ├── siunits.py ├── tests │ ├── __init__.py │ ├── common.py │ ├── test_complex.py │ ├── test_create.py │ ├── test_gummy.py │ ├── test_misc.py │ ├── test_operations.py │ └── test_ubreakdown.py ├── ummy.py ├── unit.py ├── unitparser.py ├── unitutils.py ├── usunits.py └── version.py └── setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | #dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | 106 | doctrees/ 107 | .buildinfo 108 | 109 | .DS_Store 110 | -------------------------------------------------------------------------------- /.nojekyll: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /CITATION.cff: -------------------------------------------------------------------------------- 1 | cff-version: 1.2.0 2 | message: "If you use this software, please cite it as below." 3 | authors: 4 | - family-names: "Parks" 5 | given-names: "Harold V." 6 | title: "MetroloPy" 7 | version: 0.6.5 8 | doi: 10.5281/zenodo.15595291 9 | date-released: 2025-06-04 10 | url: "https://github.com/nrc-cnrc/MetroloPy" 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MetroloPy 2 | 3 | tools for dealing with physical quantities: uncertainty propagation and unit conversion 4 | 5 | --- 6 | 7 | MetroloPy is a pure python package and requires Python 3.5 or later and the SciPy stack (NumPy, SciPy and Pandas). It looks best in a Jupyter Notebook. 8 | 9 | Install MetroloPy with `pip install metrolopy` or 10 | `conda install -c conda-forge metrolopy`. 11 | 12 | Physical quantities can then be represented in Python as `gummy` objects with an uncertainty and (or) a unit: 13 | 14 |
>>> import metrolopy as uc
15 | >>> a = uc.gummy(1.2345,u=0.0234,unit='cm')
16 | >>> a
17 | 1.234(23) cm
18 |
19 | >>> b = uc.gummy(3.034,u=0.174,unit='mm')
20 | >>> f = uc.gummy(uc.UniformDist(center=0.9345,half_width=0.096),unit='N')
21 | >>> p = f/(a*b)
22 | >>> p
23 | 2.50(21) N/cm2
24 |
25 | >>> p.unit = 'kPa'
26 | >>> p.uunit = '%'
27 | >>> p
28 | 25.0 kPa ± 8.5%
29 |
30 |
31 | 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. See:
32 |
33 | * [a tutorial](https://nrc-cnrc.github.io/MetroloPy/_build/html/_static/tutorial.html) (or download the tutorial as Jupyter notebook)
34 | * [the documentation](https://nrc-cnrc.github.io/MetroloPy/)
35 | * [the issues page on GitHub](https://github.com/nrc-cnrc/Metrolopy/issues)
36 | * [a list of the units built into MetroloPy](https://nrc-cnrc.github.io/MetroloPy/_static/units.html)
37 | * [a list of the physical constants built into MetroloPy](https://nrc-cnrc.github.io/MetroloPy/_static/constants.html)
38 |
39 | ## new in version 0.6.0
40 |
41 | * A constant library has been added with physical constants that can be accessed
42 | by name or alias with the `constant` function. The `search_constants` function
43 | with no argument gives a listing of all built-in constants. Each constant
44 | definition includes any correlations with other constants.
45 |
46 | * The `Quantity` class has been added to represent a general numerical value
47 | multiplied by a unit and the `unit` function has been added to retrieve
48 | `Unit` instances from the unit library by name or alias. `Unit` instances
49 | can now be multiplied and divided by other `Unit` instances to produce
50 | composite units, can be multiplied and divided by numbers to produce
51 | `Quantity` instances or multiply or divide `Quantity` instances. The
52 | `gummy` class is now a subclass of `Quantity` with a `nummy` value rather
53 | than a subclass of `nummy`. A `QuantityArray` class has been introduced
54 | to represent an array of values all with the same unit. Multiplying a `Unit`
55 | instance by a list, tuple, or numpy array produces a `QuantityArray` instance.
56 |
57 | * The `immy` class has been introduced as an `ummy` valued counterpart of the
58 | `jummy` class for representing complex values with uncertainties. `immy`
59 | and `jummy` values can now be displayed in a polar representation in addition
60 | to a cartesian representation. `immy` and `jummy` .r and .phi properties
61 | have been added to access the magnitude and argument of the values as a
62 | complement to the .real and .imag properties.
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/dist/metrolopy-0.6.5-py3-none-any.whl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nrc-cnrc/MetroloPy/333f9a9fb8c81696a92adafbf3ed831bf18b3d17/dist/metrolopy-0.6.5-py3-none-any.whl
--------------------------------------------------------------------------------
/dist/metrolopy-0.6.5.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nrc-cnrc/MetroloPy/333f9a9fb8c81696a92adafbf3ed831bf18b3d17/dist/metrolopy-0.6.5.tar.gz
--------------------------------------------------------------------------------
/docs/.nojekyll:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/docs/Makefile:
--------------------------------------------------------------------------------
1 | # Minimal makefile for Sphinx documentation
2 | #
3 |
4 | # You can set these variables from the command line.
5 | SPHINXOPTS =
6 | SPHINXBUILD = sphinx-build
7 | SPHINXPROJ = metrolopy
8 | SOURCEDIR = .
9 | BUILDDIR = _build
10 |
11 | # Put it first so that "make" without argument is like "make help".
12 | help:
13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14 |
15 | .PHONY: help Makefile
16 |
17 | # Catch-all target: route all unknown targets to Sphinx using the new
18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19 | %: Makefile
20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
--------------------------------------------------------------------------------
/docs/_build/doctrees/environment.pickle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nrc-cnrc/MetroloPy/333f9a9fb8c81696a92adafbf3ed831bf18b3d17/docs/_build/doctrees/environment.pickle
--------------------------------------------------------------------------------
/docs/_build/doctrees/hand_made_doc.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nrc-cnrc/MetroloPy/333f9a9fb8c81696a92adafbf3ed831bf18b3d17/docs/_build/doctrees/hand_made_doc.doctree
--------------------------------------------------------------------------------
/docs/_build/doctrees/index.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nrc-cnrc/MetroloPy/333f9a9fb8c81696a92adafbf3ed831bf18b3d17/docs/_build/doctrees/index.doctree
--------------------------------------------------------------------------------
/docs/_build/doctrees/metrolopy.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nrc-cnrc/MetroloPy/333f9a9fb8c81696a92adafbf3ed831bf18b3d17/docs/_build/doctrees/metrolopy.doctree
--------------------------------------------------------------------------------
/docs/_build/doctrees/metrolopy.tests.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nrc-cnrc/MetroloPy/333f9a9fb8c81696a92adafbf3ed831bf18b3d17/docs/_build/doctrees/metrolopy.tests.doctree
--------------------------------------------------------------------------------
/docs/_build/doctrees/modules.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nrc-cnrc/MetroloPy/333f9a9fb8c81696a92adafbf3ed831bf18b3d17/docs/_build/doctrees/modules.doctree
--------------------------------------------------------------------------------
/docs/_build/doctrees/todo.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nrc-cnrc/MetroloPy/333f9a9fb8c81696a92adafbf3ed831bf18b3d17/docs/_build/doctrees/todo.doctree
--------------------------------------------------------------------------------
/docs/_build/html/_sources/index.rst.txt:
--------------------------------------------------------------------------------
1 | .. metrolopy documentation master file, created by
2 | sphinx-quickstart on Fri Feb 22 16:15:02 2019.
3 | You can adapt this file completely to your liking, but it should at least
4 | contain the root `toctree` directive.
5 |
6 | .. toctree::
7 | :maxdepth: 2
8 | :caption: Contents:
9 |
10 | ===================
11 | MetroloPy, the docs
12 | ===================
13 |
14 | tools for dealing with physical quantities: uncertainty propagation and unit
15 | conversion
16 |
17 |
18 | getting started
19 | ===============
20 |
21 | MetroloPy is a pure python package and requires Python 3 and the
22 | `SciPy >>> import metrolopy as uc
36 | >>> a = uc.gummy(1.2345,u=0.0234,unit='cm')
37 | >>> a
38 | 1.234(23) cm
39 |
40 | >>> b = uc.gummy(3.034,u=0.174,unit='mm')
41 | >>> f = uc.gummy(uc.UniformDist(center=0.9345,half_width=0.096),unit='N')
42 | >>> p = f/(a*b)
43 | >>> p
44 | 2.50(21) N/cm2
45 |
46 | >>> p.unit = 'kPa'
47 | >>> p.uunit = '%'
48 | >>> p
49 | 25.0 kPa ± 8.5%
50 |
48 | m | ||
52 | |
53 | metrolopy | 54 | |
57 | |
58 | metrolopy.budget | 59 | |
62 | |
63 | metrolopy.dfunc | 64 | |
67 | |
68 | metrolopy.distributions | 69 | |
72 | |
73 | metrolopy.exceptions | 74 | |
77 | |
78 | metrolopy.fit | 79 | |
82 | |
83 | metrolopy.functions | 84 | |
87 | |
88 | metrolopy.gummy | 89 | |
92 | |
93 | metrolopy.logunit | 94 | |
97 | |
98 | metrolopy.mean | 99 | |
102 | |
103 | metrolopy.nonlinearunit | 104 | |
107 | |
108 | metrolopy.nummy | 109 | |
112 | |
113 | metrolopy.offsetunit | 114 | |
117 | |
118 | metrolopy.pmethod | 119 | |
122 | |
123 | metrolopy.prefixedunit | 124 | |
127 | |
128 | metrolopy.printing | 129 | |
132 | |
133 | metrolopy.relunits | 134 | |
137 | |
138 | metrolopy.siunits | 139 | |
142 | |
143 | metrolopy.tests | 144 | |
147 | |
148 | metrolopy.tests.test_create | 149 | |
152 | |
153 | metrolopy.ummy | 154 | |
157 | |
158 | metrolopy.unit | 159 | |
162 | |
163 | metrolopy.unitutils | 164 | |
167 | |
168 | metrolopy.usunits | 169 | |
172 | |
173 | metrolopy.version | 174 | |
55 | Searching for multiple words only shows matches that contain 56 | all words. 57 |
58 | 59 | 60 | 65 | 66 | 67 | 68 | 69 | 70 | 71 |Lots of help is needed to find bugs.
39 |start by putting something here
42 |>>> import metrolopy as uc
36 | >>> a = uc.gummy(1.2345,u=0.0234,unit='cm')
37 | >>> a
38 | 1.234(23) cm
39 |
40 | >>> b = uc.gummy(3.034,u=0.174,unit='mm')
41 | >>> f = uc.gummy(uc.UniformDist(center=0.9345,half_width=0.096),unit='N')
42 | >>> p = f/(a*b)
43 | >>> p
44 | 2.50(21) N/cm2
45 |
46 | >>> p.unit = 'kPa'
47 | >>> p.uunit = '%'
48 | >>> p
49 | 25.0 kPa ± 8.5%
50 |