Author Topic: Humidex formula .  (Read 5296 times)

0 Members and 1 Guest are viewing this topic.

Offline Total

  • Web dude ..
  • Senior Contributor
  • ****
  • Posts: 151
    • weather station ..
Humidex formula .
« on: July 21, 2016, 12:49:26 PM »
Hi : I'm using this formula now

 // JavaScript Document
   var T = ^vxv007^ ;
   var H = ^vxv005^ ;
   var t = 7.5*T/(237.7 + T);
   var et = Math.pow(10,t);
   var e = 6.112*et*(H/100);
   var humidex = T + (5 / 9) * (e - 10);
   if (humidex < T)
   { humidex = T;
   }
   document.write(Math.ceil(humidex));

But it is always off on the humidex that is reported at my location .  Ideas . could someone help with making  the wikipedia formula ? thanks
https://en.wikipedia.org/wiki/Humidex

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Humidex formula .
« Reply #1 on: July 21, 2016, 12:53:59 PM »
What temperature units is your T in

Offline Total

  • Web dude ..
  • Senior Contributor
  • ****
  • Posts: 151
    • weather station ..
Re: Humidex formula .
« Reply #2 on: July 21, 2016, 12:56:21 PM »
T is in Celsius .

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Humidex formula .
« Reply #3 on: July 21, 2016, 01:10:31 PM »
I cannot guarantee, but try this:

Code: [Select]
var T = ^vxv007^ ;
var H = ^vxv005^ ;
var D = ((Math.pow((H/100), 0.125))*(112+0.9*T)+(0.1*T)-112);
var temporary = 5471.7530 * (1/273.16 - 1/(D-273.15));
var temporary2 = 6.11*Math.log(temporary)-10;
result = T + 0.555 * temporary2;
document.write(Math.ceil(result ));

Offline Total

  • Web dude ..
  • Senior Contributor
  • ****
  • Posts: 151
    • weather station ..
Re: Humidex formula .
« Reply #4 on: July 21, 2016, 02:03:09 PM »
Will do . thanks

Offline ericfynne

  • Contributor
  • ***
  • Posts: 139

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Humidex formula .
« Reply #6 on: July 21, 2016, 02:21:11 PM »
Oh I see a problem, sorry, the third line should be like this:

var temporary = 5471.7530 * (1/273.16 - 1/(D+273.15));

Offline Total

  • Web dude ..
  • Senior Contributor
  • ****
  • Posts: 151
    • weather station ..
Re: Humidex formula .
« Reply #7 on: July 21, 2016, 04:45:54 PM »
Tried it , but the values are really low ..

Offline Total

  • Web dude ..
  • Senior Contributor
  • ****
  • Posts: 151
    • weather station ..
Re: Humidex formula .
« Reply #8 on: July 21, 2016, 06:33:46 PM »
The humidex now is below the temp outside . http://www.strutherslakeweather.ca/  , up at the top . thanks .

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Humidex formula .
« Reply #9 on: July 21, 2016, 06:51:07 PM »
I dont know, in my template I use the formula for apparent temperature. It is in my opinion the best parameter because:

- windchill - takes into account temperature and the wind speed cooling effect
- humidex - takes into account temperature and the humidity warming effect
- feels like (apparent) temperature - takes into account temperature, wind speed and humidity. For high Ts, it usually is higher than the T, though if it is windy it doesnt have to be. At low Ts, it is usually either equal or much lower, depending on wind speed

Offline Total

  • Web dude ..
  • Senior Contributor
  • ****
  • Posts: 151
    • weather station ..
Re: Humidex formula .
« Reply #10 on: July 21, 2016, 06:59:00 PM »
thanks for this . So this formula is for the apparent temperature ? Correct .

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Humidex formula .
« Reply #11 on: July 21, 2016, 07:21:40 PM »
No, for that I use this:

t = Temperature in C
hum = Humidity in %
w = wind speed in km/h

Code: [Select]
function feeltemp(T, hum, w){
t = eval(T);
rh = eval(hum);
w = eval(w/3.6);
e = (rh/100)*6.105*Math.pow(2.71828, ((17.27*t)/(237.7+t)));
at = Math.round((t + 0.33*e-0.7*w-4)*10)/10;
at = at.toFixed(1);
                return at;
}

So for example this would show you the apparent T:

apparent = feeltemp(25,50,15);
alert(apparent);

Offline ericfynne

  • Contributor
  • ***
  • Posts: 139
Re: Humidex formula .
« Reply #12 on: July 22, 2016, 06:52:47 AM »
Have you tried the code from the link I posted? It seems to be correct.

Eric

Offline Total

  • Web dude ..
  • Senior Contributor
  • ****
  • Posts: 151
    • weather station ..
Re: Humidex formula .
« Reply #13 on: July 22, 2016, 01:38:46 PM »
Have you tried the code from the link I posted? It seems to be correct.

Eric

I looked at it but don't know how to make it work with my web page ...

'use strict';

/*
 * @param {t} : The temperature in °C
 * @param {h} : The air humidity in % (0 <= h <= 1)
 * @returns : the humidex in °C
 */
module.exports = function humidex (t, h) {
  var dewPoint = Math.pow(h, 1 / 8) * (112 + 0.9 * t) + 0.1 * t - 112;
  var expIndex = 5417.753 * ((1 / 273.16) - (1 / (dewPoint + 273.16)));
  return t + 0.5555 * (6.11 * Math.exp(expIndex) - 10);
};


off my web page

....... <font face="Arial">Humidex (feels like):</font> <font
      face="Arial">
      <script language="javascript">



// JavaScript Document
  var T = ^vxv007^ ;
  var H = ^vxv005^ ;
  var D = ((Math.pow((H/100), 0.125))*(112+0.9*T)+(0.1*T)-112);
  var temporary = 5471.7530 * (1/273.16 - 1/(D+273.16));
  var temporary2 = 6.11*Math.log(temporary)-10;
  result = T + 0.555 * temporary2;
  if (result < T)
     { result = T;
   }
document.write(Math.ceil(result ));
   </script>°C </font>

Offline ericfynne

  • Contributor
  • ***
  • Posts: 139
Re: Humidex formula .
« Reply #14 on: July 22, 2016, 02:02:47 PM »
Instead of your original:

// JavaScript Document
  var T = ^vxv007^ ;
  var H = ^vxv005^ ;
  var D = ((Math.pow((H/100), 0.125))*(112+0.9*T)+(0.1*T)-112);
  var temporary = 5471.7530 * (1/273.16 - 1/(D+273.16));
  var temporary2 = 6.11*Math.log(temporary)-10;
  result = T + 0.555 * temporary2;
  if (result < T)
     { result = T;
   }
document.write(Math.ceil(result ));
   </script>°C </font>

try

// JavaScript Document
  var T = ^vxv007^ ;
  var H = ^vxv005^ ;
  var dewPoint = Math.pow(H, 1 / 8 ) * (112 + 0.9 * T) + 0.1 * T - 112;
  var expIndex = 5417.753 * ((1 / 273.16) - (1 / (dewPoint + 273.16)));
  result = T + 0.5555 * (6.11 * Math.exp(expIndex) - 10);
  if (result < T)
     { result = T;
   }
document.write(Math.ceil(result ));
   </script>°C </font>

The effective differences between what you had and this are small, but important.
« Last Edit: July 22, 2016, 02:08:03 PM by ericfynne »

Offline Total

  • Web dude ..
  • Senior Contributor
  • ****
  • Posts: 151
    • weather station ..
Re: Humidex formula .
« Reply #15 on: July 22, 2016, 02:21:54 PM »
Will try it and reply back .thanks again ..  :grin:

Offline Total

  • Web dude ..
  • Senior Contributor
  • ****
  • Posts: 151
    • weather station ..
Re: Humidex formula .
« Reply #16 on: July 22, 2016, 02:42:45 PM »
Will try it and reply back .thanks again ..  :grin:


Something is wrong ..  Humidex (feels like): 579°C   

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Humidex formula .
« Reply #17 on: July 22, 2016, 05:35:07 PM »
Did you try my feels like formula?

Offline Total

  • Web dude ..
  • Senior Contributor
  • ****
  • Posts: 151
    • weather station ..
Re: Humidex formula .
« Reply #18 on: July 23, 2016, 12:55:13 AM »
Does this look right ?  for the feels like temp ?
<script language="javascript">

// JavaScript Document
// t = Temperature in C
// hum = Humidity in %
// w = wind speed in km/h (M = mph)
   var t = ^vxv007^ ;
   var hum = ^vxv005^ ;
   var M = ^vxv002^ ; 
   var w = M * 1.60934 ;

 function feeltemp(T, hum, w){
      t = eval(T);
      rh = eval(hum);
      w = eval(w/3.6);
      e = (rh/100)*6.105*Math.pow(2.71828, ((17.27*t)/(237.7+t)));
      at = Math.round((t + 0.33*e-0.7*w-4)*10)/10;
      at = at.toFixed(1);
                return at;
                   }
                document.write(Math.ceil(at));
   </script>°C </font> 
« Last Edit: July 23, 2016, 01:54:01 AM by Total »

Offline ericfynne

  • Contributor
  • ***
  • Posts: 139
Re: Humidex formula .
« Reply #19 on: July 23, 2016, 01:22:21 AM »
Something is wrong ..  Humidex (feels like): 579°C
The spec for the function is wrong, it's expecting humidity as a fraction of 1, not as a percentage (like your original code).

So this line:

var dewPoint = Math.pow((H, 1 / 8 ) * (112 + 0.9 * T) + 0.1 * T - 112;

needs to be

var dewPoint = Math.pow((H/100), 1 / 8 ) * (112 + 0.9 * T) + 0.1 * T - 112;

I think that means that the only actual difference between the code from that site and the code Jachym supplied, is that it needs to use Math.exp rather than Math.log in the final calculation.

Offline Total

  • Web dude ..
  • Senior Contributor
  • ****
  • Posts: 151
    • weather station ..
Re: Humidex formula .
« Reply #20 on: July 23, 2016, 01:53:01 AM »
Something is wrong ..  Humidex (feels like): 579°C
The spec for the function is wrong, it's expecting humidity as a fraction of 1, not as a percentage (like your original code).

So this line:

var dewPoint = Math.pow((H, 1 / 8 ) * (112 + 0.9 * T) + 0.1 * T - 112;

needs to be

var dewPoint = Math.pow((H/100), 1 / 8 ) * (112 + 0.9 * T) + 0.1 * T - 112;

I think that means that the only actual difference between the code from that site and the code Jachym supplied, is that it needs to use Math.exp rather than Math.log in the final calculation.

thanks - that works now . I'm learning all the time .

Now if I can get Jachym's feel like code to read on my site .

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Humidex formula .
« Reply #21 on: July 23, 2016, 09:10:19 AM »
You need to run the function and pass the parameters to it, so like this for example:

<script>
var t = ^vxv007^ ;
var hum = ^vxv005^ ;
var M = ^vxv002^ ; 
var w = M * 1.60934 ;

feelsLike = feeltemp(t,hum,w);
document.write(feelsLike);

function feeltemp(T, hum, w){
      t = eval(T);
      rh = eval(hum);
      w = eval(w/3.6);
      e = (rh/100)*6.105*Math.pow(2.71828, ((17.27*t)/(237.7+t)));
      at = Math.round((t + 0.33*e-0.7*w-4)*10)/10;
      at = at.toFixed(1);
      return at;
   }
   </script>

Offline Total

  • Web dude ..
  • Senior Contributor
  • ****
  • Posts: 151
    • weather station ..
Re: Humidex formula .
« Reply #22 on: July 23, 2016, 12:22:18 PM »
You need to run the function and pass the parameters to it, so like this for example:

<script>
var t = ^vxv007^ ;
var hum = ^vxv005^ ;
var M = ^vxv002^ ; 
var w = M * 1.60934 ;

feelsLike = feeltemp(t,hum,w);
document.write(feelsLike);

function feeltemp(T, hum, w){
      t = eval(T);
      rh = eval(hum);
      w = eval(w/3.6);
      e = (rh/100)*6.105*Math.pow(2.71828, ((17.27*t)/(237.7+t)));
      at = Math.round((t + 0.33*e-0.7*w-4)*10)/10;
      at = at.toFixed(1);
      return at;
   }
   </script>

So if I paste this into my wx.htx file all will work ? thanks

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Humidex formula .
« Reply #23 on: July 23, 2016, 12:26:42 PM »
Im not sure, I mean I dont know which file you are talking about, the above script is the function to calculate it.

Just try it, but I dont know which page you are trying to insert it into, I just used what you posted above.

Offline Total

  • Web dude ..
  • Senior Contributor
  • ****
  • Posts: 151
    • weather station ..
Re: Humidex formula .
« Reply #24 on: July 23, 2016, 12:38:23 PM »
Im not sure, I mean I dont know which file you are talking about, the above script is the function to calculate it.

Just try it, but I dont know which page you are trying to insert it into, I just used what you posted above.

thanks , and I appreciate your help . Is this Java ?

 

anything