Skip to main content

Crate standard_atmosphere

Crate standard_atmosphere 

Source
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).