check_station_temperature_c

Function check_station_temperature_c 

Source
pub fn check_station_temperature_c(
    temperature_c: f64,
) -> Result<(), AtmosphereError>
Expand description

The one rule a station temperature, °C, is held to on its own, on every surface: finite and above absolute zero (-273.15 °C). Nothing narrower: outside 173.15-373.15 K (-100 °C to 100 °C) the humidity terms are extrapolated, never refused. StationAir::new applies it, and then the impossible-air rule, which is the only other reason a temperature is refused (in flight too: AtmosphereErrorReason::AirAloftBelowAbsoluteZero). A surface that checks a reading as it is typed (a CLI flag, converted to °C) applies this same function, so a reading is accepted or refused alike everywhere.

use ballistics_engine::atmosphere::check_station_temperature_c;

assert!(check_station_temperature_c(250.0).is_ok()); // extrapolated, not refused
assert!(check_station_temperature_c(-150.0).is_ok());
assert!(check_station_temperature_c(-273.15).is_err()); // absolute zero
assert!(check_station_temperature_c(f64::NAN).is_err());

§Errors

AtmosphereErrorReason::NotFinite or AtmosphereErrorReason::AtOrBelowAbsoluteZero, on temperature_c.