Skip to main content

Real and complex physical quantities with units with numpy support.

Project description

scuq

This is scuq. Scuq provides scalar (real) and complex physical quantities with units.

This software is distributed unter GPL-3 or higher. See LICENSE for details.

Installation

pip3 install scuq

Command line

The package installs a small diagnostic command:

scuq-info

It prints the installed scuq version, Python and NumPy versions, the package path, the current strict-mode setting, and a few quick smoke-check results. Use scuq-info --json for machine-readable output.

Quick examples

Create quantities and combine them in calculations:

from scuq.quantities import Quantity
from scuq.si import AMPERE, METER, SECOND, VOLT

voltage = Quantity(VOLT, 12.0)
current = Quantity(AMPERE, 0.25)
resistance = voltage / current

speed = Quantity(METER, 10.0) / Quantity(SECOND, 2.0)

print(resistance)  # 48.0 V*A^(-1)
print(speed)       # 5.0 m*s^(-1)

Use compatible units with automatic conversion by disabling strict mode:

from scuq.quantities import Quantity, set_strict
from scuq.si import VOLT
from scuq.units import AlternateUnit

mV = AlternateUnit("mV", VOLT / 1000)

set_strict(False)
signal = Quantity(VOLT, 2.0) + Quantity(mV, 500.0)

print(signal)                 # 2.5 V
print(signal.get_value(mV))   # 2500.0

Propagate uncertainties through a measurement model:

from scuq.quantities import Quantity
from scuq.si import METER
from scuq.ucomponents import Context, UncertainInput

length = Quantity(METER, UncertainInput(2.0, 0.02))
width = Quantity(METER, UncertainInput(3.0, 0.03))

area = length * width
area_uncertainty = Context().uncertainty(area)

print(area)              # 6.0 +/- 0.08485281374238571 [NC] m^(2)
print(area_uncertainty)  # 0.08485281374238571 m^(2)

[NC] means "no context" in the string representation. It appears when an uncertain expression is printed without an assigned uncertainty Context; the explicit Context().uncertainty(...) call uses the provided context and does not include this marker.

License

GPL-3 or higher

Repository

https://gitlab.hrz.tu-chemnitz.de/chair-of-electromagnetic-theory-and-compatibility-at-tu-dresden/mpylab/scuq.git

The documentation is also available from the gitlab server of TU Chemnitz:

https://scuq-b5d96a.gp.hrz.tu-chemnitz.de/

Contact

Prof. Dr. Hans Georg Krauthäuser (hgk@ieee.org)
Chair for Electromagnetic Theory and Compatibility
Technische Universität Dresden, Dresden, Germany

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

scuq-1.0.6.tar.gz (103.4 kB view details)

Uploaded Source

Built Distribution

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

scuq-1.0.6-py3-none-any.whl (85.4 kB view details)

Uploaded Python 3

File details

Details for the file scuq-1.0.6.tar.gz.

File metadata

  • Download URL: scuq-1.0.6.tar.gz
  • Upload date:
  • Size: 103.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for scuq-1.0.6.tar.gz
Algorithm Hash digest
SHA256 cf1f5c21e5861f7483e24f23435692a909f05b32bc0c085985d3c4a0c658b567
MD5 0401393e6f60d1e5a7678fd740d56388
BLAKE2b-256 be14730fb56c8d3f54f3358e015f428d4077afaed266dae2157d4d90a3d1e0f2

See more details on using hashes here.

File details

Details for the file scuq-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: scuq-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 85.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for scuq-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9af0463518bddab98f311df16012f6d452006e362448142a6187668a880eba07
MD5 3741d1b78c9449c949cd2446fe8826ec
BLAKE2b-256 91e0c3c817f6a3502d4895c4820cc4298e7e9de60c868bc6607b48e4808c8e3f

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