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 4019) - 03 April 2024

Legacy Cumulus 1 release 1.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

Changing Feels Like Values?

Discussion of Ken True's web site templates

Moderator: saratogaWX

User avatar
William Grimsley
Posts: 833
Joined: Thu 22 Sep 2011 5:22 pm
Weather Station: Davis Vantage Vue
Operating System: Windows 7 Home Premium 64-bit
Location: Latitude: 50.70189285 Longitude: -3.30849957
Contact:

Changing Feels Like Values?

Post by William Grimsley »

Hi Ken,

My Feels Like temperature currently shows Heat Index but I want to change it to Apparent Temperature.

I did this in ajaxCUwx.js:

Code: Select all

// FeelsLike
        temp = cTempToC(realtime[54]); // note.. temp in C
		var HC = 0;
		var HCraw = 0;
		switch (useFeelslike) {
		  case 0: 
			  HCraw = realtime[41]; //use HeatIndex
		  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;
  		}
		var HC = cTempToC(HCraw);
        if (temp <= 16.0 ) {
		  feelslike = cTempToC(realtime[24]); //use WindChill
		} else if (temp >=27.0) {
		  feelslike = HC; //use HeatIndex/Humidex/ApparentTemp
		} else {
		  feelslike = temp;   // use temperature
		}
		var feelslike  = Math.round(convertTempC(feelslike));
        set_ajax_obs("ajaxfeelslike",feelslike + uomTemp);
But, nothing happened...

I also tried doing this in ajaxCUwx.js:

Code: Select all

var useFeelslike = 2;        // =0 use HeatIndex, =1 use Humidex, =2 use apparent temperature
But again, nothing happened...

Please help,

Thanks

Will
User avatar
saratogaWX
Posts: 1185
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: Changing Feels Like Values?

Post by saratogaWX »

A small bug in the logic. Change

Code: Select all

        case 0:
           HCraw = realtime[41]; //use HeatIndex
to

Code: Select all

        case 0:
           HCraw = realtime[41]; //use HeatIndex
           break;
User avatar
William Grimsley
Posts: 833
Joined: Thu 22 Sep 2011 5:22 pm
Weather Station: Davis Vantage Vue
Operating System: Windows 7 Home Premium 64-bit
Location: Latitude: 50.70189285 Longitude: -3.30849957
Contact:

Re: Changing Feels Like Values?

Post by William Grimsley »

Hi Ken,

Sorry, that didn't work. I'm wanting to change the Feels Like from Heat Index to Apparent Temperature.

Thanks

Will
User avatar
mcrossley
Posts: 12756
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Changing Feels Like Values?

Post by mcrossley »

The code...

Code: Select all

// FeelsLike
        temp = cTempToC(realtime[54]); // note.. temp in C
You are setting the temp variable to the apparent temp not the real temp

Code: Select all

      var HC = 0;
      var HCraw = 0;
      switch (useFeelslike) {
        case 0: 
           HCraw = realtime[41]; //use HeatIndex
Missing break; as identified by Ken above


Code: Select all

      var HC = cTempToC(HCraw);
        if (temp <= 16.0 ) {
        feelslike = cTempToC(realtime[24]); //use WindChill
      } else if (temp >=27.0) {
        feelslike = HC; //use HeatIndex/Humidex/ApparentTemp
      } else {
        feelslike = temp;   // use temperature
      }
      var feelslike  = Math.round(convertTempC(feelslike));
        set_ajax_obs("ajaxfeelslike",feelslike + uomTem
This checks the current temp and...
if below/= 16C sets feelslike to WindChill
if above/= 27C sets feelslike to Apparent
between 16 & 27 sets feelslike to temp

Then rounds to whole degrees.

So nowhere does it set it to Heat Index? For your current temperatures (2.4) it should be displaying WindChill.

If you really want it to display Apparent ALL the time just comment out that lot and set

feelslike = cTempToC(realtime[54]);
User avatar
William Grimsley
Posts: 833
Joined: Thu 22 Sep 2011 5:22 pm
Weather Station: Davis Vantage Vue
Operating System: Windows 7 Home Premium 64-bit
Location: Latitude: 50.70189285 Longitude: -3.30849957
Contact:

Re: Changing Feels Like Values?

Post by William Grimsley »

Hi Mark,

In ajaxCUwx.js:

Code: Select all

// FeelsLike
        temp = cTempToC(realtime[54]); // note.. temp in C
The same.

Code: Select all

var HC = 0;
      var HCraw = 0;
      switch (useFeelslike) {
        case 0: 
           HCraw = realtime[41]; //use HeatIndex
           break;
The same with "break;" added.
User avatar
saratogaWX
Posts: 1185
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: Changing Feels Like Values?

Post by saratogaWX »

I think you misunderstood what Mark recommended and how the feelslike determination works. Your current code in ajaxCUwx.js has

Code: Select all

        // FeelsLike
        temp = cTempToC(realtime[54]); // 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;
  		}
		var HC = cTempToC(HCraw);
        if (temp <= 16.0 ) {
		  feelslike = cTempToC(realtime[24]); //use WindChill
		} else if (temp >=27.0) {
		  feelslike = HC; //use HeatIndex/Humidex/ApparentTemp
		} else {
		  feelslike = temp;   // use temperature
		}
		var feelslike  = Math.round(convertTempC(feelslike));
        set_ajax_obs("ajaxfeelslike",feelslike + uomTemp);
The first line

Code: Select all

        temp = cTempToC(realtime[54]); // note.. temp in C
should be

Code: Select all

        temp = cTempToC(realtime[2]); // note.. temp in C
to use the actual temperature now as the comparison point.

It is later in the code set

Code: Select all

		var HC = cTempToC(HCraw);
        if (temp <= 16.0 ) {
		  feelslike = cTempToC(realtime[24]); //use WindChill
		} else if (temp >=27.0) {
		  feelslike = HC; //use HeatIndex/Humidex/ApparentTemp
		} else {
		  feelslike = temp;   // use temperature
		}
where the feelslike temperature is set from either the apparenttemp (if current>=27C) or windchill (if current <=16C) or the actual temperature if in between those values. Your quest to use apparenttemp for ALL the feelslike is curious for two reasons:
1) most met offices use WindChill or equivalent for indication of 'how it feels' when the temperatures are below 16C, so that is what the script uses too.
2) does apparent temperature includes any 'wind chill' adjustments or is like a 'heat index' at the high end (above 27C)?
The Cumulus doc for it states:
Apparent temperature is the general term for the perceived outdoor temperature, caused by the combined effects of air temperature, relative humidity and wind speed.

Specifically, in Cumulus, a formula from the BOM is used: http://www.bom.gov.au/info/thermal_stre ... roximation
and the BOM.au site does indicate that Apparent Temperature in their calculations does encompass wind chill effects.

So.. to use it exclusively as the feelslike temperature, you need to change

Code: Select all

		var feelslike  = Math.round(convertTempC(feelslike));
        set_ajax_obs("ajaxfeelslike",feelslike + uomTemp);
to

Code: Select all

		var feelslike  = Math.round(convertTemp(realtime[54]));
        set_ajax_obs("ajaxfeelslike",feelslike + uomTemp);
and feelslike will always use apparent temperature.

When you're making changes to code, it's always best to see ALL the calculations that lead up to the final result.
User avatar
William Grimsley
Posts: 833
Joined: Thu 22 Sep 2011 5:22 pm
Weather Station: Davis Vantage Vue
Operating System: Windows 7 Home Premium 64-bit
Location: Latitude: 50.70189285 Longitude: -3.30849957
Contact:

Re: Changing Feels Like Values?

Post by William Grimsley »

Hi Ken,

WOW! That's alot of info! :D

Ok, I put in your changes and they didn't work.

But, I then changed this code in the ajaxCUwx.js file:

From

Code: Select all

var feelslike  = Math.round(convertTemp(realtime[2]));
        set_ajax_obs("ajaxfeelslike",feelslike + uomTemp);
To

Code: Select all

var feelslike  = Math.round(convertTemp(apparenttemp));
        set_ajax_obs("ajaxfeelslike",feelslike + uomTemp);
Then, it worked! :D

Thanks for your help

Will
User avatar
saratogaWX
Posts: 1185
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: Changing Feels Like Values?

Post by saratogaWX »

D'Oh..

The

Code: Select all

var feelslike  = Math.round(convertTemp(realtime[2]));
should have been

Code: Select all

var feelslike  = Math.round(convertTemp(realtime[54]));
That's what happens when you code on-the-fly and don't inspect quite enough. I fixed the line in my prior post.
BCJKiwi
Posts: 1255
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: Changing Feels Like Values?

Post by BCJKiwi »

@Will,
If the only thing you wanted to do was to change the feelslike to use apparenttemp instead of HeatIndex, there is a option setting in Settings-weather.php (around line 56) for that.

If your changes are more detailed then there are some things to note with the ajax-dashboard page where data items are presented by both the ajax-dashboard.php script, and updated by ajaxCUwx.js. When changing ajax-dashboard (including CU-tags.php), check in ajaxCUwx.js to see if the change needs to be made there as well to keep the presentation of the data item consistent.
User avatar
William Grimsley
Posts: 833
Joined: Thu 22 Sep 2011 5:22 pm
Weather Station: Davis Vantage Vue
Operating System: Windows 7 Home Premium 64-bit
Location: Latitude: 50.70189285 Longitude: -3.30849957
Contact:

Re: Changing Feels Like Values?

Post by William Grimsley »

saratogaWX wrote:D'Oh..

The

Code: Select all

var feelslike  = Math.round(convertTemp(realtime[2]));
should have been

Code: Select all

var feelslike  = Math.round(convertTemp(realtime[54]));
That's what happens when you code on-the-fly and don't inspect quite enough. I fixed the line in my prior post.
Thanks Ken! That worked! :lol:
User avatar
William Grimsley
Posts: 833
Joined: Thu 22 Sep 2011 5:22 pm
Weather Station: Davis Vantage Vue
Operating System: Windows 7 Home Premium 64-bit
Location: Latitude: 50.70189285 Longitude: -3.30849957
Contact:

Re: Changing Feels Like Values?

Post by William Grimsley »

Hi guys,

Sorry, I've gone back to how it was before.

For example, when the feels like is a certain value it changes from Heat Index to Wind Chill...

Thanks for your help,

William
BCJKiwi
Posts: 1255
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: Changing Feels Like Values?

Post by BCJKiwi »

Just a small Q on this for clarification.
in the switch/case statement, should there be a break after the default?
User avatar
steve
Cumulus Author
Posts: 26701
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: Changing Feels Like Values?

Post by steve »

BCJKiwi wrote:in the switch/case statement, should there be a break after the default?
It doesn't matter either way.
Steve
BCJKiwi
Posts: 1255
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: Changing Feels Like Values?

Post by BCJKiwi »

Thanks,
I know it works the way it is without error but none of the texts or examples show it.
Good to know some things in all this website coding are tolerant!
User avatar
William Grimsley
Posts: 833
Joined: Thu 22 Sep 2011 5:22 pm
Weather Station: Davis Vantage Vue
Operating System: Windows 7 Home Premium 64-bit
Location: Latitude: 50.70189285 Longitude: -3.30849957
Contact:

Re: Changing Feels Like Values?

Post by William Grimsley »

Yes, I wondered if there should there be a break after the default, too! :lol:
Post Reply