Ajax Heat Color Word

Hi
Can anyone help correct the following,the above shows “unknown” after a update this only happened today as the temp reached 19C
It has bee working correctly at lower temp.

Tony
http://www.gyweather.com

It is in Beta, but I changed this part in ajaxWdwx.js and it is more or less working

// function to add colored heatColorWord by Mike Challis
493function heatColor(temp,WindChill,Humidex) {
494 var hcWord = langHeatWords[0];
495 if (Humidex > 27) {
496 if (Humidex > 54) { return ('<span style="border: solid 1px; color: white; background-color: #BA1928;">&nbsp;'+langHeatWords[1]+'&nbsp;</span>'); }
497 if (Humidex > 40) { return ('<span style="border: solid 1px; color: white; background-color: #E02538;">&nbsp;'+langHeatWords[2]+'&nbsp;</span>'); }
498 if (Humidex > 32) { return ('<span style="border: solid 1px; color: black; background-color: #E8555D;">&nbsp;'+langHeatWords[3]+'&nbsp;</span>'); }
499 if (Humidex > 27) { return ('<span style="border: solid 1px; color: black; background-color: #E178A1;">&nbsp;'+langHeatWords[4]+'&nbsp;</span>'); }
500 } else if (WindChill < 16 ) {
501 if (WindChill < -18) { return ('<span style="border: solid 1px; color: black; background-color: #91ACFF;">&nbsp;'+langHeatWords[13]+'&nbsp;</span>'); }
502 if (WindChill < -9) { return ('<span style="border: solid 1px; color: white; background-color: #806AF9;">&nbsp;'+langHeatWords[12]+'&nbsp;</span>'); }
503 if (WindChill < -1) { return ('<span style="border: solid 1px; color: white; background-color: #3366FF;">&nbsp;'+langHeatWords[11]+'&nbsp;</span>'); }
504 if (WindChill < 8) { return ('<span style="border: solid 1px; color: white; background-color: #6699FF;">&nbsp;'+langHeatWords[10]+'&nbsp;</span>'); }
505 if (WindChill < 16) { return ('<span style="border: solid 1px; color: black; background-color: #89B2EA;">&nbsp;'+langHeatWords[9]+'&nbsp;</span>'); }
506 } else if (temp > 32 && Humidex < 27 ) {
507 return ('<span style="border: solid 1px; color: black; background-color: #F0A2A2;">&nbsp;'+langHeatWords[5]+'&nbsp;</span>');
508 } else if (WindChill > 15) {
509 if (temp < 26) { return ('<span style="border: solid 1px; color: black; background-color: #C6EF8C;">&nbsp;'+langHeatWords[8]+'&nbsp;</span>'); }
510 if (temp < 32) { return ('<span style="border: solid 1px; color: black; background-color: #CC9933;">&nbsp;'+langHeatWords[7]+'&nbsp;</span>'); }
511 if (temp < 35) { return ('<span style="border: solid 1px; color: white; background-color: #CC6633;">&nbsp;'+langHeatWords[6]+'&nbsp;</span>'); }
512}
513 return hcWord;
514}

Jozef

Thanks, Jozef. I was having the same issue as Tony. Your edit appears to have it working. :slight_smile:

–Dave

Thanks Jozef

Now working here also

Jozef,

What did you change?
What did it look like before you changed it?
This beta is really hard to test. I have to discover each condition happening to see if it works or not. :frowning:

This is the version I am currently testing:
EDIT: See the following link for the newest Final version


// function to add colored heatColorWord by Mike Challis
function heatColor(temp,WindChill,Humidex) {
  var hcWord = langHeatWords[0];
 if (temp > 32 && Humidex > 29) {
  if (Humidex > 54) { return ('<span style="border: solid 1px; color: white; background-color: #BA1928;">&nbsp;'+langHeatWords[1]+'&nbsp;</span>'); }
  if (Humidex > 45) { return ('<span style="border: solid 1px; color: white; background-color: #E02538;">&nbsp;'+langHeatWords[2]+'&nbsp;</span>'); }
  if (Humidex > 39) { return ('<span style="border: solid 1px; color: black; background-color: #E178A1;">&nbsp;'+langHeatWords[4]+'&nbsp;</span>'); }
  if (Humidex > 29) { return ('<span style="border: solid 1px; color: white; background-color: #CC6633;">&nbsp;'+langHeatWords[6]+'&nbsp;</span>'); }
 } else if (WindChill < 16 ) {
  if (WindChill < -18) { return ('<span style="border: solid 1px; color: black; background-color: #91ACFF;">&nbsp;'+langHeatWords[13]+'&nbsp;</span>'); }
  if (WindChill < -9)  { return ('<span style="border: solid 1px; color: white; background-color: #806AF9;">&nbsp;'+langHeatWords[12]+'&nbsp;</span>'); }
  if (WindChill < -1)  { return ('<span style="border: solid 1px; color: white; background-color: #3366FF;">&nbsp;'+langHeatWords[11]+'&nbsp;</span>'); }
  if (WindChill < 8)   { return ('<span style="border: solid 1px; color: white; background-color: #6699FF;">&nbsp;'+langHeatWords[10]+'&nbsp;</span>'); }
  if (WindChill < 16)  { return ('<span style="border: solid 1px; color: black; background-color: #89B2EA;">&nbsp;'+langHeatWords[9]+'&nbsp;</span>'); }
 }  else if (WindChill >= 16 && temp <= 32) {
  if (temp < 26) { return ('<span style="border: solid 1px; color: black; background-color: #C6EF8C;">&nbsp;'+langHeatWords[8]+'&nbsp;</span>'); }
  if (temp <= 32) { return ('<span style="border: solid 1px; color: black; background-color: #CC9933;">&nbsp;'+langHeatWords[7]+'&nbsp;</span>'); }
  }
  return hcWord;
}

The temps I need to verify are all the warm and hot ones.
If you see a condition you think is not working, please reply here with the temp, windchill, humidex and the condition you think it should be displaying.
You can find the temp, windchill, and humidex from Kevin’s ClientRaw Parser.
http://www.tnetweather.com/wd-parser.php
temp, windchill, and humidex is fields, 004(temp), 044(windchill), and 045(humidex).

I can test it by setting the temp, windchill, and humidex manually in the function


function heatColor(temp,WindChill,Humidex) {
  var hcWord = langHeatWords[0];
  temp      = '28.8';  //temporary test
  WindChill = '28.8';  //temporary test
  Humidex   = '28.7'; //temporary test


//started with the first code I did ever find from Mike Challis
//using panel from WD
//starting at the bottom of that panel, we have 4 times humidex(checking from highest value to lowest
//next we do windchill
//checking lowest to highest
//what about "uncomfortably hot" => My opinion ? it says > temperature warm(temperature warm in the panel = 32
//< humidex 38 in the panel ??
//so, why I use 27 in "} else if (temp > 32 && Humidex < 27 ) {"
//we checked in the first place for Humidex > 27, so now I di put < 27 in here(there is 38 in the panel)
//Now for comfortable it did return Unknown
// "} else if (WindChill > 15) {" was "temp < 26"
//but we checked WindChill < 16, so what happens if Windchill was higher ?
//I know it is not perfect, there are some missing pieces in here, but so far I know it is working
// for comfortable and lower( according to the PHP version in the templates from Ken, and the heatcolorword comes from WD in there
// now I'm waiting to see what it does when it is summer here
// I wanted to test this with fake values, but whaterver I did put in there, I always have some different words, compared to that panel in WD
//
//Now, I did my best to explain what I was thinking here
//I hope you can understand this explanation(I'm not english)
//
// 
// function to add colored heatColorWord by Mike Challis
function heatColor(temp,WindChill,Humidex) {
 var hcWord = langHeatWords[0];
 if (Humidex > 27) {
 if (Humidex > 54) { return ('<span style="border: solid 1px; color: white; background-color: #BA1928;">&nbsp;'+langHeatWords[1]+'&nbsp;</span>'); }
 if (Humidex > 40) { return ('<span style="border: solid 1px; color: white; background-color: #E02538;">&nbsp;'+langHeatWords[2]+'&nbsp;</span>'); }
 if (Humidex > 32) { return ('<span style="border: solid 1px; color: black; background-color: #E8555D;">&nbsp;'+langHeatWords[3]+'&nbsp;</span>'); }
 if (Humidex > 27) { return ('<span style="border: solid 1px; color: black; background-color: #E178A1;">&nbsp;'+langHeatWords[4]+'&nbsp;</span>'); }
 } else if (WindChill < 16 ) {
 if (WindChill < -18) { return ('<span style="border: solid 1px; color: black; background-color: #91ACFF;">&nbsp;'+langHeatWords[13]+'&nbsp;</span>'); }
 if (WindChill < -9) { return ('<span style="border: solid 1px; color: white; background-color: #806AF9;">&nbsp;'+langHeatWords[12]+'&nbsp;</span>'); }
 if (WindChill < -1) { return ('<span style="border: solid 1px; color: white; background-color: #3366FF;">&nbsp;'+langHeatWords[11]+'&nbsp;</span>'); }
 if (WindChill < 8) { return ('<span style="border: solid 1px; color: white; background-color: #6699FF;">&nbsp;'+langHeatWords[10]+'&nbsp;</span>'); }
 if (WindChill < 16) { return ('<span style="border: solid 1px; color: black; background-color: #89B2EA;">&nbsp;'+langHeatWords[9]+'&nbsp;</span>'); }
 } else if (temp > 32 && Humidex < 27 ) {
 return ('<span style="border: solid 1px; color: black; background-color: #F0A2A2;">&nbsp;'+langHeatWords[5]+'&nbsp;</span>');
 } else if (WindChill > 15) {
 if (temp < 26) { return ('<span style="border: solid 1px; color: black; background-color: #C6EF8C;">&nbsp;'+langHeatWords[8]+'&nbsp;</span>'); }
 if (temp < 32) { return ('<span style="border: solid 1px; color: black; background-color: #CC9933;">&nbsp;'+langHeatWords[7]+'&nbsp;</span>'); }
 if (temp < 35) { return ('<span style="border: solid 1px; color: white; background-color: #CC6633;">&nbsp;'+langHeatWords[6]+'&nbsp;</span>'); }
}
 return hcWord;
}

I hope this helps

Jozef

This is my latest BETA, can some people in Hot climates test it?

I made a new feature for ajaxWDwx.js
This feature is called “Ajax Heat Color Word” and it is a BETA Test until I am for sure about the logic.
It makes the heatcolourword ajaxed with a color background that changes with the heatcolor, very similar to heatcolourword in WD

See it being used on my ajax dashboard here:
http://www.carmosaic.com/weather/index.php

This is the BETA version I am currently testing:
EDIT 05/09/08:
made some more changes to the heatColor function, if you installed this function earlier, you should replace it with this.
EDIT: See the following link for the newest Final version

http://discourse.weather-watch.com/c/74

Here is how to add it:

edit ajax-dashboard.php:
change:


<?php  echo $heatcolourword; ?>

to:


<span class="ajax" id="ajaxheatcolorword"><?php  echo $heatcolourword; ?></span>

edit ajaxWDwx.js:

change:


// -- end of language settings ----------------------------------------------------------

to:


var langHeatWords = new Array (
 'Unknown', 'Extreme Heat Danger', 'Heat Danger', 'Extreme Heat Caution', 'Extremely Hot', 'Uncomfortably Hot',
 'Hot', 'Warm', 'Comfortable', 'Cool', 'Cold', 'Uncomfortably Cold', 'Very Cold', 'Extreme Cold' );

// -- end of language settings ----------------------------------------------------------

change:


// Mike Challis' counter function (adapted by Ken True)

to:


// function to add colored heatColorWord by Mike Challis
// beta version 0.91 
function heatColor(temp,WindChill,Humidex) {
  var hcWord = langHeatWords[0];
 if (temp > 32 && Humidex > 29) {
  if (Humidex > 54) { return ('<span style="border: solid 1px; color: white; background-color: #BA1928;">&nbsp;'+langHeatWords[1]+'&nbsp;</span>'); }
  if (Humidex > 45) { return ('<span style="border: solid 1px; color: white; background-color: #E02538;">&nbsp;'+langHeatWords[2]+'&nbsp;</span>'); }
  if (Humidex > 39) { return ('<span style="border: solid 1px; color: black; background-color: #E178A1;">&nbsp;'+langHeatWords[4]+'&nbsp;</span>'); }
  if (Humidex > 29) { return ('<span style="border: solid 1px; color: white; background-color: #CC6633;">&nbsp;'+langHeatWords[6]+'&nbsp;</span>'); }
 } else if (WindChill < 16 ) {
  if (WindChill < -18) { return ('<span style="border: solid 1px; color: black; background-color: #91ACFF;">&nbsp;'+langHeatWords[13]+'&nbsp;</span>'); }
  if (WindChill < -9)  { return ('<span style="border: solid 1px; color: white; background-color: #806AF9;">&nbsp;'+langHeatWords[12]+'&nbsp;</span>'); }
  if (WindChill < -1)  { return ('<span style="border: solid 1px; color: white; background-color: #3366FF;">&nbsp;'+langHeatWords[11]+'&nbsp;</span>'); }
  if (WindChill < 8)   { return ('<span style="border: solid 1px; color: white; background-color: #6699FF;">&nbsp;'+langHeatWords[10]+'&nbsp;</span>'); }
  if (WindChill < 16)  { return ('<span style="border: solid 1px; color: black; background-color: #89B2EA;">&nbsp;'+langHeatWords[9]+'&nbsp;</span>'); }
 }  else if (WindChill >= 16 && temp <= 32) {
  if (temp < 26) { return ('<span style="border: solid 1px; color: black; background-color: #C6EF8C;">&nbsp;'+langHeatWords[8]+'&nbsp;</span>'); }
  if (temp <= 32) { return ('<span style="border: solid 1px; color: black; background-color: #CC9933;">&nbsp;'+langHeatWords[7]+'&nbsp;</span>'); }
  }
  return hcWord;
}

// Mike Challis' counter function (adapted by Ken True)

change:


set_ajax_obs("ajaxfeelslike",feelslike + uomTemp);

to:


set_ajax_obs("ajaxfeelslike",feelslike + uomTemp);

                // # mike challis added heatColorWord feature
                var heatColorWord = heatColor(clientraw[4],clientraw[44],clientraw[45]);
                set_ajax_obs("ajaxheatcolorword",heatColorWord);

Mike,
I’ve installed the heatcolorword function into the ajaxWDwx.js used in the Multilingual template test site

http://saratoga-weather.org/template/WD-World-ML/wxindex.php

Seems to work fine on all translations too :wink:

Nice job!

Best regards,
Ken

I’ve incorporated the Ajax changes into my site and seems to be working fine as far as I can tell. www.bigbaywx.com

I am still having trouble wrapping my brain around this one.
The “Uncomfortably hot” condition in my BETA code is not correct ( I was trying something there, but after more study I have more doubts)

The problem is there are only 4 official levels of humidex “Degree of Comfort” above “comfortable”. WD is trying to implement 5 levels while it does not seem to make sense according to this chart:

How is humidex interpreted?

The relation between humidex and comfort is subjective. It varies widely between individuals. Environment Canada provides the following guide as a measure of discomfort according to humidex:

* Where humidex levels are less than 29, most people are comfortable.
* Where humidex levels range from 30 to 39, people experience some discomfort.
* Where humidex levels range from 40 to 45, people are uncomfortable.
* Where humidex levels are over 45, dangerous conditions exist and many types of labour must be restricted.
* Where humidex exceeds 54, heat stroke is imminent.

My thoughts are…
The problem I am having is that the default WD condition thresholds are
38(uncomfortably hot),
27(extremely hot),
32(extreme heat caution),
40(heat danger),
54(extreme heat danger)

So then why is “Uncomfortably hot” a higher default level than “extremely hot” and “extreme heat caution”?
That does pass the logic I am trying to figure out!
Where humidex levels are less than 29, most people are comfortable, so why not just drop the 38(uncomfortably hot)?
This needs more discussion and testing.

This is how I think WD is calculating it with default WD settings:
(the problem? “Uncomfortably hot”(38) is a higher default humidex level than “extremely hot”(27) and “extreme heat caution”(32))

// function to add colored heatColorWord by Mike Challis
function heatColor(temp,WindChill,Humidex) {
  var hcWord = langHeatWords[0];
 if (temp > 32 && Humidex > 27) {
  if (Humidex > 54) { return ('Extreme Heat Danger'); }
  if (Humidex > 40) { return ('Heat Danger'); }
  if (Humidex > 32) { return ('Extreme Heat Caution'); }
  if (Humidex > 27) { return ('Extremely Hot'); }
 } else if (temp > 32 && Humidex <= 38) {
    return ('Uncomfortably Hot');
 } else if (WindChill < 16 ) {
  if (WindChill < -18) { return ('Extreme Cold'); }
  if (WindChill < -9)  { return ('Very Cold'); }
  if (WindChill < -1)  { return ('Uncomfortably Cold'); }
  if (WindChill < 8)   { return ('Cold'); }
  if (WindChill < 16)  { return ('Cool'); }
 } else if (WindChill >= 16 && temp < 35) {
  if (temp < 26) { return ('Comfortable'); }
  if (temp < 32) { return ('Warm'); }
  if (temp < 35) { return ('Hot'); }
}
  return hcWord;
}

I tried to compensate with (Humidex <= 27) in the BETA code but the charts say humidex below 29 is “comfortable” and if the temp is above 32 for this condition I do not think humidex would ever be less than 32

Did I open a can o worms?
:scratch: :shaking2: :scratch:


Maybe just go with the humidex version, then you have something "official’ to hang it on.

I agree niko, this is what I would do…
I got rid of “Uncomfortably Hot”, and “Extreme Heat Caution”, and made the 4 levels of highest heat more resemble the Environment Canada Scale.
Do I like it better? yes
Is it perfect? probably not.
Was WD wrong? I do not know.


// test version for forum discussion only //
// function to add colored heatColorWord by Mike Challis
function heatColortest(temp,WindChill,Humidex) {
  var hcWord = 'unknown';
 if (temp > 32 && Humidex > 29) {
  if (Humidex > 54) { return ('Extreme Heat Danger'); }
  if (Humidex > 45) { return ('Heat Danger'); }
  if (Humidex > 39) { return ('Extremely Hot'); }
  if (Humidex > 29) { return ('Hot'); }
 } else if (WindChill < 16 ) {
  if (WindChill < -18) { return ('Extreme Cold'); }
  if (WindChill < -9)  { return ('Very Cold'); }
  if (WindChill < -1)  { return ('Uncomfortably Cold'); }
  if (WindChill < 8)   { return ('Cold'); }
  if (WindChill < 16)  { return ('Cool'); }
 } else if (WindChill >= 16 && temp <= 32) {
  if (temp < 26) { return ('Comfortable'); }
  if (temp <= 32) { return ('Warm'); }
}
  return hcWord;
}

The BETA code would then be:
and I will now call it… beta version 0.90

[b]EDIT 05/09/08:
made some more changes to the heatColor function, if you installed this function earlier, you should replace it with this.

EDIT: See the following link for the newest Final version[/b]


// function to add colored heatColorWord by Mike Challis
// beta version 0.91 
function heatColor(temp,WindChill,Humidex) {
  var hcWord = langHeatWords[0];
 if (temp > 32 && Humidex > 29) {
  if (Humidex > 54) { return ('<span style="border: solid 1px; color: white; background-color: #BA1928;">&nbsp;'+langHeatWords[1]+'&nbsp;</span>'); }
  if (Humidex > 45) { return ('<span style="border: solid 1px; color: white; background-color: #E02538;">&nbsp;'+langHeatWords[2]+'&nbsp;</span>'); }
  if (Humidex > 39) { return ('<span style="border: solid 1px; color: black; background-color: #E178A1;">&nbsp;'+langHeatWords[4]+'&nbsp;</span>'); }
  if (Humidex > 29) { return ('<span style="border: solid 1px; color: white; background-color: #CC6633;">&nbsp;'+langHeatWords[6]+'&nbsp;</span>'); }
 } else if (WindChill < 16 ) {
  if (WindChill < -18) { return ('<span style="border: solid 1px; color: black; background-color: #91ACFF;">&nbsp;'+langHeatWords[13]+'&nbsp;</span>'); }
  if (WindChill < -9)  { return ('<span style="border: solid 1px; color: white; background-color: #806AF9;">&nbsp;'+langHeatWords[12]+'&nbsp;</span>'); }
  if (WindChill < -1)  { return ('<span style="border: solid 1px; color: white; background-color: #3366FF;">&nbsp;'+langHeatWords[11]+'&nbsp;</span>'); }
  if (WindChill < 8)   { return ('<span style="border: solid 1px; color: white; background-color: #6699FF;">&nbsp;'+langHeatWords[10]+'&nbsp;</span>'); }
  if (WindChill < 16)  { return ('<span style="border: solid 1px; color: black; background-color: #89B2EA;">&nbsp;'+langHeatWords[9]+'&nbsp;</span>'); }
 }  else if (WindChill >= 16 && temp <= 32) {
  if (temp < 26) { return ('<span style="border: solid 1px; color: black; background-color: #C6EF8C;">&nbsp;'+langHeatWords[8]+'&nbsp;</span>'); }
  if (temp <= 32) { return ('<span style="border: solid 1px; color: black; background-color: #CC9933;">&nbsp;'+langHeatWords[7]+'&nbsp;</span>'); }
  }
  return hcWord;
}

It’s all pretty subjective anyway and I suspect there are a lot of people, especially outdoor workers, in warm climates that are unware that they are already dead by Canadian standards :roll:

MCHALLIS:
Just updated to the latest beta version…North Carolina can get kinda warm…thanks for making this available.
http://www.i40exit319weather.com/index.php

Ronnie

Have updated mine also. Last year I had a high in August of 100.4 and a heat index of 114.7 so maybe something will show up. But I hoping not to get close to those temps. :slight_smile:

Thanks for the update!

–Dave

Hi,

The BETA seems to be working fine.

John

Works for me as well…good job. Current temp is 79deg F. Showing “Warm”

Linda