Skip to main content

Module open_meteo

Module open_meteo 

Source
Expand description

Weather from Open-Meteo: a launch site’s forecast (or a past day’s archived forecast) on pressure levels, turned into a SoundingProfile.

Open-Meteo serves numerical weather models’ output as JSON. Two of its APIs carry winds on pressure levels, which a rocket needs above the surface:

  • the forecast API (api.open-meteo.com/v1/forecast), about 16 days ahead and 3 months back;
  • the historical-forecast API (historical-forecast-api.open-meteo.com/v1/forecast), the same forecasts archived, for a past launch. (Its ERA5 archive API has no pressure levels.)

An OpenMeteoRequest asks for the two whole hours around the launch time, in UTC, with these hourly variables:

variableunit asked forwhere
temperature_2m, relative_humidity_2m°C, %2 m above the ground
surface_pressurehPathe ground
wind_speed_10m, wind_direction_10mm/s, ° from10 m above the ground
temperature_<p>hPa, relative_humidity_<p>hPa°C, %each of PRESSURE_LEVELS_HPA
wind_speed_<p>hPa, wind_direction_<p>hPam/s, ° fromeach level
geopotential_height_<p>hPageopotential meach level

OpenMeteoProfile::parse reads the answer, refusing any unit but those, and interpolates linearly in time between the two hours (the wind by its east and north components). It keeps:

  • The surface at the response’s elevation: the surface pressure there, with the 2 m temperature and humidity and the 10 m wind. Placing the 10 m wind at the ground makes it the wind on the launch rail, as Loft lesson L6 asks, rather than a step at the lowest pressure level.
  • Each pressure level above the ground. The models report every level, including those below the ground at a high site, where the values are extrapolated. A level is dropped when its pressure is not below the surface pressure or its height is not above the elevation. A level with no data at either hour is dropped too, and so is one whose relative humidity is outside 0 to 100%. OpenMeteoProfile::dropped lists each, with its reason.

Heights are read as geopotential meters, as the weather models define them, and converted to geometric heights at the response’s latitude with WMO-No. 8 eq. 12.16 (hpr_atmos::profile::geometric_from_wmo_geopotential_m), as the atmosphere page explains. Open-Meteo’s documentation calls the variable an altitude above sea level; the recorded answers’ layer thicknesses bear out geopotential meters (the hypsometric check in tests/open_meteo.rs). Directions are the meteorological convention, the direction the wind blows from, clockwise from north. Relative humidity is taken as over liquid water, which is what SoundingLevel means by it. A model that reports it over ice at cold levels shifts the air’s density there by 0.378 (e_w − e_i)/p: at most 27 Pa of vapour pressure (near −12 °C), so under 0.03% at 400 hPa. Higher up the air is colder and the gap smaller: about 6 Pa at −40 °C, 0.08% even at 30 hPa.

fetch asks a Client for the URL, so the answer comes from the cache when it can, and offline from the cache only; an answer that doesn’t parse is never cached. The data is licensed CC BY 4.0: show ATTRIBUTION (it is on every Fetched) wherever the weather is shown.

How far to trust it: the profile gives back every level it keeps as recorded (the tests); how good the forecast is depends on the weather model, and nothing here measures that. The guide page says more.

use hpr_atmos::WindInterpolation;
use hpr_net::open_meteo::OpenMeteoProfile;

// A response recorded from the historical-forecast API: Spaceport America, 2025-06-21,
// 15:00 and 16:00 UTC. Ask for 15:30.
let body = include_bytes!("../tests/fixtures/replay/open-meteo-historical.json");
let profile = OpenMeteoProfile::parse(body, 1_750_519_800)?;
assert_eq!(profile.dropped.len(), 5); // 1000 to 900 hPa lie below the 1,400 m ground.
let air = profile.sounding(WindInterpolation::SpeedDirection)?;
let at_5_km = air.sample(5_000.0)?.air;
assert!((at_5_km.pressure_pa - 55_000.0).abs() < 1_000.0);

Structs§

DroppedLevel
A pressure level left out of the profile, and why.
OpenMeteoLevel
One pressure level above the ground, at the launch time.
OpenMeteoProfile
An Open-Meteo response read at one time: the surface and the pressure levels above it.
OpenMeteoRequest
What to ask Open-Meteo for: a place, a time and an API.
OpenMeteoSurface
The ground under the forecast, at the launch time.

Enums§

DropReason
Why a pressure level was left out of the profile.
OpenMeteoApi
Which Open-Meteo API to ask.
OpenMeteoError
Why an Open-Meteo request or response was refused.

Constants§

ATTRIBUTION
The credit Open-Meteo’s license (CC BY 4.0) asks for, shown wherever its data is shown.
PRESSURE_LEVELS_HPA
The pressure levels asked for, hPa: all 19 that Open-Meteo’s forecast APIs serve.

Functions§

fetch
Fetches request through client and reads it at the request’s time.