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.3

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.3
File Size Uploaded
dsiunits-3.1.3.tar.gz 56.3 kB Details

Built distribution (wheel)

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

Total release size: 101.0 kB

Release files / dsiunits-3.1.3.tar.gz

Download URL dsiunits-3.1.3.tar.gz
Size 56.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b2209bdf14d5abd2c1a033d34e199b4375fe1245602f65306531bcf72040c666
BLAKE2b-256 checksum
How to use checksums
4ee73e7d3e34d1dda1d604226087b0cd9b2bd9629806b081b53f3a19fce0a2d2
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.3-py3-none-any.whl

Download URL dsiunits-3.1.3-py3-none-any.whl
Size 44.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
31cadef5f2541e4448c3188e48ed287fa4cf80964ec13cfd814121413c118f7a
BLAKE2b-256 checksum
How to use checksums
340f0f112a10e55f0b81ae3bdb4ae1cc2d70004a48979c8c40f34539928a3077
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

This release

3.1.3 This release

2 release files

3.1.2

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