Skip to main content

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

Project description

MetroloPy

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


MetroloPy is a pure python package and requires Python 3.6 or later and the SciPy stack (NumPy, SciPy and Pandas). 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. See:

new in version 1.0.0

  • The calculation of effective degrees of freedom has been improved. In previous versions, in a multi-step calculation, the effective degree of freedom were calculated at each step based on the degrees of freedom calculated for the previous step (using a modified Welch-Satterthwaite approximation). Now effective degrees of freedom are always calculated directly from the independent variables using the Welch-Satterthwaite equation.

  • CODATA 2022 values instead of 2018 values are used in the Constants module.

  • The significance value in budget table has been redefined from (sensitivity coefficient * standard uncertainty/combined uncertainty) to the square of that value so that the significance values in a budget sum to one.

  • Units can now be raised to a fractional power and many other bug fixes.

new in version 0.6.0

  • A constant library has been added with physical constants that can be accessed by name or alias with the constant function. The search_constants function with no argument gives a listing of all built-in constants. Each constant definition includes any correlations with other constants.

  • The Quantity class has been added to represent a general numerical value multiplied by a unit and the unit function has been added to retrieve Unit instances from the unit library by name or alias. Unit instances can now be multiplied and divided by other Unit instances to produce composite units, can be multiplied and divided by numbers to produce Quantity instances or multiply or divide Quantity instances. The gummy class is now a subclass of Quantity with a nummy value rather than a subclass of nummy. A QuantityArray class has been introduced to represent an array of values all with the same unit. Multiplying a Unit instance by a list, tuple, or numpy array produces a QuantityArray instance.

  • The immy class has been introduced as an ummy valued counterpart of the jummy class for representing complex values with uncertainties. immy and jummy values can now be displayed in a polar representation in addition to a cartesian representation. immy and jummy .r and .phi properties have been added to access the magnitude and argument of the values as a complement to the .real and .imag properties.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

metrolopy-1.0.2.tar.gz (181.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

metrolopy-1.0.2-py3-none-any.whl (208.1 kB view details)

Uploaded Python 3

File details

Details for the file metrolopy-1.0.2.tar.gz.

File metadata

  • Download URL: metrolopy-1.0.2.tar.gz
  • Upload date:
  • Size: 181.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for metrolopy-1.0.2.tar.gz
Algorithm Hash digest
SHA256 9812cc8c8aa9bb40855e53bbf4d3bce20a0b46aa4382f3af1ee67621a1b32d82
MD5 d6a030a65aeac40ff6dca9410dfc725a
BLAKE2b-256 f42412fe0bce76f04b74a76bf41ad11944ac199d98d355b745d69426c8066496

See more details on using hashes here.

File details

Details for the file metrolopy-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: metrolopy-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 208.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for metrolopy-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d8dc88bdd3bd4c8bd9b649a759cf4796b1951de474c137b9239e12887f5abef4
MD5 60938474b44541f5b1b9002134be8111
BLAKE2b-256 ac73f695f60e9e993c23fb69e37a5bd8db0d86d7d58734b3a25d993ee001517b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page