Expand description
§standard-atmosphere
The International Standard Atmosphere (ISA / U.S. Standard Atmosphere 1976), with the vertical-coordinate conversions weather and aviation tooling actually needs: pressure to altitude, and flight level to pressure.
§Flight levels and pressure levels are the same axis
Gridded weather lives on pressure levels (500 hPa, 300 hPa, 250 hPa). Aviation lives on flight levels (FL300, FL350). A flight level is the altitude an altimeter reads with the standard subscale set to 1013.25 hPa, and an altimeter reports the ISA pressure-altitude of the ambient static pressure. So an aircraft holding FL300 is sitting wherever the ambient pressure equals the ISA pressure for 30,000 ft, about 300.9 hPa. A flight level is therefore, to a very good approximation, a real isobaric surface: converting a flight level to a pressure level to sample a weather grid is not an approximation, it is physically what the aircraft is doing.
use standard_atmosphere as isa;
// FL300 is the ~301 hPa surface.
let p = isa::pressure_hpa_from_flight_level(300.0);
assert!((p - 300.9).abs() < 0.5);
// ...and back.
let fl = isa::flight_level_from_pressure_hpa(300.9);
assert!((fl - 300.0).abs() < 0.5);§Model
The atmosphere is the standard’s stack of layers, each with a constant temperature lapse rate, integrated hydrostatically, from sea level to 71 km geopotential. That span covers all aviation and tropospheric/stratospheric meteorology. The piecewise structure matters: a single tropospheric formula used above the 11 km tropopause (about FL360) is wrong, which is the classic bug this crate avoids.
Heights are geopotential metres internally, the coordinate the standard is defined in.
geometric_from_geopotential and geopotential_from_geometric convert to and from
true geometric altitude when you need it; the difference is about 0.3% at 20 km.
Units are explicit in every function name: _pa pascals, _hpa hectopascals
(millibars), _m metres, _ft feet, _k kelvin. SI is the core; the hPa and
flight-level helpers wrap it. No dependencies, no unsafe.
Constants§
- EARTH_
RADIUS_ M - Effective Earth radius for the geopotential/geometric conversion (m), per the standard.
- G0
- Standard gravitational acceleration (m/s^2).
- GMR
- Hydrostatic constant
G0 * M_AIR / R_STAR(“GMR”), in K/m. - M_AIR
- Molar mass of dry air (kg/mol), per the 1976 standard.
- P0_PA
- Sea-level standard pressure (Pa).
- R_AIR
- Specific gas constant for dry air,
R_STAR / M_AIR(J/(kg*K)). - R_STAR
- Universal gas constant used by the 1976 standard (J/(mol*K)).
- T0_K
- Sea-level standard temperature (K).
Functions§
- density_
kg_ m3_ from_ geopotential_ m - Air density at a geopotential altitude (kg/m^3), from the ideal gas law.
- flight_
level_ from_ pressure_ hpa - Flight level (hundreds of feet) for a given pressure (hPa). Inverse of
pressure_hpa_from_flight_level. - geometric_
from_ geopotential - Convert geopotential altitude to geometric altitude (true height above sea level).
- geopotential_
from_ geometric - Convert geometric altitude (true height above sea level) to geopotential altitude.
- geopotential_
m_ from_ pressure_ pa - Geopotential altitude (metres) for a given pressure (pascals). Inverse of
pressure_pa_from_geopotential_m. - pressure_
altitude_ ft_ from_ pressure_ hpa - Pressure-altitude in feet for a given pressure (hPa): the value an altimeter set to the standard 1013.25 hPa would display.
- pressure_
hpa_ from_ flight_ level - Pressure (hPa) at a pressure-altitude given as a flight level (hundreds of feet).
- pressure_
hpa_ from_ geopotential_ m - Pressure at a geopotential altitude (hectopascals / millibars).
- pressure_
pa_ from_ geopotential_ m - Pressure at a geopotential altitude (pascals).
- temperature_
k_ from_ geopotential_ m - Temperature at a geopotential altitude (kelvin).