| name | units |
| version | 1.0.0 |
| category | engineering |
| description | Unit-safe engineering calculations with provenance tracking, dimensional consistency verification, and unit conversion across SI, inch, and metric systems. |
| type | reference |
| tags | [] |
| scripts_exempt | true |
/units — Engineering Unit Tracking
Unit-safe engineering calculations with provenance tracking across the workspace-hub ecosystem.
Usage
/units [subcommand]
Subcommands
| Subcommand | Description |
|---|
wrap <file> | Analyze a Python file and suggest TrackedQuantity wrapping for raw numerics |
audit <file> | Generate a CalculationAuditLog from an instrumented script |
check <file> | Verify dimensional consistency across a calculation chain |
convert <value> <from> <to> | Quick unit conversion with provenance |
systems | List available unit systems (SI, inch, metric_engineering) |
registry | Show all registered units including custom energy/offshore units |
Quick Reference
Core API (assetutilities.units)
from assetutilities.units import (
TrackedQuantity,
CalculationAuditLog,
UnitMismatchError,
UnitSystemPolicy,
unit_checked,
get_registry,
)
TrackedQuantity
depth = TrackedQuantity(1300.0, "m", source="gulf_of_mexico")
depth_ft = depth.to("ft")
depth.dimensions
depth.is_compatible("ft")
depth.is_compatible("kg")
depth.check_dimensions("[length]")
pressure = rho * g * depth
data = depth.to_dict()
restored = TrackedQuantity.from_dict(data)
OrcaFlex Adapter (rock_oil_field.units.orcaflex_adapter)
from rock_oil_field.units.orcaflex_adapter import (
wrap_orcaflex_value,
unwrap_for_orcaflex,
wrap_model_parameters,
wrap_environment,
ORCAFLEX_UNITS,
)
Instrumented Workflow Pattern
from rock_oil_field.workflows.diffraction import (
setup_environment,
setup_vessel_inertia,
setup_wave_parameters,
run_instrumented_setup,
)
Unit Systems
| System | Length | Stress | Force | Temperature |
|---|
SI | m | Pa | N | degC |
inch | inch | psi | lbf | degF |
metric_engineering | mm | MPa | kN | degC |
OrcaFlex Default Units
| Type | Unit | Type | Unit |
|---|
| length | m | mass | tonne |
| force | kN | stiffness | kN/m |
| moment | kN*m | period | s |
| angle | deg | pressure | kPa |
| velocity | m/s | acceleration | m/s^2 |
| density | tonne/m^3 | | |
Wrapping Raw Parameters
When instrumenting a script with raw numerics:
seabed_depth = 1300
diff.SetData('WaterDepth', 0, seabed_depth)
from rock_oil_field.units.orcaflex_adapter import wrap_orcaflex_value, unwrap_for_orcaflex
seabed_depth = wrap_orcaflex_value(1300.0, "length", source="gulf_of_mexico")
diff.SetData('WaterDepth', 0, unwrap_for_orcaflex(seabed_depth, "length"))
Visualization
from assetutilities.units.visualization import LineageGraph
graph = LineageGraph.from_audit_log(audit)
graph.to_html()
graph.to_svg()
graph.to_dot()
graph.to_dict()
Related
- Full guide:
assetutilities/docs/units-guide.md
- Tests:
assetutilities/tests/units/, client-b/tests/unit/
- S7 reference scripts:
client-b/s7/analysis_general/