Skip to main content

D-SI Units

A Python library for parsing, validating, and performing mathematical operations on SI units using the D-SI (Digital SI) and BIPM-RP (SI Reference Point) syntax.

The library allows:

  • Unit Parsing & Validation: Parse units from D-SI and BIPM-RP notation strings
  • Mathematical Operations: Perform multiplication, division, and power operations on units while preserving dimensional consistency
  • Multiple Output Formats: Convert units to LaTeX, UTF-8, and SIRP representations
  • Scale Factor Calculations: Calculate conversion factors between compatible units
  • Base Unit Conversions: Convert complex units to their base SI unit representation

The Javascript version of this library has moved to https://gitlab1.ptb.de/digitaldynamicmeasurement/dsiunits-js/

Installation

pip install dsiUnits

Requirements: Python 3.9+

Quick Start

from dsi_unit import DsiUnit

# Create units from D-SI notation
meter = DsiUnit(r"\metre")
second = DsiUnit(r"\second")
kilogram = DsiUnit(r"\kilogram")

# Or from BIPM-RP notation
velocity = DsiUnit("m.s-1")  # meters per second

Usage Examples

Basic Unit Operations

from dsi_unit import DsiUnit

# Mathematical operations
velocity = DsiUnit(r"\metre") / DsiUnit(r"\second")
print(velocity)  # \metre\per\second

acceleration = velocity / DsiUnit(r"\second")
print(acceleration)  # \metre\per\second\tothe{2}

force = DsiUnit(r"\kilogram") * acceleration
print(force)  # \kilogram\metre\per\second\tothe{2}

# Power operations
area = DsiUnit(r"\metre") ** 2
print(area)  # \metre\tothe{2}

Unit Conversions

# Check if units are scalable (convertible)
joule = DsiUnit(r"\joule")
watt_second = DsiUnit(r"\watt") * DsiUnit(r"\second")
print(joule.is_scalable(watt_second))  # True

# Get scale factor between compatible units
km = DsiUnit(r"\kilo\metre")
m = DsiUnit(r"\metre")
scale = km.get_scale_factor(m)  # 0.001 (1 km = 1000 m, so 1 km * 0.001 = 1 m)

# Convert to base units
newton = DsiUnit(r"\newton")
base = newton.to_base_unit_tree()
print(base)  # \kilogram\metre\per\second\tothe{2}

Output Formats

unit = DsiUnit(r"\kilo\metre\tothe{2}\per\second")

# LaTeX representation
print(unit.to_latex())  # $$\frac{\mathrm{k}\mathrm{m}^{2}}{\mathrm{s}}$$

# UTF-8 representation
print(unit.to_utf8())  # km²/s

# SIRP (SI Reference Point) representation
print(unit.to_sirp())  # km2.s-1

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

Metadata

Release files for dsiUnits 3.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dsiUnits 3.1.2
File Size Uploaded
dsiunits-3.1.2.tar.gz 56.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dsiUnits 3.1.2
File Interpreter ABI Platform
dsiunits-3.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 100.7 kB

Release files / dsiunits-3.1.2.tar.gz

Download URL dsiunits-3.1.2.tar.gz
Size 56.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0ead5ce915fc96950fd2920d84b6bddb752d63a64e9c9dd458487e97e739f3ab
BLAKE2b-256 checksum
How to use checksums
027f9abe4ef284998330cb97d3ac70d5f1cc5bae9d1531240a054ad95f97c30b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / dsiunits-3.1.2-py3-none-any.whl

Download URL dsiunits-3.1.2-py3-none-any.whl
Size 44.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5ccd2debc64c224b951f186f16ec294aa464ec263a55594a75852189097c6a67
BLAKE2b-256 checksum
How to use checksums
9a02cba60ea61c65cb37d11d8595fa3605f8f4da7f999f4e198caedf93784ed3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release history Release notifications | RSS feed

3.1.3

2 release files

This release

3.1.2 This release

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.5.2

2 release files

2.5.1

2 release files

2.4.2

1 release file

2.4.1

2 release files

2.4.0

2 release files

2.3.2

2 release files

2.3.1

2 release files

2.3.0

2 release files

2.2.3

2 release files

2.2.2

2 release files

2.2.1

2 release files

2.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page