Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4018) - 28 March 2024

Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014 (a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

Suggestion with tags (comfortable, warm etc)

Discussion of Ken True's web site templates

Moderator: saratogaWX

Post Reply
bort483
Posts: 31
Joined: Tue 19 Sep 2017 9:16 am
Weather Station: Davis Vantage Pro2
Operating System: Ubuntu

Suggestion with tags (comfortable, warm etc)

Post by bort483 »

Hi again. Can I just say a big thank you for your help on my previous two threads - I'm really enjoying this template and it's starting to become a little addictive just thinking about what I should or should not add to it!

Anyway, to the topic at hand; I was wondering if there was any other way (or if it could be added) to define the temp description tags differently. So, in my example, it's 9:51pm, the temp is still 26C with a DP of 22.5C...but the label reads comfortable (presumably since the sun has gone down and the temp has fallen)...it's anything but! On warm summer nights especially near the coast It's fairly common to see dewpoints into the low-mid 20s, those nights (like tonight and tomorrow night) are absolute stinkers, so I was wondering if there's a way to better describe such conditions because atm I feel as though 'comfortable' doesn't describe these conditions well at all. Is there anything else I can do apart from remove the tags?

edit: Maybe even a separate set of tags which is more dependant on the dewpoint, or temp + DP.

Cheers
User avatar
saratogaWX
Posts: 1170
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: Suggestion with tags (comfortable, warm etc)

Post by saratogaWX »

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'&deg;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;">&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;
}
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.
bort483
Posts: 31
Joined: Tue 19 Sep 2017 9:16 am
Weather Station: Davis Vantage Pro2
Operating System: Ubuntu

Re: Suggestion with tags (comfortable, warm etc)

Post by bort483 »

Awesome. Can't wait to play around with this, thank you.
bort483
Posts: 31
Joined: Tue 19 Sep 2017 9:16 am
Weather Station: Davis Vantage Pro2
Operating System: Ubuntu

Re: Suggestion with tags (comfortable, warm etc)

Post by bort483 »

So I tried changing the thresholds in both ajaxcu and cu-defs but no dice. I changed:

} elseif ($TC >=27.0) {
$feelslike = $HC; //use HeatIndex/Humidex/ApparentTemp
} else {

to 24.0. Played around with:

$hcFound = false; (tried setting it to true, not sure if necessary)
if ($TC > 32 and $HC > 29) { (tried lowering $TC (temp).

And changing
if ($HC > 29 and ! $hcFound) { $hcWord = $HeatWords[6]; $hcFound = true; } to [7]

But still no go. I'm still a noob to all this so I'm probably making it more difficult than it actually is...

Cheers
bort483
Posts: 31
Joined: Tue 19 Sep 2017 9:16 am
Weather Station: Davis Vantage Pro2
Operating System: Ubuntu

Re: Suggestion with tags (comfortable, warm etc)

Post by bort483 »

So I've decided I want to change my 'feels like' to the apparent temp. I can see it's worked for the standard CU-defs (before the ajax script kicks in) but can't seem to activate it for the script. I've changed

Code: Select all

var useFeelslike = 0;        // =0 use HeatIndex, =1 use Humidex, =2 use apparent temperature
to

Code: Select all

var useFeelslike = 2;        // =0 use HeatIndex, =1 use Humidex, =2 use apparent temperature
but still nothing yet.

edit: So it's something to do with:

Code: Select all

 // FeelsLike
        temp = cTempToC(realtime[2]); // note.. temp in C
		var HC = 0;
		var HCraw = 0;
		switch (useFeelslike) {
		  case 0: 
			  HCraw = realtime[41]; //use HeatIndex
			  break;
		  case 1: 
			  HCraw = realtime[42]; //use Humidex
			  break;
		  case 2: 
			  HCraw = realtime[54]; //use Apparent Temperature
			  break;
		  default: 
			  HCraw = realtime[41]; //use HeatIndex (default)
			  break;
  		}
I have to figure out which part to change here because at the moment it's using the Heat Index which I don't want.
User avatar
saratogaWX
Posts: 1170
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: Suggestion with tags (comfortable, warm etc)

Post by saratogaWX »

That should work.. maybe your browser has cached the ajaxCUwx.js instead of getting a updated copy. Try using a shift-reload to refresh the browser cache.
bort483
Posts: 31
Joined: Tue 19 Sep 2017 9:16 am
Weather Station: Davis Vantage Pro2
Operating System: Ubuntu

Re: Suggestion with tags (comfortable, warm etc)

Post by bort483 »

Yup it's working now. :)
bort483
Posts: 31
Joined: Tue 19 Sep 2017 9:16 am
Weather Station: Davis Vantage Pro2
Operating System: Ubuntu

Re: Suggestion with tags (comfortable, warm etc)

Post by bort483 »

Sorry to bump this up again, just a quick query; is it possible to use Cumulus' calculated "Feels like" temperature instead of the others (Humidex, Apptemp, Heatindex etc)? I've looked into the code in ajaxCU.php but I don't see any option to use it. Currently using Apptemp but I feel that for my area, Cumulus' Feels Like temp is constantly closer to what I'm looking for.

Code: Select all

var useFeelslike = 2;        // =0 use HeatIndex, =1 use Humidex, =2 use apparent temperature, =3
and

Code: Select all

switch (useFeelslike) {
		  case 0: 
			  HCraw = realtime[41]; //use HeatIndex
			  break;
		  case 1: 
			  HCraw = realtime[42]; //use Humidex
			  break;
		  case 2: 
			  HCraw = realtime[54]; //use Apparent Temperature
			  break;
		  default: 
			  HCraw = realtime[53]; //use HeatIndex (default)
How would I go about adding it?
Post Reply