Add in a windchill calculator.

This commit is contained in:
Dorian 2019-11-06 17:23:25 -05:00
parent 8086a18181
commit 2dafc1f321
1 changed files with 10 additions and 0 deletions

View File

@ -22,7 +22,17 @@ 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<f32>) -> Vec<f32> {