/* --------------------------------------------------------------- */ /* Calculate wind chill temperature, <= temp only */ /* --------------------------------------------------------------- */ /* */ /* Copyright (c) Mike Cowlishaw, 2010-2012. All rights reserved. */ /* */ /* Permission to use, copy, modify, and/or distribute this */ /* software for any purpose with or without fee is hereby granted, */ /* provided that the above copyright notice and this permission */ /* notice appear in all copies, and that notice and the date of */ /* any modifications be added to the software. */ /* */ /* This software is provided "as is". No warranties, whether */ /* express, implied, or statutory, including, but not limited to, */ /* implied warranties of merchantability and fitness for a */ /* particular purpose apply to this software. The author shall */ /* not, in any circumstances, be liable for special, incidental, */ /* or consequential damages, for any reason whatsoever. */ /* */ /* --------------------------------------------------------------- */ /* */ /* Call as a function or a command. */ /* */ /* windchill(temp speed) */ /* windchill temp speed */ /* */ /* In the argument string: */ /* */ /* Word 1 is temperature in degrees C */ /* Word 2 is wind speed in kph */ /* */ /* Returns or displays the wind chill temperature, rounded to the */ /* nearest degree C below. */ /* --------------------------------------------------------------- */ if RxFuncQuery("MathLoadFuncs") then do call RxFuncAdd "MathLoadFuncs","rxmath","MathLoadFuncs" call MathLoadFuncs end parse arg t v . if \datatype(t, 'n') then do say 'Temperature must be a number, not "'t'"' exit; end if \datatype(v, 'n') then do say 'Wind speed must be a number, not "'v'"' exit; end /** Old wind chill fomula: Siple and Passel (1945) WCT = 0.045*(5.2735*SQRT(W) + 10.45 - 0.2778*W)*(T-33.0) + 33 where: WCT = Windchill Temperature (degrees Celsius) W = wind speed (Km/hr) T = air temperature (degrees Celsius) For old formula: if v<6.5 then return t -- no effect if v>90 then v=90 -- clamp b=0.2392; c=-0.01261 -- constants s=33 -- skin temperature feel1=s - (s - t)*(0.474266 + b*rxcalcSqrt(v) + c*v) feel1=format(feel1,,1) say '*** Old chill:' feel1 **/ /** New wind chill formula: (Office of the Federal Coordinator for Meteorological Services and Supporing Research (OFCM)) Wind Chill ('F) = 35.74 + 0.6215T - 35.75(V^0.16) + 0.4275T(V^0.16) Where V = the wind speed value in mph and T = the temperature in 'F Note: Frostbite occurs in 15 minutes or less at wind chill values of -18F (-27.7C) or lower **/ f=c2f(t) -- now 'F v=v/1.609 -- now mph vp=rxcalcpower(v, 0.16) wc=35.74 + 0.6215*f - 35.75*vp + 0.4275*f*vp feel=f2c(wc) -- say '*** New chill:' feel if feel>t then feel=t -- clamp feel=format(feel-0.5,,0) -- round down parse source . how . if how\='COMMAND' then return feel arg t v . say 'Feels like:' feel'øC [for' t'øC ambient at' v'kph]' exit /* --------------------------------------------------------------- */ /* Temperature converters */ /* --------------------------------------------------------------- */ f2c: return (arg(1)-32)*5/9 c2f: return arg(1)*9/5+32