cwicr-unit-converter
Convert between construction measurement units. Handle metric/imperial conversion, area/volume calculations, and unit normalization for CWICR data.
git clone --depth 1 https://github.com/datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction /tmp/cwicr-unit-converter && cp -r /tmp/cwicr-unit-converter/1_DDC_Toolkit/CWICR-Database/cwicr-unit-converter ~/.claude/skills/cwicr-unit-converterSKILL.md
# CWICR Unit Converter
## Business Case
### Problem Statement
Construction data comes in various unit systems:
- Metric vs Imperial measurements
- Different unit conventions by trade
- BIM quantities need normalization
- Regional standards differ
### Solution
Comprehensive unit conversion for construction quantities, normalizing data for CWICR integration and analysis.
### Business Value
- **Accuracy** - Eliminate unit conversion errors
- **Consistency** - Standardize across projects
- **Integration** - BIM to cost data alignment
- **Global** - Support international projects
## Technical Implementation
```python
import pandas as pd
import numpy as np
from typing import Dict, Any, List, Optional, Tuple, Union
from dataclasses import dataclass
from enum import Enum
class UnitCategory(Enum):
"""Categories of measurement units."""
LENGTH = "length"
AREA = "area"
VOLUME = "volume"
WEIGHT = "weight"
TIME = "time"
QUANTITY = "quantity"
class UnitSystem(Enum):
"""Unit systems."""
METRIC = "metric"
IMPERIAL = "imperial"
MIXED = "mixed"
@dataclass
class UnitConversion:
"""Unit conversion result."""
original_value: float
original_unit: str
converted_value: float
target_unit: str
conversion_factor: float
category: UnitCategory
# Conversion factors to base units
# Base units: meter (length), m² (area), m³ (volume), kg (weight), hour (time)
CONVERSIONS = {
# Length to meters
'm': {'factor': 1.0, 'category': UnitCategory.LENGTH, 'base': 'm'},
'meter': {'factor': 1.0, 'category': UnitCategory.LENGTH, 'base': 'm'},
'meters': {'factor': 1.0, 'category': UnitCategory.LENGTH, 'base': 'm'},
'cm': {'factor': 0.01, 'category': UnitCategory.LENGTH, 'base': 'm'},
'mm': {'factor': 0.001, 'category': UnitCategory.LENGTH, 'base': 'm'},
'km': {'factor': 1000.0, 'category': UnitCategory.LENGTH, 'base': 'm'},
'ft': {'factor': 0.3048, 'category': UnitCategory.LENGTH, 'base': 'm'},
'feet': {'factor': 0.3048, 'category': UnitCategory.LENGTH, 'base': 'm'},
'foot': {'factor': 0.3048, 'category': UnitCategory.LENGTH, 'base': 'm'},
'in': {'factor': 0.0254, 'category': UnitCategory.LENGTH, 'base': 'm'},
'inch': {'factor': 0.0254, 'category': UnitCategory.LENGTH, 'base': 'm'},
'inches': {'factor': 0.0254, 'category': UnitCategory.LENGTH, 'base': 'm'},
'yd': {'factor': 0.9144, 'category': UnitCategory.LENGTH, 'base': 'm'},
'yard': {'factor': 0.9144, 'category': UnitCategory.LENGTH, 'base': 'm'},
'yards': {'factor': 0.9144, 'category': UnitCategory.LENGTH, 'base': 'm'},
'mi': {'factor': 1609.344, 'category': UnitCategory.LENGTH, 'base': 'm'},
'mile': {'factor': 1609.344, 'category': UnitCategory.LENGTH, 'base': 'm'},
'lf': {'factor': 0.3048, 'category': UnitCategory.LENGTH, 'base': 'm'}, # Linear foot
# Area to m²
'm2': {'factor': 1.0, 'category': UnitCategory.AREA, 'base': 'm2'},
'm²': {'factor': 1.0, 'category': UnitCategory.AREA, 'base': 'm2'},
'sqm': {'factor': 1.0, 'category': UnitCategory.AREA, 'base': 'm2'},
'cm2': {'factor': 0.0001, 'category': UnitCategory.AREA, 'base': 'm2'},
'mm2': {'factor': 0.000001, 'category': UnitCategory.AREA, 'base': 'm2'},
'ha': {'factor': 10000.0, 'category': UnitCategory.AREA, 'base': 'm2'},
'hectare': {'factor': 10000.0, 'category': UnitCategory.AREA, 'base': 'm2'},
'ft2': {'factor': 0.092903, 'category': UnitCategory.AREA, 'base': 'm2'},
'sf': {'factor': 0.092903, 'category': UnitCategory.AREA, 'base': 'm2'},
'sqft': {'factor': 0.092903, 'category': UnitCategory.AREA, 'base': 'm2'},
'yd2': {'factor': 0.836127, 'category': UnitCategory.AREA, 'base': 'm2'},
'sy': {'factor': 0.836127, 'category': UnitCategory.AREA, 'base': 'm2'}, # Square yard
'acre': {'factor': 4046.86, 'category': UnitCategory.AREA, 'base': 'm2'},
# Volume to m³
'm3': {'factor': 1.0, 'category': UnitCategory.VOLUME, 'base': 'm3'},
'm³': {'factor': 1.0, 'category': UnitCategory.VOLUME, 'base': 'm3'},
'cbm': {'factor': 1.0, 'category': UnitCategory.VOLUME, 'base': 'm3'},
'l': {'factor': 0.001, 'category': UnitCategory.VOLUME, 'base': 'm3'},
'liter': {'factor': 0.001, 'category': UnitCategory.VOLUME, 'base': 'm3'},
'litre': {'factor': 0.001, 'category': UnitCategory.VOLUME, 'base': 'm3'},
'ml': {'factor': 0.000001, 'category': UnitCategory.VOLUME, 'base': 'm3'},
'ft3': {'factor': 0.0283168, 'category': UnitCategory.VOLUME, 'base': 'm3'},
'cf': {'factor': 0.0283168, 'category': UnitCategory.VOLUME, 'base': 'm3'},
'cuft': {'factor': 0.0283168, 'category': UnitCategory.VOLUME, 'base': 'm3'},
'yd3': {'factor': 0.764555, 'category': UnitCategory.VOLUME, 'base': 'm3'},
'cy': {'factor': 0.764555, 'category': UnitCategory.VOLUME, 'base': 'm3'}, # Cubic yard
'cuyd': {'factor': 0.764555, 'category': UnitCategory.VOLUME, 'base': 'm3'},
'gal': {'factor': 0.00378541, 'category': UnitCategory.VOLUME, 'base': 'm3'},
'gallon': {'factor': 0.00378541, 'category': UnitCategory.VOLUME, 'base': 'm3'},
# Weight to kg
'kg': {'factor': 1.0, 'category': UnitCategory.WEIGHT, 'base': 'kg'},
'kilogram': {'factor': 1.0, 'category': UnitCategory.WEIGHT, 'base': 'kg'},
'g': {'factor': 0.001, 'category': UnitCategory.WEIGHT, 'base': 'kg'},
'gram': {'factor': 0.001, 'category': UnitCategory.WEIGHT, 'base': 'kg'},
'mg': {'factor': 0.000001, 'category': UnitCategory.WEIGHT, 'base': 'kg'},
't': {'factor': 1000.0, 'category': UnitCategory.WEIGHT, 'base': 'kg'},
'ton': {'factor': 1000.0, 'category': UnitCategory.WEIGHT, 'base': 'kg'}, # Metric ton
'tonne': {'factor': 1000.0, 'category': UnitCategory.WEIGHT, 'base': 'kg'},
'mt': {'factor': 1000.0, 'category': UnitCategory.WEIGHT, 'base': 'kg'},
'lb': {'factor': 0.453592, 'category': UnitCategory.WEIGHT, 'base': 'kg'},
'lbs': {'factor': 0.453592, 'category': UnitCategory.WEIGHT, 'baseGenerate automated daily progress reports from site data. Track work completed, labor hours, equipment usage, and weather conditions.
Analyze labor productivity from site data. Compare planned vs actual, identify trends, benchmark against industry standards.
Create interactive KPI dashboards for construction projects. Track schedule, cost, quality, and safety metrics in real-time.
Detect and analyze geometric clashes in BIM models. Identify MEP, structural, and architectural conflicts before construction.
Classify BIM elements using AI and standard classification systems. Map elements to UniFormat, MasterFormat, OmniClass, and CWICR codes.
Generate comprehensive BIM model validation reports. Check data quality, completeness, and compliance with standards.
Calculate CO2 emissions and carbon footprint from BIM model data. Analyze embodied carbon by material, element, and building system.
Extract quantities from IFC/Revit models for quantity takeoff. Uses DDC converters to get element counts, areas, volumes, lengths with grouping and reporting.