Author Topic: Possible issue with WUforecast script ?  (Read 3467 times)

0 Members and 1 Guest are viewing this topic.

Offline meteo-saint-brevin

  • Senior Contributor
  • ****
  • Posts: 192
    • Météo Saint-Brevin
Possible issue with WUforecast script ?
« on: April 19, 2014, 01:09:54 PM »
Hi Ken,

I found an anomaly in the forecast obtained with release 2.04 of the script. It happens only between 6PM and midnight here.

To illustrate it, i made a screenshot of the script running in English for the city of Stockholm. But the anomaly is the same when the script is running in French for my city.

http://www.meteo-saint-brevin.fr/wuforecast5/index.php?z=3

During the period from 6PM to midnight, the left icon as well as the first line of datas should concern TONIGHT.

Unfortunately, the first icon and the first line of datas are for SATURDAY, with exactly the same data as for the next TONIGHT icon/line of text.
And below the first icon, you have a LOW TEMP written in RED.

So, please let me know if I am wrong, and i hope you will understand despite my bad level in English.

Best regards,

Marcel
Marcel Le Jeune F6DOW - Saint-Brevin-les-Pins - Pays de la Loire - France
www.meteo-saint-brevin.fr
Vantage Pro2 6163EU - VirtualVP, Cumulus, WeatherLink
Wifi cam Reolink RLC-410W - Blue Iris - Blue Iris tools

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Possible issue with WUforecast script ?
« Reply #1 on: April 19, 2014, 03:36:21 PM »
I think it has to do with when WU updates their forecast (I think daily), so the first icon entry is always 'today' in the JSON.

I had put a bit of commented-out code in the script to see how many hours were left in 'today's forecast and skip it if < number of hours were left.

You might experiment around with changing
Code: [Select]
// next line disabled to match return from older WU forecasts
//    if(count($FCpart['hours']) < 12 and $dnpart == 'day') { continue; }// skip 'day' if not a full day forecast
to
Code: [Select]
// next line disabled to match return from older WU forecasts
    if(count($FCpart['hours']) < 12 and $dnpart == 'day') { continue; }// skip 'day' if not a full day forecast
so the first icon would be 'tonight' if less than 12 hours of forecast are left for today.

Even try  changing the 12 to 6 if that makes sense for your geography.  I really haven't checked to see how WU handles that on their page with JavaScript yet.

Best regards,
Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline meteo-saint-brevin

  • Senior Contributor
  • ****
  • Posts: 192
    • Météo Saint-Brevin
Re: Possible issue with WUforecast script ?
« Reply #2 on: April 19, 2014, 04:26:19 PM »
Thank you very much Ken !

I made the change and it works as expected.
Tomorrow, I'll try to replace 12 with 6 and I will let you know.

Best regards,
Marcel

Marcel Le Jeune F6DOW - Saint-Brevin-les-Pins - Pays de la Loire - France
www.meteo-saint-brevin.fr
Vantage Pro2 6163EU - VirtualVP, Cumulus, WeatherLink
Wifi cam Reolink RLC-410W - Blue Iris - Blue Iris tools

Offline meteo-saint-brevin

  • Senior Contributor
  • ****
  • Posts: 192
    • Météo Saint-Brevin
Re: Possible issue with WUforecast script ?
« Reply #3 on: April 20, 2014, 01:50:40 PM »
Quote
Even try  changing the 12 to 6 if that makes sense for your geography. 

I changed the value from 12 to 6 without any visible change for me. Everything continue to be working fine.
Thank you again for your help.

Marcel
Marcel Le Jeune F6DOW - Saint-Brevin-les-Pins - Pays de la Loire - France
www.meteo-saint-brevin.fr
Vantage Pro2 6163EU - VirtualVP, Cumulus, WeatherLink
Wifi cam Reolink RLC-410W - Blue Iris - Blue Iris tools

Offline meteo-saint-brevin

  • Senior Contributor
  • ****
  • Posts: 192
    • Météo Saint-Brevin
Re: Possible issue with WUforecast script ?
« Reply #4 on: April 21, 2014, 11:51:06 AM »
In fact, Weather Underground changed the forecast not at 6PM but at 4PM.
And so, I had to change back the value from 6 (causing the bug @4PM) to 12.
Marcel
Marcel Le Jeune F6DOW - Saint-Brevin-les-Pins - Pays de la Loire - France
www.meteo-saint-brevin.fr
Vantage Pro2 6163EU - VirtualVP, Cumulus, WeatherLink
Wifi cam Reolink RLC-410W - Blue Iris - Blue Iris tools

Offline BCJKiwi

  • Forecaster
  • *****
  • Posts: 302
    • Silver Acorn Weather - N.Z.
Re: Possible issue with WUforecast script ?
« Reply #5 on: April 22, 2014, 02:21:48 AM »
I have been puzzling over this as well.
1. The issue seems to be that at some time in the afternoon (4pm ?) "Today" changes to the day name e.g. at 2pm it shows Today, some time later it shows "Monday" or "Tuesday" or whatever the current day is.

2. The switch
Code: [Select]
if(count($FCpart['hours']) < 6 and $dnpart == 'day') { continue; }// skip 'day' if not a full day forecast does not affect this but does determine when the first item in the array gets dropped - the day is always present in the downloaded data file.

So have just been testing with enabling/disabling the < 6 switch (it has just gone 6pm here).

To fix this I have added this line;
   
Code: [Select]
if ($WUforecastday[0] <> "Tonight" and $WUforecastday[0] <> "Today") {$WUforecastday[0] = "Today";} here
Code: [Select]
$WUforecastday[$n] = trim($FCpart['summary'][$dnpart]['title']);
if ($WUforecastday[0] <> "Tonight" and $WUforecastday[0] <> "Today") {$WUforecastday[0] = "Today";}
if($doIconv) {$WUforecastday[$n] = iconv($charsetInput,$charsetOutput.'//TRANSLIT',$WUforecastday[$n]);}
This enables the time  ( < 6 or whenever you want the display to drop "Today" and change to "Tonight") to continue to display "Today" instead of "Tuesday".
« Last Edit: April 22, 2014, 11:45:30 PM by BCJKiwi »

Offline Mearns

  • Senior Member
  • **
  • Posts: 61
    • Glenbervie Weather
Re: Possible issue with WUforecast script ?
« Reply #6 on: April 22, 2014, 05:07:47 PM »
I presume this is related to the bug you guys have but I only noticed just now - at 2150 UK local time - that on my home page instead of just the forecast for tonight it also has one for today and they are identical.  It used to be only the tonight forecast that showed at this time of day.  I don't know at what time of day this double format started. I'm on 2.04 of the forecast script.

My forecast page also has the double entry as per Marcel's original post.

Screenshots attached.

I don't have any programming skills but it seems to me that code needs to be added so that when "Today" or the actual day description changes to "Tonight" then other icons/descriptions relating to the current day should be dropped - or am I talking rubbish... :???:
« Last Edit: April 22, 2014, 05:36:57 PM by Mearns »
Tony
Glenbervie, North East Scotland, http://www.glenbervie-weather.org

Vantage Pro 2 - Weather Display 10.37S Build 81

Offline BCJKiwi

  • Forecaster
  • *****
  • Posts: 302
    • Silver Acorn Weather - N.Z.
Re: Possible issue with WUforecast script ?
« Reply #7 on: April 22, 2014, 11:44:57 PM »
My post immediately before yours deals with this issue - well it does for me.

I had not noticed that the two forecasts were the same - don't believe they were yesterday but they sure seem to be today - just checked 6 from different parts of the country and all have Wednesday and Tonight the same (yes its 4pm Wednesday here).

So perhaps you can forget the code line below that changes Wednesday into Today and just change the test for time from < 6 to , < 12.

Since the change to JSON encoding that Ken's ver 2.04 script handles, the daytime forecast is always there in the file that is downloaded from WU.
However it changes from Today to the name of the day some time in the afternoon.

If you apply the two script changes I detail in my last post, Today will always be Today, and the Today will disappear at 18:00 (that is what the < 6 test does - you can fiddle with the number to suit yourself).

Make a copy of your WU-foreast.php script to another name for safety, and edit the one you have with the two changes and the issue should go away.
If it doesn't work then just put the original back.
« Last Edit: April 22, 2014, 11:57:36 PM by BCJKiwi »

Offline BCJKiwi

  • Forecaster
  • *****
  • Posts: 302
    • Silver Acorn Weather - N.Z.
Re: Possible issue with WUforecast script ?
« Reply #8 on: April 23, 2014, 01:33:27 AM »
An hour and a half on and the download file is again showing Today and Tonight with different forecasts.
When will WU get their act together??
 

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Possible issue with WUforecast script ?
« Reply #9 on: April 23, 2014, 11:35:31 AM »
My post immediately before yours deals with this issue - well it does for me.

I had not noticed that the two forecasts were the same - don't believe they were yesterday but they sure seem to be today - just checked 6 from different parts of the country and all have Wednesday and Tonight the same (yes its 4pm Wednesday here).

So perhaps you can forget the code line below that changes Wednesday into Today and just change the test for time from < 6 to , < 12.

Since the change to JSON encoding that Ken's ver 2.04 script handles, the daytime forecast is always there in the file that is downloaded from WU.
However it changes from Today to the name of the day some time in the afternoon.

If you apply the two script changes I detail in my last post, Today will always be Today, and the Today will disappear at 18:00 (that is what the < 6 test does - you can fiddle with the number to suit yourself).

Make a copy of your WU-foreast.php script to another name for safety, and edit the one you have with the two changes and the issue should go away.
If it doesn't work then just put the original back.

The mod you made is very English specific and may not work as anticipated when a non-English WU forecast is selected.  Since the WU-forecast script is available for both standalone and Saratoga template use, I had to rely on WU doing all the translation activity for the day names/text.   So.. if you're only using English, BCJKiwi's mod would work fine -- for non-English, it likely won't work as expected due to non-English word for 'Today'.

I've not quite figured out when WU updates the forecast routinely and whether or not it is 'time-zone' aware (likely not), but I'm browsing the massive JavaScripts that do the WU page generation from the JSON data to see if there's an underlying algorithm for proper display of Today/Tonight.  Meanwhile, the default script just displays what the first entry is in the JSON.

Also, running a page with WU-forecast on it with ?debug=y shows (in the view-source) a bit of analysis about the number of hours/times in the hourly forecast for the first entry in the JSON -- that may help pick the number of hours to use to skip the first entry.

Best regards,
Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Mearns

  • Senior Member
  • **
  • Posts: 61
    • Glenbervie Weather
Re: Possible issue with WUforecast script ?
« Reply #10 on: April 23, 2014, 12:28:38 PM »
Thanks for that BCJKiwi - experimenting with your suggestions for the next 24 hours....
Tony
Glenbervie, North East Scotland, http://www.glenbervie-weather.org

Vantage Pro 2 - Weather Display 10.37S Build 81

Offline meteo-saint-brevin

  • Senior Contributor
  • ****
  • Posts: 192
    • Météo Saint-Brevin
Re: Possible issue with WUforecast script ?
« Reply #11 on: April 23, 2014, 05:51:22 PM »
Thanks to BCJKiwi for this suggestion, but unfortunately, it does not work here.

Actually, the best solution for me is the one from Ken with a value of 8.

Code: [Select]
// next line disabled to match return from older WU forecasts
    if(count($FCpart['hours']) < 8 and $dnpart == 'day') { continue; }// skip 'day' if not a full day forecast
Marcel Le Jeune F6DOW - Saint-Brevin-les-Pins - Pays de la Loire - France
www.meteo-saint-brevin.fr
Vantage Pro2 6163EU - VirtualVP, Cumulus, WeatherLink
Wifi cam Reolink RLC-410W - Blue Iris - Blue Iris tools

Offline Mearns

  • Senior Member
  • **
  • Posts: 61
    • Glenbervie Weather
Re: Possible issue with WUforecast script ?
« Reply #12 on: April 24, 2014, 04:06:20 PM »
I used Ken's solution and tried a value of 7 and that has worked for me over the last 24 hours.
Tony
Glenbervie, North East Scotland, http://www.glenbervie-weather.org

Vantage Pro 2 - Weather Display 10.37S Build 81

Offline BCJKiwi

  • Forecaster
  • *****
  • Posts: 302
    • Silver Acorn Weather - N.Z.
Re: Possible issue with WUforecast script ?
« Reply #13 on: April 24, 2014, 05:25:50 PM »
It seems there is no real consistency to the data coming from WU.
Have been logging the data files every ~ 30 mins and find that there are significant changes in format during the 24 hr period (not a full 24 hours logged yet).

Our NZST offset in New Zealand is currently +12 hours so 5:55 AM GMT is already 5:55 PM the same day in New Zealand. The Today/Tonight/tomorrow/dayname should presumably be set to the local time.
From 5:55 GMT to 8:55 GMT first and second JSON entries were titled Today & Tonight.
At 9:30 through 11:45 this changed to Thursday & Tonight.
At 12:02 GMT it changed to Tomorrow  & Tomorrow Night
At 15:50 GMT it changed to Today & Tonight.

At 20:49 GMT which is 8:49 am in New Zealand it is still showing Today & Tonight.
Just above the Title: Today, there is a section "pretty": which always seems to be "7:00 PM NZST on April 25, 2014" (with the current date but always the same time) regardless of the actual time.

At no time in any of these logged files is the forecast the same for day and night as it was a few days ago so perhaps that was just an anomaly?

I put this out for what it is worth (maybe nothing?) as I don't immediately see how one could reliably decode this into a consistent output format as some of it seems plain wrong - why would it say tomorrow just after midnight (or midday here) without any Today or Tonight?

Offline BCJKiwi

  • Forecaster
  • *****
  • Posts: 302
    • Silver Acorn Weather - N.Z.
Re: Possible issue with WUforecast script ?
« Reply #14 on: April 25, 2014, 02:09:50 AM »
Another day another difference!
Yesterday, the Today/Tonight pattern persisted until 9:30 pm local.
Today it has changed from Today/Tonight to Friday/Tonight somewhere between 5:30pm and 6:00 pm local.

Offline Mearns

  • Senior Member
  • **
  • Posts: 61
    • Glenbervie Weather
Re: Possible issue with WUforecast script ?
« Reply #15 on: April 26, 2014, 11:41:06 AM »
Everything seemed okay for a couple of days after I entered a value of 7 as described previously but just now when I looked at my site at 1640 the forecast is showing Saturday + Tonight and the forecasts are the same....
Tony
Glenbervie, North East Scotland, http://www.glenbervie-weather.org

Vantage Pro 2 - Weather Display 10.37S Build 81

Offline meteo-saint-brevin

  • Senior Contributor
  • ****
  • Posts: 192
    • Météo Saint-Brevin
Re: Possible issue with WUforecast script ?
« Reply #16 on: April 26, 2014, 05:32:20 PM »
I got no problem with 8.
Marcel Le Jeune F6DOW - Saint-Brevin-les-Pins - Pays de la Loire - France
www.meteo-saint-brevin.fr
Vantage Pro2 6163EU - VirtualVP, Cumulus, WeatherLink
Wifi cam Reolink RLC-410W - Blue Iris - Blue Iris tools

Offline Mearns

  • Senior Member
  • **
  • Posts: 61
    • Glenbervie Weather
Re: Possible issue with WUforecast script ?
« Reply #17 on: April 26, 2014, 06:05:35 PM »
At 2305 it's working okay again but I'll try 8 for tomorrow.

Edit: no good with 8 - at some point this afternoon (noticed at 1530 30th) it changed from Today/Tonight to Wednesday/Tonight.
« Last Edit: April 30, 2014, 10:34:44 AM by Mearns »
Tony
Glenbervie, North East Scotland, http://www.glenbervie-weather.org

Vantage Pro 2 - Weather Display 10.37S Build 81

Offline Mearns

  • Senior Member
  • **
  • Posts: 61
    • Glenbervie Weather
Re: Possible issue with WUforecast script ?
« Reply #18 on: June 07, 2014, 03:42:55 AM »
Looks as though WU have changed their format again - the days of the week are missing from the forecasts throughout my website.  Have checked several other sites to make sure it's not just mine.
Tony
Glenbervie, North East Scotland, http://www.glenbervie-weather.org

Vantage Pro 2 - Weather Display 10.37S Build 81

Offline garimba

  • Member
  • *
  • Posts: 18
    • Anaga Weather Canary Islands
Re: Possible issue with WUforecast script ?
« Reply #19 on: June 07, 2014, 06:48:08 AM »
Looks as though WU have changed their format again - the days of the week are missing from the forecasts throughout my website.  Have checked several other sites to make sure it's not just mine.

Same problem

Meteoanaga

Orengon Scientific WMR300

Offline marfanuk

  • Member
  • *
  • Posts: 28
  • Davis Vantage Vue/Meteobridge/Weather34
    • Nantwich Weather
Re: Possible issue with WUforecast script ?
« Reply #20 on: June 07, 2014, 07:10:05 AM »
Same with Me too.  The day above the weather icon is missing.

Offline Stegrie

  • Senior Member
  • **
  • Posts: 97
    • Wetterstation Johanngeorgenstadt
Re: Possible issue with WUforecast script ?
« Reply #21 on: June 07, 2014, 09:00:56 AM »
Here are the same Problem,day s above the weather icon is missing.....

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Possible issue with WUforecast script ?
« Reply #22 on: June 07, 2014, 01:19:15 PM »
WeatherUnderground has tweaked the JSON content (again), so there's an updated WU-forecast.php V2.05 script available now to handle it.

One difference you will note is that the temperatures high/low below the icons will no longer display words for 'High' or 'Low' -- just the forecast temperature in red for daytime and blue for nighttime forecasts.  I am now using just the JSON entries for the daily high/low, and they (WU) provide no translation labels for the words 'High' and 'Low' when languages other than English are used.

Also, they stopped putting in the entries for the forecast periods in the forecast period itself for some forecasts, so the day of the week is used in the language selected (based on lookups in their 'labels part of the JSON based on the ISO8601 date for the forecast period).

Standalone users: http://saratoga-weather.org/scripts-WUforecast.php#WUforecast

Saratoga template users: http://saratoga-weather.org/wxtemplates/updates.php query for (Base-World, Plugin-*, 07-Jun-2014)

Best regards,
Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline marfanuk

  • Member
  • *
  • Posts: 28
  • Davis Vantage Vue/Meteobridge/Weather34
    • Nantwich Weather
Re: Possible issue with WUforecast script ?
« Reply #23 on: June 07, 2014, 02:47:48 PM »
works great again now, thanks for your fast fix :)

Offline meteo-saint-brevin

  • Senior Contributor
  • ****
  • Posts: 192
    • Météo Saint-Brevin
Re: Possible issue with WUforecast script ?
« Reply #24 on: June 07, 2014, 06:57:39 PM »
Thank you very much Ken !

Marcel
Marcel Le Jeune F6DOW - Saint-Brevin-les-Pins - Pays de la Loire - France
www.meteo-saint-brevin.fr
Vantage Pro2 6163EU - VirtualVP, Cumulus, WeatherLink
Wifi cam Reolink RLC-410W - Blue Iris - Blue Iris tools