pub fn pressure_altitude_m(station_pressure_hpa: f64) -> f64Expand description
The pressure altitude of a station pressure, m, wherever it lands: the NWS formula
(nws_pressure_altitude_ft in metres, to the bit) inside -5 km to 11 km, where it is the
published figure, and outside that band the standard atmosphere’s own (geopotential)
altitude of the pressure, walking the same ICAO layers air_at walks: the troposphere’s
lapse below -5 km, isothermal from 11 km, warming from 20 km and 32 km, isothermal again
from 47 km, cooling from 51 km and 71 km, the last layer’s lapse continuing above 84 km.
Each layer’s base pressure is chained from 101325 Pa by the layer formula, so standard
pressure at any height reads that height.
Every pressure above 0 has a finite pressure altitude, below 178.3 km (where the last layer’s lapse reaches 0 K). At the band’s edges the two differ by the few metres the NWS constants and the ICAO troposphere part by: the NWS formula reads 22615.3 Pa as 11000 m and the standard atmosphere reads it as 11005 m, so the figure steps up by 5 m there as the pressure falls, and at the bottom edge (177725 Pa) it steps down by 2 m as the pressure rises. It never falls as the pressure falls. A NaN pressure gives NaN.
use ballistics_engine::atmosphere::{nws_pressure_altitude_ft, pressure_altitude_m};
// Inside the band, the NWS formula to the bit.
assert_eq!(pressure_altitude_m(850.0).to_bits(), (nws_pressure_altitude_ft(850.0) * 0.3048).to_bits());
// Standard pressure at 20 km reads 20 km.
assert!((pressure_altitude_m(54.7489) - 20_000.0).abs() < 1.0);
// A near vacuum still has an altitude.
assert!(pressure_altitude_m(0.01).is_finite());