Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Atmosphere

Learn how HPR Sim builds the air at each height from a standard atmosphere, field conditions or a sounding, and what an altimeter reads.

In short

  • What it models: the air’s temperature, pressure, density, speed of sound and viscosity by height. It covers the 1976 U.S. Standard Atmosphere, optionally shifted to field conditions, humid air, and weather-balloon soundings or forecasts. It also gives the pressure altitude a barometric altimeter reads.
  • Sources: the U.S. Standard Atmosphere, 1976; the WMO’s Guide to Instruments and Methods of Observation (WMO-No. 8, 2023); the CIPM-2007 moist-air density formula (Picard et al., 2008).
  • How well it is validated: every value within 0.1% of the 1976 tables at 32 altitudes from −2 to 86 km (−1.2 to 53 mi). Humid density is within 0.047% of CIPM-2007 over 15–27 °C. Against RocketPy, its density agrees within 3.7e-4 over the 23 heights its parachute descents sample (Recovery). Its pressure altitude matches two flight logs’ own altimeter readings of their pressure, to 0.195 m (0.64 ft) and 1.321 m (4.33 ft) (report). The air itself has no real-flight check.
  • What it leaves out: a real day’s changes aloft. A field-condition offset holds all the way up, so higher flights need a sounding. An offset of +20 K at a 1,400 m (4,593 ft) field puts density +30% off the standard’s at 30 km (19 mi). Viscosity ignores humidity, which lowers it 2.1% at 30 °C and saturation.

Code and sources

Code: hpr_atmos::ussa76 (the standard and its offsets), hpr_atmos::moist (humid air), hpr_atmos::profile (soundings and forecasts), and the Atmosphere trait in hpr_atmos::air.

Sources:

  • [USSA] U.S. Standard Atmosphere, 1976, NOAA-S/T 76-1562, part 1, pinned as us-std-atmosphere-1976. Equation, table and page numbers below are its own.
  • [WMO] WMO-No. 8, Guide to Instruments and Methods of Observation, Vol. I (2023), wmo-no8-vol1-2023.
  • [CIPM] A. Picard et al., “Revised formula for the density of moist air (CIPM-2007)”, Metrologia 45 (2008) 149–155, picard-2008-cipm-2007.

The standard atmosphere

The height datum, the 1976 standard, offsets for a site’s conditions, and pressure altitude.

Height datum

Every atmosphere is queried with geometric height above mean sea level (height_msl_m). The core’s heights are ellipsoidal (Frames), so the flight engine subtracts the geoid undulation first: Hmsl=h−N. Samples carry an extrapolated flag, set whenever a model answers outside the range it is defined or tabulated over.

The 1976 standard, −5 km (−3.1 mi) to 86 km (53 mi)

Seven layers in geopotential altitude H, the last ending at 84.852 geopotential km (52.72 mi), each with a constant gradient of the molecular-scale temperature TM ([USSA] Table 4):

base Hb (km′)LM,b gradient (K/km′)
0−6.5
110
20+1.0
32+2.8
470
51−2.8
71−2.0

Eq. (18) gives the geopotential altitude H from the geometric altitude Z, with r0 the Earth’s effective radius (below). Eq. (23) gives the temperature from the layer’s base values Hb and TM,b:

H=r0Zr0+Z,TM=TM,b+LM,b(H−Hb)

Pressure follows eq. (33a) where LM,b≠0 and eq. (33b) where LM,b=0, with the exponent n=g0′M0/(R∗LM,b):

P=Pb(TM,bTM)n,P=Pbexp(−g0′M0(H−Hb)R∗TM,b)

Then eqs. (42), (22), (50), (51) and (52):

ρ=PM0R∗TM,T=TMMM0,a=(γR∗TMM0)1/2,μ=βT3/2T+S,ν=μ/ρ
  • The constants:
    • R∗ is 8314.32J/(kmol⋅K) (p. 3), not CODATA’s 8314.46. Table 2 misprints the exponent’s sign.
    • M0=28.9644kg/kmol, g0=g0′=9.80665, r0=6356766m.
    • P0=101325Pa, T0=288.15K, γ=1.40, β=1.458×10−6.
    • S=110.4K (p. 19). Table 2 and p. 4 print 110 K, but the tables use 110.4 K: sea-level μ is 1.7894e-5 Pa·s with it and 1.7912e-5 with 110.
  • From 80 to 86 km (50 to 53 mi), M/M0 comes from Table 8, interpolated linearly in Z. The printed tables leave it out below 86 km (53 mi) and print T=TM (p. 9). This model follows the equations, so its kinetic temperature there is up to 0.036%, and its viscosity up to 0.031%, below the print.
  • Below −5 km (−3.1 mi) the first layer continues. Above 86 km (53 mi) the atmosphere is isothermal at 186.87 K. Both are flagged. The real standard is also isothermal from 86 to 91 km (53 to 57 mi), then warms. Its composition changes above 86 km (53 mi). Pressure and density there are rough, but tiny.
  • Loft got this wrong (Loft lessons L2 to L4):
    • It fed geometric altitude to geopotential formulas. At 11 km (6.8 mi) it gave 216.65 K and 22 632 Pa, against 216.774 K and 22 699.96 Pa.
    • It had only four layers, so at 70 km (43 mi) it gave 335 K against 219.6 K.
    • Its Sutherland constants gave a sea-level viscosity 1.3% high.

Offsets and launch-site conditions

Ussa76::with_offset(ΔT, P₀) adds ΔT to TM at every geopotential height and integrates eqs. 33a/33b from P0, so the atmosphere stays hydrostatic. Ussa76::anchored(Z, T, P) picks ΔT and P0 so the profile passes through a measured temperature and pressure, such as field conditions.

This is not the aviation convention (ESDU 77022), which offsets temperature at equal pressure altitude. Both are hydrostatic, but they differ aloft. At H=3000m′ with ΔT=+20K, the aviation convention gives 289.95 K where this gives 288.65 K, and densities 0.38% apart (validation/oracles/atmosphere/conventions.py). This choice keeps the lapse rate attached to height, like a sounding; see the atmosphere decision.

An anchor’s offset holds all the way up, which a real hot or cold day doesn’t. Anchoring +20 K at a 1,400 m (4,593 ft) field, at the standard’s pressure there, gives these densities against the standard (conventions.py):

heightdensity against the standard
3 km (1.9 mi)−5.7%
20 km (12 mi)+14%
30 km (19 mi)+30%

Field conditions suit flights of a few kilometers; higher flights need a sounding.

Pressure altitude: what a barometric altimeter reads

A barometric altimeter measures pressure, not height. It turns the pressure into the height at which the 1976 standard has that pressure, its pressure altitude, and subtracts the pad’s. Ussa76::pressure_altitude_m(P) computes the same number, so HPR Sim can read its own flight the way a logged flight was read (Accuracy: real flights).

It inverts eqs. 33a and 33b in the layer whose base pressures bracket P. The first line below is for LM,b≠0, the second for LM,b=0, and n is the exponent above:

H=Hb+TM,bLM,b×[(PPb)−1/n−1],H=Hb−R∗TM,bg0′M0lnPPb

In the standard’s troposphere this is the altimeter formula

H=44330.8m×[1−(P101325Pa)0.190263].

The result is in geopotential meters, m′, as an altimeter’s is.

A worked example. An altimeter on a pad at 86,000 Pa reads 1,361.8 m (4,468 ft)′ there. At 58,000 Pa it reads 4,464.4 m (14,647 ft)′, so it logs a climb of 3,102.6 m (10,179 ft)′. Now make the day 20 K warmer than the standard all the way up, with the same sea-level pressure. The same two pressures then lie 3,318.0 m (10,886 ft)′ apart. The rocket climbed 6.9% more than its altimeter says, and the altimeter reads 6.5% less than the climb. Warm air is less dense, so pressure falls more slowly with height. In the troposphere, with the sea-level pressure unchanged, the ratio is exactly (T0+ΔT)/T0=308.15/288.15.

Where it is used. The simulator’s flights don’t use it: they fly in the air of the day. The real-flight comparison reads the simulator’s height through it when the log is barometric (hpr_validate::real_flight::Barometer). It takes the ERA5 pressure at the center of mass. Two logs record their pressure, Prometheus’s and Juno III’s. Over the rows compared, their height column is this reading less the first row’s, to 0.195 m (0.64 ft) and 1.321 m (4.33 ft) (report).

Moist air and weather

Humid air, and profiles built from a sounding or a forecast.

Moist air

An ideal mixture of dry air (M0, γ=1.4) and water vapor (Mv=18.01528kg/kmol, [CIPM] §2.1). The first line is [WMO] Annex 4.B, eq. 4.B.1, in hPa with t in °C. The density’s second form is [WMO] eq. 12.18:

ew(t)=6.112exp(17.62t243.12+t),e=Uew(T),xv=e/p,ρ=p[(1−xv)M0+xvMv]R∗T=pRdTv,Cp=(1−xv)72R∗+xv⋅4R∗,γ=CpCp−R∗,a=(γR∗TM)1/2
  • Relative humidity is taken with respect to liquid water at every temperature, as radiosondes report it ([WMO] §12.1.2). No enhancement factor is applied. Near the surface it would raise e by about 0.47%. That changes density by at most 0.013% (at 40 °C and saturation), and less in cooler or drier air.
  • The moist-air model’s accuracy:
    • Density agrees with CIPM-2007 (a real-gas equation) to 0.047% over its range: 15–27 °C, 600–1,100 hPa, dry to saturated. Ignoring humidity entirely is 0.4% off at 20 °C and 50% RH.
    • Water vapor’s Cp is taken as 4R∗, and its real value near 300 K is about 1% higher. That moves a by 0.009% at 30 °C and saturation.
    • Viscosity stays dry air’s Sutherland value. By Wilke’s rule with IAPWS R12-08 vapor viscosity, saturation at 30 °C lowers it 2.1%, which moves turbulent skin friction about 0.4%.
    • All these numbers come from validation/oracles/atmosphere/moist_air.py.

Sounding and forecast profiles

SoundingProfile takes the site’s latitude and levels of geometric height, temperature, optional pressure, optional relative humidity, and optional wind speed and direction. Humidity and wind are given on every level or on none. A given pressure must be below the level beneath it, which catches hPa entered as Pa.

  • The profile works in WMO geopotential height Z(z,φ) ([WMO] eqs. 12.15–12.16). Its gravity is the normal gravity at the site’s latitude.
    • Surface gravity runs from 9.780 m/s² at the equator to 9.832 m/s² at the poles, ±0.27% around the standard’s g0.
    • Over 2 km (1.2 mi) at 293 K the same sounding’s pressure falls 0.12% more at the pole than at the equator.
    • A latitude-free geopotential would leave errors of that size.
  • Between levels, interpolation runs in Z:
    • T and U are linear in Z.

    • Pressure uses

      lnP=lnPi+lnPi+1Pi⋅ln(T/Ti)ln(Ti+1/Ti),

      which is exact for a dry hydrostatic layer with T linear in Z and passes through both levels’ pressures.

    • Levels sampled from the standard at its geopotential levels reproduce it between them to 1e-12, at any latitude.

  • Missing pressures above the lowest level are filled hydrostatically, with virtual temperature linear in Z ([WMO] eqs. 12.17–12.18).
    • A dry fill agrees with direct integration under WGS 84 normal gravity to 2e-8. The limit is WMO’s rounded surface gravity constants, 3–5e-8 low.
    • A humid fill agrees to 1.1e-5, because vapor pressure is exponential in T and so not quite linear across the layer.
  • Beyond the levels, the profile continues as the standard atmosphere anchored at the end level, and flags the sample. It evaluates the standard at the same geopotential, so still with the local gravity.
    • Below, it holds relative humidity.
    • Above, it holds the vapor mole fraction, capped at saturation, so a humid top doesn’t carry water into the cold stratosphere.
    • The continued pressure is the dry standard’s. It is hydrostatic for dry air. In humid air it falls up to xv(1−Mv/M0) faster (1.6% of the gradient at 30 °C and saturation).
  • Soundings (Wyoming’s HGHT) and forecasts (Open-Meteo’s geopotential_height) report geopotential meters above sea level. Convert them with geometric_from_wmo_geopotential_m. At 30 km (19 mi) that is 29.932 km (18.60 mi) of geopotential at 80° N and 29.7785 km (18.504 mi) at the equator. The standard’s latitude-free r0 formula is only for the standard itself.
  • From an ERA5 file, hpr_io::era5 builds this profile over a launch site at launch time from the day’s reanalysis; see ERA5 weather files.
  • From Open-Meteo, hpr_net::open_meteo builds it from a forecast, or an archived one, on pressure levels; see Launch-day weather.
  • From a weather balloon, hpr_net::wyoming builds it from a radiosonde’s sounding in the University of Wyoming’s archive; see Weather-balloon soundings.
  • Loft’s “today’s conditions” kept the standard lapse from the field up, ignored humidity and never used sounding temperatures (Loft lesson L5).

Comparison and tests

Notes on RocketPy’s atmosphere for the code-to-code comparison, and the tests that pin this one.

RocketPy 1.13.0, for the code-to-code comparison

These are findings from reading refs/rocketpy for the RocketPy comparison of the validation milestone, not yet pinned by fixtures:

  • Its standard atmosphere has ISO 2533 layers from −2 to 80 km (−1.2 to 50 mi), with R=287.05287 (the same as R∗/M0). Temperature is linear in geometric height between converted layer boundaries. Pressure is sampled at 100 points and splined.
  • In its custom profiles:
    • Every quantity, pressure included, is linear in height above sea level, with constant extrapolation.
    • Linear pressure is off hydrostatic by up to 0.06% between 1,000 and 925 hPa, and 1.15% between 700 and 500 hPa (conventions.py). Between 50 and 30 hPa it is up to 3.4% off (conventions.py).
    • Those comparisons need a RocketPy-compatible option or levels dense enough that this doesn’t matter.
  • Humidity is not used anywhere.
  • Wyoming heights are converted from geopotential with a radius only (no latitude).
    • The helper’s default radius, 63,781,370 m (39,632 mi) in rocketpy/tools.py:972, is ten times the Earth’s.
    • Check which callers rely on that default before those comparisons.

Tests that pin this

  • ussa76::tests::matches_the_1976_tables_at_32_altitudes is the done when of the atmosphere and wind milestone:
    • It covers T, TM, H, P, ρ, a, μ and ν at 32 altitudes from −2 to 86 km (−1.2 to 53 mi).
    • Every value is within 0.1%, and within one count of its last printed digit.
    • The exceptions to the last-digit match are those above (80–85.5 km (50–53 mi), where the printed T equals TM). The 84 km (52 mi) density is another. It prints 9.6940E-6 where the equations give 9.69387e-6; the row’s own ρ/ρ0 agrees with the equations.
    • The fixture was transcribed from the page images and cross-checked by validation/oracles/ussa76/tables.py against mpmath and ambiance.
  • The Loft lessons:
  • For pressure altitude:
    • pressure_altitude_inverts_the_1976_tables: each printed pressure’s altitude is the printed geopotential altitude at all 32 rows, to what the prints resolve.
    • pressure_altitude_is_the_altimeter_formula_in_the_troposphere, and its refusals.
    • pressure_altitude_inverts_the_pressure: a property test over offsets and heights, the extrapolated layers included.
  • For the constants and the structure:
    • constants_match_the_transcription checks the constants and Tables 4 and 8.
    • Hydrostatic balance dP/dZ=−ρg is checked in every layer, and as a property test over offsets.
    • Anchors reproduce their conditions, and layers join continuously.
  • moist::tests:
    • WMO 4.B.1 against the formula evaluated separately in mpmath (WMO prints no table of it).
    • Dry air equals the standard.
    • CIPM-2007 density to 0.05% at 36 points.
  • profile::tests:
    • Standard levels are reproduced at 0°, 45° and 80°.
    • Dry fills at 0°, 33° and 90°, and a humid fill, match direct integration under WGS 84 normal gravity.
    • Pressure falls faster at the pole.
    • The continuation beyond the levels is hydrostatic when dry, with the humid shortfall pinned.
    • WMO geopotential values.
    • Errors (including rising pressures) and serde.
FusionSpace HPRVersion 0.1.0Issued 2026-11-21In preparationAbout HPR Sim