Advertisement
NBK_PlanB

Improved TempSensorCalcs

Jan 1st, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. double calcDewPointFast(double T, double RH)
  2. {
  3. double Td = T - ((100 - RH)/5.); //https://iridl.ldeo.columbia.edu/dochelp/QA/Basic/dewpoint.html
  4. if (Td < 0) Td = 0;
  5. return Td;
  6. }
  7.  
  8. double calcHeatIndex(double T, double RH)
  9. {
  10. // The Rothfusz regression is not appropriate when conditions of temperature and humidity warrant a heat index value below about 80 degrees F.
  11. // In those cases, a simpler formula is applied to calculate values consistent with Steadman's results:
  12. // HI = 0.5 * {T + 61.0 + [(T-68.0)*1.2] + (RH*0.094)}
  13. // In practice, the simple formula is computed first and the result averaged with the temperature. If this heat index value is 80 degrees F or higher, the full regression equation along with any adjustment as described above is applied.
  14.  
  15. double HI = 0.5 * (T + 61.0 + ((T-68.0)*1.2) + (RH*0.094));
  16.  
  17. if (HI > 80.0)
  18. {
  19. HI = -42.379 + 2.04901523*T + 10.14333127*RH - .22475541*T*RH - .00683783*T*T - .05481717*RH*RH + .00122874*T*T*RH + .00085282*T*RH*RH - .00000199*T*T*RH*RH;
  20.  
  21. // If the RH is less than 13% and the temperature is between 80 and 112 degrees F
  22. // ADJUSTMENT = [(13-RH)/4]*SQRT{[17-ABS(T-95.)]/17}
  23.  
  24. if (RH < 13 & (T > 80.0 & T < 112.0))
  25. {
  26. double ADJUSTMENT = ((13-RH)/4)*sqrt((17-abs(T-95.))/17);
  27. HI = HI - ADJUSTMENT;
  28. }
  29.  
  30. // If the RH is greater than 85% and the temperature is between 80 and 87 degrees F
  31. // ADJUSTMENT = [(RH-85)/10] * [(87-T)/5]
  32. if (RH > 85 & (T > 80.0 & T < 87.0))
  33. {
  34. double ADJUSTMENT = ((RH-85)/10) * ((87-T)/5);
  35. HI = HI - ADJUSTMENT;
  36. }
  37. }
  38. return HI;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement