From 2dafc1f32193ecdbaede038a0a18ed11bd19cacc Mon Sep 17 00:00:00 2001 From: Dorian Pula Date: Wed, 6 Nov 2019 17:23:25 -0500 Subject: [PATCH] Add in a windchill calculator. --- src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 17dfd50..174f25d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,8 +22,18 @@ impl Temperature { fn to_fahrenheit(&self) -> f32 { self.celsius * 1.8 + 32.0 } + + fn windchill(&self, wind_speed_kph: f32) -> f32 { + // From https://www.weather.gov/media/epz/wxcalc/windChill.pdf + // And https://www.calcunation.com/calculator/wind-chill-celsius.php + 13.12 + (0.6215 * self.celsius) - (11.37 * wind_speed_kph.powf(0.16)) + + (0.3965 * self.celsius * wind_speed_kph.powf(0.16)) + } } +// Refer to: https://www.weather.gov/epz/wxcalc_windchill +// TODO: Add a test that -20 C and 32 kph feels like -32.9 + #[pyfunction] fn batch_converter(temperatures: Vec) -> Vec { temperatures