Author Topic: Forecast Summary issue.  (Read 3417 times)

0 Members and 1 Guest are viewing this topic.

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 946
    • LexMAWeather
Re: Forecast Summary issue.
« Reply #25 on: November 03, 2017, 05:56:11 PM »
I'm getting the exact same thing now so I can dig into it.

I'd ask the cumulus question on that board.
https://lexmaweather.info
On Mastodon: @LexMAWeather@toot.community

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 946
    • LexMAWeather
Re: Forecast Summary issue.
« Reply #26 on: November 03, 2017, 06:17:34 PM »
I think we have it.

Here is the issue: The discussion from your particular weather office is using an "&&" *before* the word SYNOPSIS.  E.g.:

Code: [Select]
000
FXUS63 KIND 032028
AFDIND

Area Forecast Discussion
National Weather Service Indianapolis IN
428 PM EDT Fri Nov 3 2017

.UPDATE...
-- Changed Discussion --
The AVIATION Section has been updated below.
-- End Changed Discussion --


&&

.SYNOPSIS...
Issued at 328 PM EDT Fri Nov 3 2017

So when $start and $end are calculated, $end ends up less than $start and when the substr call is made:

Code: [Select]
$discuss = substr($discussion, $start+0, ($end-1-$start)); // new text (too long to print in cell format)
since $end < $start, it is ignored and you get the whole remainder of the string.

So I modified the code like this:

Code: [Select]
$sstring = 'SYNOPSIS'; // start of synopis quick text
$estring = '&&'; // first divider
$start = strpos($discussion,$sstring); // starting position of where to keep
$synopsis = substr($discussion, $start);  // new - covers case of where && in text before SYNOPSIS
$end = strpos($synopsis,$estring) + $start; // end of where to keep - covers case of where && in text before SYNOPSIS
// $end = strpos($discussion,$estring); // end of where to keep
$discuss = substr($discussion, $start+0, ($end-1-$start)); // new text (too long to print in cell format)

And using that I'm seeing the synopsis clipped out as it should be.

(Yet another piece of evidence that HTML scraping is error-fraught)..
https://lexmaweather.info
On Mastodon: @LexMAWeather@toot.community

Offline mkutche

  • Forecaster
  • *****
  • Posts: 1041
    • GosportWx.com
Re: Forecast Summary issue.
« Reply #27 on: November 03, 2017, 06:26:25 PM »
I think we have it.

Here is the issue: The discussion from your particular weather office is using an "&&" *before* the word SYNOPSIS.  E.g.:

Code: [Select]
000
FXUS63 KIND 032028
AFDIND

Area Forecast Discussion
National Weather Service Indianapolis IN
428 PM EDT Fri Nov 3 2017

.UPDATE...
-- Changed Discussion --
The AVIATION Section has been updated below.
-- End Changed Discussion --


&&

.SYNOPSIS...
Issued at 328 PM EDT Fri Nov 3 2017

So when $start and $end are calculated, $end ends up less than $start and when the substr call is made:

Code: [Select]
$discuss = substr($discussion, $start+0, ($end-1-$start)); // new text (too long to print in cell format)
since $end < $start, it is ignored and you get the whole remainder of the string.

So I modified the code like this:

Code: [Select]
$sstring = 'SYNOPSIS'; // start of synopis quick text
$estring = '&&'; // first divider
$start = strpos($discussion,$sstring); // starting position of where to keep
$synopsis = substr($discussion, $start);  // new - covers case of where && in text before SYNOPSIS
$end = strpos($synopsis,$estring) + $start; // end of where to keep - covers case of where && in text before SYNOPSIS
// $end = strpos($discussion,$estring); // end of where to keep
$discuss = substr($discussion, $start+0, ($end-1-$start)); // new text (too long to print in cell format)

And using that I'm seeing the synopsis clipped out as it should be.

(Yet another piece of evidence that HTML scraping is error-fraught)..

thanks man! Looks great now! :D
Mike K.
Davis Vantage Vue 6250 - CumulusMX (3.21.1-b3205)
Gosport, Indiana
Gosportwx.com twitter.com/GosportINWX
-----------------------------------------------------------

Offline mkutche

  • Forecaster
  • *****
  • Posts: 1041
    • GosportWx.com
Re: Forecast Summary issue.
« Reply #28 on: November 03, 2017, 07:28:52 PM »
Now none of these are wanting to work.. http://gosportwx.com/wxnoaaproducts.php
Mike K.
Davis Vantage Vue 6250 - CumulusMX (3.21.1-b3205)
Gosport, Indiana
Gosportwx.com twitter.com/GosportINWX
-----------------------------------------------------------

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 946
    • LexMAWeather
Re: Forecast Summary issue.
« Reply #29 on: November 03, 2017, 10:19:25 PM »
Probably a similar issue. I can possibly look at it tomorrow.

In the mean time, where did these features come from? forecast-summary wasn't a part of the initial Base-USA I pulled in July, 2015 and I don't see it in the Saratoga add-ons. Same with wxnoaaproducts.php.
https://lexmaweather.info
On Mastodon: @LexMAWeather@toot.community

Offline mkutche

  • Forecaster
  • *****
  • Posts: 1041
    • GosportWx.com
Re: Forecast Summary issue.
« Reply #30 on: November 03, 2017, 10:32:39 PM »
Probably a similar issue. I can possibly look at it tomorrow.

In the mean time, where did these features come from? forecast-summary wasn't a part of the initial Base-USA I pulled in July, 2015 and I don't see it in the Saratoga add-ons. Same with wxnoaaproducts.php.

wxnoaaproducts.php was from https://gwwilkins.org his script and forecast-summary was from http://www.weather-watch.com/smf/index.php?topic=54085.0

i resorted back to my old host since 1and1 is having trouble receiving my cumulus uploads.. been messin with it for 12hrs now.. not sure what could be blocking NWS forecast discussions, ect from uploading it seemed fine on 1and1 *shrugs* maybe Ken or someone could weigh in on it.
Mike K.
Davis Vantage Vue 6250 - CumulusMX (3.21.1-b3205)
Gosport, Indiana
Gosportwx.com twitter.com/GosportINWX
-----------------------------------------------------------

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9244
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Forecast Summary issue.
« Reply #31 on: November 04, 2017, 10:25:15 AM »
Using the older script from the weather-watch.com posting will likely fail -- the fetch method didn't include a User-agent: header (that is now required on almost all NOAA sites).
Try https://saratoga-weather.org/forecast-discussion.php?sce=view V1.05 which does have the User-agent: header in the request and will work on accesses to the http://forecast.weather.gov/ (but will fail in the future when forecast.weather.gov switches to https-only access).  Guess I'll have to update that script also for SSL support.
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 Jasiu

  • Forecaster
  • *****
  • Posts: 946
    • LexMAWeather
Re: Forecast Summary issue.
« Reply #32 on: November 04, 2017, 10:51:14 AM »

wxnoaaproducts.php was from https://gwwilkins.org his script and forecast-summary was from http://www.weather-watch.com/smf/index.php?topic=54085.0


I would go to the sources for those scripts and see what the maintenance plan is. As Ken mentioned, the details for fetching the pages from the NWS have changed and are changing again. If the authors of the scripts are going to keep them alive on their sites, I'm assuming they'll share the code changes with you.
https://lexmaweather.info
On Mastodon: @LexMAWeather@toot.community

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 946
    • LexMAWeather
Re: Forecast Summary issue.
« Reply #33 on: November 04, 2017, 10:58:19 AM »
BTW your NOAA products page seems to be working now.
https://lexmaweather.info
On Mastodon: @LexMAWeather@toot.community

Offline mkutche

  • Forecaster
  • *****
  • Posts: 1041
    • GosportWx.com
Re: Forecast Summary issue.
« Reply #34 on: November 04, 2017, 11:56:18 AM »
Turned out it was my host it needed to reboot it's systems for it to work correct. Raspberry Pi tends to do that sometimes. I'll look into the coding but for the summary itself i'm just using the one from CNYweather.com.
Mike K.
Davis Vantage Vue 6250 - CumulusMX (3.21.1-b3205)
Gosport, Indiana
Gosportwx.com twitter.com/GosportINWX
-----------------------------------------------------------