Author Topic: NaN for Barometer  (Read 364 times)

0 Members and 1 Guest are viewing this topic.

Offline Hugh Whalen

  • Member
  • *
  • Posts: 18
NaN for Barometer
« on: September 09, 2021, 09:14:53 AM »
I am setting up a new Weather Site and I am using the Saratoga templates. The site is www.flowers-cove.ca/wxindex.php

Most everything is working except for the Barometer.  It shows NaN, which I assume means Not a Number.

I am using the Base Canada template and WeatherCat software.

Anybody have any idea what is going on here? [ You are not allowed to view attachments ]

Offline Hugh Whalen

  • Member
  • *
  • Posts: 18
Re: NaN for Barometer
« Reply #1 on: September 09, 2021, 12:02:03 PM »
I have been trying to figure out what is going on here.

If I look at the WCT_realtime.txt file on the server it shows some strange things. The current pressure is 1,012.0

In fact, all the pressure readings (min today, max today, etc) are recorded as x,xxx.x That is, there is a comma there. Shouldn't it be xxxx.x eg no comma?

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 885
    • LexMAWeather
Re: NaN for Barometer
« Reply #2 on: September 09, 2021, 12:37:40 PM »
The javascript code (ajaxWCTwx.js) expects no comma in the data. You hit the multiply by 1.0 below as your UOM is "mb" and that is what results in the NaN.

Code: [Select]
function cBaroToHPA ( rawbaro ) {
// convert input pressure to hPa if need be    
var cpat=/mb|hpa/i;
if(cpat.test(rBaroUOM)) { // baro already in mb/hPa
return rawbaro * 1.0;
} else { // convert inHg to mb/hPa
return rawbaro * 33.86;
}
   
}


Offline Jasiu

  • Forecaster
  • *****
  • Posts: 885
    • LexMAWeather
Re: NaN for Barometer
« Reply #3 on: September 09, 2021, 12:39:20 PM »
Also note on http://www.flowers-cove.ca/wxstatus.php that the realtime file status is Not Current.

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8645
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: NaN for Barometer
« Reply #4 on: September 09, 2021, 12:55:01 PM »
It appears that your locale settings on your mac has 'use commas in thousands' displays for numbers.  You need to turn that off so the barometer will show without embedded commas.  That should fix the issue.

example in WCTtags.php
Quote
STAT:PRESSURE:CURRENT|1,011.7|// Current Pressure:|:
STAT:PRESSURE:DELTA1|-0.4|// Current Pressure change over 1 hour.:|:
STAT:PRESSURE:DELTA24|-2.4|// Current Pressure change over 24 hours.:|:
STAT:PRESSURE:24HRSAGO|1,014.2|// Current Pressure value 24 hours ago.:|:
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Hugh Whalen

  • Member
  • *
  • Posts: 18
Re: NaN for Barometer
« Reply #5 on: September 09, 2021, 01:05:40 PM »
That fixed the problem. Thank you very much for your help.

Hugh

 

anything