Quantity-Value supports calculations with physical quantities
Project description
This package provides Python support for physical quantities used in mathematical equations.
Python objects called quantity-values are used to associate a measured value with a unit of measurement. Calculations involving these objects follow the rules of quantity calculus.
The package can be used to define the quantities, and associated units of measurement, of interest in a specific problem. In that way the context in which quantity calculations are performed is well defined.
Example
Calculations involving electrical measurements can be described in terms of a simple set of base quantities, here we declare current and voltage and the dependent quantity resistance
>>> from QV import *
>>> context = Context( ("Current","I"),("Voltage","V") )
>>> Resistance = context.declare('Resistance','R','Voltage/Current')
Units can be declared in terms of these quantities
>>> ureg = UnitRegister("ureg",context)
>>>
>>> volt = ureg.unit( RatioScale(context['Voltage'],'volt','V') )
>>> amp = ureg.unit( RatioScale(context['Current'],'amp','A') )
>>> milliamp = ureg.unit( prefix.milli(amp) )
>>> ohm = ureg.unit( RatioScale(context['Resistance'],'Ohm','Ohm') )
and then quantity-values can be created and manipulated
>>> v1 = qvalue(0.10,volt)
>>> i1 = qvalue(15,milliamp)
>>> print( qresult( v1/i1 ) )
6.6666666666... Ohm
Status
The Quantity-Value package is part of a research project at the Measurement Standards Laboratory of New Zealand looking at issues in Digital Metrology.
Quantity-Value is intended as an exemplar for software that supports the concept of a physical quantity and physical quantity calculations.
The project is on-going and should not yet be considered stable. There may be substantial changes in later versions.
Documentation
The documentation for Quantity-Value can be found here.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for Quantity_Value-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6c49e2ecd191e3350522b2f6920d04500f47431a5ddff9c2b989adb0b8e5ed1 |
|
MD5 | 46e0bac914c0a6ae3fee25e0658bd730 |
|
BLAKE2b-256 | 7c3d2cad5bed740a77ad78d143acea3f2b76529d22b3b0162de8be4219dc3fe2 |