Unit Conversion (cross-cutting/units-atmos/unit-conversion)
Use when the task is converting an aerospace quantity between unit
systems: SI to imperial, imperial to SI, or to the aviation units
pilots and flight manuals use (knots, NM, inHg, Mach).
Domain quick reference
Deterministic factor tables, one canonical base per quantity
(m, m/s, K, Pa, kg/m3, kg, N). Exact where the unit system defines
them; standard reference values otherwise.
- Length (base m): 1 ft = 0.3048 m; 1 NM = 1852 m.
- Speed (base m/s): 1 kt = 1852/3600 = 0.514444 m/s; 1 ft/s = 0.3048
m/s. Mach converts through a speed of sound; the default is the ISA
sea-level value 340.294 m/s, pass the flight-condition value for
altitude-corrected Mach.
- Temperature (base K, offset scales, not factors): K = C + 273.15;
F = K * 9/5 - 459.67; R = K * 9/5. Anchor: 0 C = 273.15 K = 32 F =
491.67 R.
- Pressure (base Pa): 1 hPa = 100 Pa; 1 psi = 6894.757293168 Pa;
1 inHg = 3386.389 Pa. ISA sea level is 101325 Pa = 1013.25 hPa =
29.92 inHg = 14.6959 psi.
- Density (base kg/m3): 1 slug/ft3 = 515.3788184 kg/m3; ISA sea level
is 1.225 kg/m3 = 0.0023769 slug/ft3.
- Mass (base kg): 1 lb = 0.45359237 kg; 1 slug = 14.59390294 kg =
32.1740 lb.
- Force (base N): 1 lbf = 0.45359237 kg * 9.80665 m/s2 =
4.4482216152605 N.
- Altitude conventions: pressure altitude inverts the ISA troposphere
pressure field (what an altimeter set to 1013.25 hPa reads);
geometric altitude converts to geopotential altitude with the
nominal Earth radius 6356766 m: h_gp = h * R / (R + h).
Workflow
- Name the quantity and the two units involved.
- Pick the matching function: convert_length, convert_speed,
convert_temperature, convert_pressure, convert_density,
convert_mass, convert_force.
- Pass value, from_unit, to_unit. Unit tokens are case-insensitive;
"NM", "kts", "kg/m^3" all resolve.
- For Mach, pass the speed of sound at the flight condition, or
accept the ISA sea-level default.
- For altitude, use pressure_altitude_m on a static pressure, or
convert_altitude between geom and geopotential.
- Sanity-check the result against the quick-reference anchors
(e.g. 1013.25 hPa, 1.225 kg/m3, 250 kt about 129 m/s).
Pitfalls
- Treating temperature as a plain factor: 0 C is not 32 F minus an
offset; the code routes every temperature through kelvin.
- Mach without a speed of sound: the default is ISA sea level; at
altitude the speed of sound drops and Mach rises for the same
true airspeed.
- Confusing pressure altitude with geometric altitude, or geometric
with geopotential (the difference is about 19 m at 11 km).
- Confusing slug with lb (factor 32.1740) and NM with statute miles
or km.
- Mixing gauge pressure with absolute pressure; the tables here are
absolute.
- Writing "kph" or "mph": not in the table by design, raises
ValueError, convert via m/s first.
Behavior contract (gate 3)
The conversion logic is exercised by the gate 3 contract test:
scripts/test_unit_conversion.py against
scripts/unit_conversion_logic.py (stdlib unittest, offline). Run:
python3 scripts/test_unit_conversion.py
Compliance
- Standards referenced, not reproduced: NACA TR-824 is public-domain
US government work; this skill uses only its standard-atmosphere
context (sea-level state, speed of sound, pressure altitude) as
common reference data, summary-only per standards-map.yaml.
- compliance: STANDARDS-REF, gated: false.
1---2name: unit-conversion3description: Use when you must convert aerospace quantities between SI and imperial or aviation units: length (m, ft, NM), speed (m/s, kt, ft/s, Mach), temperature (K, C, F, R), pressure (Pa, hPa, psi, inHg), density (kg/m3, slug/ft3), mass (kg, lb, slug), and force (N, lbf). Converts with a deterministic factor table, handles offset temperature scales, computes Mach from true airspeed and speed of sound, and relates pressure altitude to geometric altitude. Trigger: unit conversion, convert units, knots, mach number, temperature conversion, pressure altitude, SI imperial.4license: Apache-2.05---67# Unit Conversion (cross-cutting/units-atmos/unit-conversion)89Use when the task is converting an aerospace quantity between unit10systems: SI to imperial, imperial to SI, or to the aviation units11pilots and flight manuals use (knots, NM, inHg, Mach).1213## Domain quick reference1415Deterministic factor tables, one canonical base per quantity16(m, m/s, K, Pa, kg/m3, kg, N). Exact where the unit system defines17them; standard reference values otherwise.1819- Length (base m): 1 ft = 0.3048 m; 1 NM = 1852 m.20- Speed (base m/s): 1 kt = 1852/3600 = 0.514444 m/s; 1 ft/s = 0.304821 m/s. Mach converts through a speed of sound; the default is the ISA22 sea-level value 340.294 m/s, pass the flight-condition value for23 altitude-corrected Mach.24- Temperature (base K, offset scales, not factors): K = C + 273.15;25 F = K * 9/5 - 459.67; R = K * 9/5. Anchor: 0 C = 273.15 K = 32 F =26 491.67 R.27- Pressure (base Pa): 1 hPa = 100 Pa; 1 psi = 6894.757293168 Pa;28 1 inHg = 3386.389 Pa. ISA sea level is 101325 Pa = 1013.25 hPa =29 29.92 inHg = 14.6959 psi.30- Density (base kg/m3): 1 slug/ft3 = 515.3788184 kg/m3; ISA sea level31 is 1.225 kg/m3 = 0.0023769 slug/ft3.32- Mass (base kg): 1 lb = 0.45359237 kg; 1 slug = 14.59390294 kg =33 32.1740 lb.34- Force (base N): 1 lbf = 0.45359237 kg * 9.80665 m/s2 =35 4.4482216152605 N.36- Altitude conventions: pressure altitude inverts the ISA troposphere37 pressure field (what an altimeter set to 1013.25 hPa reads);38 geometric altitude converts to geopotential altitude with the39 nominal Earth radius 6356766 m: h_gp = h * R / (R + h).4041## Workflow42431. Name the quantity and the two units involved.442. Pick the matching function: convert_length, convert_speed,45 convert_temperature, convert_pressure, convert_density,46 convert_mass, convert_force.473. Pass value, from_unit, to_unit. Unit tokens are case-insensitive;48 "NM", "kts", "kg/m^3" all resolve.494. For Mach, pass the speed of sound at the flight condition, or50 accept the ISA sea-level default.515. For altitude, use pressure_altitude_m on a static pressure, or52 convert_altitude between geom and geopotential.536. Sanity-check the result against the quick-reference anchors54 (e.g. 1013.25 hPa, 1.225 kg/m3, 250 kt about 129 m/s).5556## Pitfalls5758- Treating temperature as a plain factor: 0 C is not 32 F minus an59 offset; the code routes every temperature through kelvin.60- Mach without a speed of sound: the default is ISA sea level; at61 altitude the speed of sound drops and Mach rises for the same62 true airspeed.63- Confusing pressure altitude with geometric altitude, or geometric64 with geopotential (the difference is about 19 m at 11 km).65- Confusing slug with lb (factor 32.1740) and NM with statute miles66 or km.67- Mixing gauge pressure with absolute pressure; the tables here are68 absolute.69- Writing "kph" or "mph": not in the table by design, raises70 ValueError, convert via m/s first.7172## Behavior contract (gate 3)7374The conversion logic is exercised by the gate 3 contract test:75scripts/test_unit_conversion.py against76scripts/unit_conversion_logic.py (stdlib unittest, offline). Run:77python3 scripts/test_unit_conversion.py7879## Compliance8081- Standards referenced, not reproduced: NACA TR-824 is public-domain82 US government work; this skill uses only its standard-atmosphere83 context (sea-level state, speed of sound, pressure altitude) as84 common reference data, summary-only per standards-map.yaml.85- compliance: STANDARDS-REF, gated: false.