一键导入
units
Unit-safe engineering calculations with provenance tracking, dimensional consistency verification, and unit conversion across SI, inch, and metric systems.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Unit-safe engineering calculations with provenance tracking, dimensional consistency verification, and unit conversion across SI, inch, and metric systems.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Conventions for creating consistent Mermaid diagrams including decision node layout, edge ordering, and flowchart direction rules.
Generate interactive validation reports with quality scoring, missing data analysis, and type checking. Combines Pandas validation, Plotly visualization, and YAML configuration for comprehensive data quality reporting.
Class-level Hermes local configuration and setup workflows, including config audit gotchas and Windows installation.
Guide AI model selection based on task complexity, cost constraints, and latency requirements
Sub-skill of modular-architecture-documentation: 1. Module Definition Framework (+9).
Sub-skill of modular-architecture-documentation: Overview (+6).
| 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 |
Unit-safe engineering calculations with provenance tracking across the workspace-hub ecosystem.
/units [subcommand]
| 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 |
from assetutilities.units import (
TrackedQuantity, # Unit-tracked value with provenance
CalculationAuditLog, # Aggregate audit trail
UnitMismatchError, # Dimension mismatch exception
UnitSystemPolicy, # Project-wide unit enforcement
unit_checked, # Decorator for function-level validation
get_registry, # Singleton pint UnitRegistry
)
# Create with source provenance
depth = TrackedQuantity(1300.0, "m", source="gulf_of_mexico")
# Convert (provenance recorded automatically)
depth_ft = depth.to("ft")
# Dimension analysis
depth.dimensions # "[length]"
depth.is_compatible("ft") # True
depth.is_compatible("kg") # False
depth.check_dimensions("[length]") # passes or raises ValueError
# Arithmetic (provenance merged from operands)
pressure = rho * g * depth # compound units handled by pint
# Serialize
data = depth.to_dict()
restored = TrackedQuantity.from_dict(data)
from rock_oil_field.units.orcaflex_adapter import (
wrap_orcaflex_value, # Single value → TrackedQuantity
unwrap_for_orcaflex, # TrackedQuantity → raw float (converts to OrcaFlex units)
wrap_model_parameters, # Dict of (value, type) → TrackedQuantity dict
wrap_environment, # Config dict → TrackedQuantity dict with unit inference
ORCAFLEX_UNITS, # Default unit mapping per parameter type
)
from rock_oil_field.workflows.diffraction import (
setup_environment, # Water depth, mesh positions
setup_vessel_inertia, # Mass, CoG, inertia tensor, draught
setup_wave_parameters, # Headings, periods
run_instrumented_setup, # Full workflow → CalculationAuditLog
)
| System | Length | Stress | Force | Temperature |
|---|---|---|---|---|
SI | m | Pa | N | degC |
inch | inch | psi | lbf | degF |
metric_engineering | mm | MPa | kN | degC |
| 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 |
When instrumenting a script with raw numerics:
# BEFORE (raw — no unit safety)
seabed_depth = 1300
diff.SetData('WaterDepth', 0, seabed_depth)
# AFTER (tracked — full provenance)
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"))
from assetutilities.units.visualization import LineageGraph
graph = LineageGraph.from_audit_log(audit)
graph.to_html() # Standalone HTML (no dependencies)
graph.to_svg() # SVG via graphviz (optional)
graph.to_dot() # Graphviz DOT text
graph.to_dict() # JSON-serializable dict
assetutilities/docs/units-guide.mdassetutilities/tests/units/, client-b/tests/unit/client-b/s7/analysis_general/