NWS Forecast and minus temperatures

Post Reply
User avatar
dmgould
Forecaster
Forecaster
Posts: 173
Joined: Sat Aug 26, 2017 2:43 am
Location: Divide, Colorado, USA
Station model: Davis Pro 2 Plus Wireless
Software: Meteobridge
Contact:

NWS Forecast and minus temperatures

Post by dmgould » Wed Dec 26, 2018 12:40 am

Attached images show the NWS Forecast block on my page and the same data on the NWS official page. I couldn't figure out what was going on with the temperature numbers missing and in the wrong place in the block. It looks like there is an issue with displaying negative temperature values in the block version. The negative temperatures don't show and they cause the rest of the numbers to appear off by one space.
forecasterror.JPG
forecasterror.JPG (68.29 KiB) Viewed 5849 times
forecast.JPG
forecast.JPG (48.21 KiB) Viewed 5849 times
Dave G
Image

User avatar
dmgould
Forecaster
Forecaster
Posts: 173
Joined: Sat Aug 26, 2017 2:43 am
Location: Divide, Colorado, USA
Station model: Davis Pro 2 Plus Wireless
Software: Meteobridge
Contact:

Re: NWS Forecast and minus temperatures

Post by dmgould » Wed Dec 26, 2018 9:06 pm

Checking my cache file nwsForcastChace.txt, <p class="temp temp-low">Low: -2 &deg;F is in the correct place with the correct value. It looks like code for that block sets up an array with a counter to line up the images and temperatures to display in the block. When it encounters a negative temperature something happens, maybe to the counter??, and it skips any negative temperatures. Also, this same thing happens in the nwsForecastCustom block. Whatever is happening occurs in both blocks with temperatures below zero.
Dave G
Image

User avatar
Jachym
Site Admin
Site Admin
Posts: 1686
Joined: Fri Aug 18, 2017 10:12 pm
Location: Brno, Czech Republic
Station model: WH1080
Software: Meteobridge
Contact:

Re: NWS Forecast and minus temperatures

Post by Jachym » Wed Dec 26, 2018 9:12 pm

Could be some minor change in their code, since the code uses HTML scraping this would affect it. I will have a look

User avatar
dmgould
Forecaster
Forecaster
Posts: 173
Joined: Sat Aug 26, 2017 2:43 am
Location: Divide, Colorado, USA
Station model: Davis Pro 2 Plus Wireless
Software: Meteobridge
Contact:

Re: NWS Forecast and minus temperatures

Post by dmgould » Wed Dec 26, 2018 10:33 pm

Thanks for looking at this. I also noticed the link to that scraped code is still http. It forwards to https. If you end up making a change to the block you might want to change that link as well. I figured out it's setting up a table for each entry, but I get lost following the array.
Dave G
Image

User avatar
dmgould
Forecaster
Forecaster
Posts: 173
Joined: Sat Aug 26, 2017 2:43 am
Location: Divide, Colorado, USA
Station model: Davis Pro 2 Plus Wireless
Software: Meteobridge
Contact:

Re: NWS Forecast and minus temperatures

Post by dmgould » Fri Dec 28, 2018 3:06 am

I made the follow minor change to line 90 in nwsForecastBlock.php. It seems to have fixed the issue of skipping past a negative (below zero) temperature. It now shows the minus sign and places the temperatures into the correct places. I'll keep track of it for a bit to see if the fix holds. If so, I'll make the same change in customLoader.php in the nwsForecastCustom Block which currently has the same issue with minus temperatures. I also updated the data source for the NWS images to https as that link was forwarding there.

Here are snips of the modified code and the block after the change.
nwsTry.JPG
nwsTry.JPG (17.14 KiB) Viewed 5808 times
forecastTry.JPG
forecastTry.JPG (58.34 KiB) Viewed 5808 times
Dave G
Image

User avatar
MonyMony
Forecaster
Forecaster
Posts: 192
Joined: Sun Aug 20, 2017 12:54 pm
Location: Elkton, Maryland, US
Station model: Davis Pro 2
Software: WeatherCat/Meteobridge
Contact:

Re: NWS Forecast and minus temperatures

Post by MonyMony » Mon Jan 28, 2019 1:21 am

Thanks everyone for the post as I was noticing the same issue.
Image

Post Reply