You're very welcome.. glad you're having fun with the template set.
For your site at
https://maryborough-wx.com/ , the 'weather words' are determined by scripts in two location:
1) for the PHP page, it's in CU-defs.php
Code: Select all
#-------------------------------------------------------------------------------------
# CU support function - CU_setFeelslike
#-------------------------------------------------------------------------------------
function CU_setFeelslike ($temp,$windchill,$heatindex,$humidex,$apparenttemp,$tempUOM) {
global $Debug, $SITE;
// establish the feelslike temperature and return a word describing how it feels
$HeatWords = 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' );
if(isset($SITE['feelslike'])) {
$flVar = $SITE['feelslike'];
} else {
$flVar = -1;
}
// first convert all temperatures to Centigrade if need be
$TC = $temp;
$WC = $windchill;
switch ($flVar) {
case 0:
$HC = $heatindex;
$using = 'HeatIndex';
break;
case 1:
$HC = $humidex;
$using = 'Humidex';
break;
case 2:
$HC = $apparenttemp;
$using = 'ApparentTemp';
break;
default:
$HC = $heatindex;
$using = 'HeatIndex(default)';
break;
}
if(strpos($TC,',') !== false) {
$TC = preg_replace('|,|','.',$TC);
$WC = preg_replace('|,|','.',$WC);
$HC = preg_replace('|,|','.',$HC);
}
if (preg_match('|F|i',$tempUOM)) { // convert F to C if need be
$TC = sprintf("%01.1f",round(($TC-32.0) / 1.8,1));
$WC = sprintf("%01.1f",round(($WC-32.0) / 1.8,1));
$HC = sprintf("%01.1f",round(($HC-32.0) / 1.8,1));
}
// Feelslike
if ($TC <= 16.0 ) {
$feelslike = $WC; //use WindChill
} elseif ($TC >=27.0) {
$feelslike = $HC; //use HeatIndex/Humidex/ApparentTemp
} else {
$feelslike = $TC; // use temperature
}
if (preg_match('|F|i',$tempUOM)) { // convert C back to F if need be
$feelslike = (1.8 * $feelslike) + 32.0;
}
$feelslike = round($feelslike,0);
// determine the 'heat color word' to use
$hcWord = $HeatWords[0];
$hcFound = false;
if ($TC > 32 and $HC > 29) {
if ($HC > 54 and ! $hcFound) { $hcWord = $HeatWords[1]; $hcFound = true;}
if ($HC > 45 and ! $hcFound) { $hcWord = $HeatWords[2]; $hcFound = true; }
if ($HC > 39 and ! $hcFound) { $hcWord = $HeatWords[4]; $hcFound = true; }
if ($HC > 29 and ! $hcFound) { $hcWord = $HeatWords[6]; $hcFound = true; }
} elseif ($WC < 16 ) {
if ($WC < -18 and ! $hcFound) { $hcWord = $HeatWords[13]; $hcFound = true; }
if ($WC < -9 and ! $hcFound) { $hcWord = $HeatWords[12]; $hcFound = true; }
if ($WC < -1 and ! $hcFound) { $hcWord = $HeatWords[11]; $hcFound = true; }
if ($WC < 8 and ! $hcFound) { $hcWord = $HeatWords[10]; $hcFound = true; }
if ($WC < 16 and ! $hcFound) { $hcWord = $HeatWords[9]; $hcFound = true; }
} elseif ($WC >= 16 and $TC <= 32) {
if ($TC <= 26 and ! $hcFound) { $hcWord = $HeatWords[8]; $hcFound = true; }
if ($TC <= 32 and ! $hcFound) { $hcWord = $HeatWords[7]; $hcFound = true; }
}
if(isset($_REQUEST['debug'])) {
echo "<!-- CU_setFeelslike input T,WC,HI,HU,AT,U='$temp,$windchill,$heatindex,$humidex,$apparenttemp,$tempUOM'\n";
echo " cnvt T,WC,$using='$TC,$WC,$HC'°C\n";
echo " feelslike=$feelslike hcWord=$hcWord\n -->\n";
}
return(array($feelslike,$hcWord));
} // end of CU_setFeelslike
and that is what is used for the initial page display. If you allow AJAX (which you do), then shortly after the page is displayed, the ajaxCUwx.js JavaScript cuts in and updates the values based on data from realtime.txt
Code: Select all
// function to add colored heatColorWord by Mike Challis
// final version 1.00
function heatColor(inTemp,inWindChill,inHumidex) {
var hcWord = langHeatWords[0];
// make sure raw variables are converted to C before the compare
var temp = cTempToC(inTemp);
var WindChill = cTempToC(inWindChill);
var Humidex = cTempToC(inHumidex);
if (temp > 32 && Humidex > 29) {
if (Humidex > 54) { return ('<span style="border: solid 1px; color: white; background-color: #BA1928;"> '+langHeatWords[1]+' </span>'); }
if (Humidex > 45) { return ('<span style="border: solid 1px; color: white; background-color: #E02538;"> '+langHeatWords[2]+' </span>'); }
if (Humidex > 39) { return ('<span style="border: solid 1px; color: black; background-color: #E178A1;"> '+langHeatWords[4]+' </span>'); }
if (Humidex > 29) { return ('<span style="border: solid 1px; color: white; background-color: #CC6633;"> '+langHeatWords[6]+' </span>'); }
} else if (WindChill < 16 ) {
if (WindChill < -18) { return ('<span style="border: solid 1px; color: black; background-color: #91ACFF;"> '+langHeatWords[13]+' </span>'); }
if (WindChill < -9) { return ('<span style="border: solid 1px; color: white; background-color: #806AF9;"> '+langHeatWords[12]+' </span>'); }
if (WindChill < -1) { return ('<span style="border: solid 1px; color: white; background-color: #3366FF;"> '+langHeatWords[11]+' </span>'); }
if (WindChill < 8) { return ('<span style="border: solid 1px; color: white; background-color: #6699FF;"> '+langHeatWords[10]+' </span>'); }
if (WindChill < 16) { return ('<span style="border: solid 1px; color: black; background-color: #89B2EA;"> '+langHeatWords[9]+' </span>'); }
} else if (WindChill >= 16 && temp <= 32) {
if (temp < 26) { return ('<span style="border: solid 1px; color: black; background-color: #C6EF8C;"> '+langHeatWords[8]+' </span>'); }
if (temp <= 32) { return ('<span style="border: solid 1px; color: black; background-color: #CC9933;"> '+langHeatWords[7]+' </span>'); }
}
return hcWord;
}
which also uses the word definitions in the script of
Code: Select all
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' );
and those words may be replaced by loading a translation file language-LL.js.
Whew.. the short format of this is the feelslike words use windchill for < 16C, and Humidex for temperatures > 32C.
For temperatures >16 and <26 it shows 'Comfortable', and for temperatures > 26 and <32 it shows 'Warm'
These values correspond to the values/method used by Weather-Display software for it's weather words (and the scripts originated from Weather-Display first) and the method was cloned to all the other weather software sets supported by the templates.
Yes, you can change the thresholds if you like, but do so in both places.