Author Topic: SOLVED - advforecast2.php returning waaaay too many alerts  (Read 645 times)

0 Members and 1 Guest are viewing this topic.

Offline K6GKM

  • CamWX.com
  • Contributor
  • ***
  • Posts: 125
    • CamWX
SOLVED - advforecast2.php returning waaaay too many alerts
« on: June 07, 2020, 01:15:40 PM »
Hello All,

Wondering if anyone has run into this issue before, and knows how to solve it.  For some reason, my advforecast2.php is returning far too many weather alerts for the zones configured in the pinpoint NWSforecasts array in settings.php.  Seems to be returning alerts for neighboring zones as well.  See screenshot below.  I tried simply disabling the alerts by setting $showZoneWarning to false and letting the links in the menubar do the talking, but that doesn't seem to work either. I tried loading a fresh advforecast2.php, no joy there. Any ideas?

 [ You are not allowed to view attachments ]

Thanks for the input.

-Grant
« Last Edit: June 07, 2020, 03:20:40 PM by Grant Miles »
Grant Miles
Camarillo, CA, USA
Owner/Admin - CamWX.com
SKYWARN Spotter
Station Hardware: Davis Vantage Pro2 Plus w/ 24hr FARS
Station Software: Weather Display, Weather Message, FWI Calculator, StartWatch, with social media & messaging automation using Make.com, Twilio, and Brevo.


Online Jasiu

  • Forecaster
  • *****
  • Posts: 951
    • LexMAWeather
Re: advforecast2.php returning waaaay too many alerts
« Reply #1 on: June 07, 2020, 02:22:08 PM »
Website link?
https://lexmaweather.info
On Mastodon: @LexMAWeather@toot.community

Offline K6GKM

  • CamWX.com
  • Contributor
  • ***
  • Posts: 125
    • CamWX
Re: advforecast2.php returning waaaay too many alerts
« Reply #2 on: June 07, 2020, 02:23:25 PM »
Website link?

Apologies.  Site is located at CamWX.com
Grant Miles
Camarillo, CA, USA
Owner/Admin - CamWX.com
SKYWARN Spotter
Station Hardware: Davis Vantage Pro2 Plus w/ 24hr FARS
Station Software: Weather Display, Weather Message, FWI Calculator, StartWatch, with social media & messaging automation using Make.com, Twilio, and Brevo.


Online Jasiu

  • Forecaster
  • *****
  • Posts: 951
    • LexMAWeather
Re: advforecast2.php returning waaaay too many alerts
« Reply #3 on: June 07, 2020, 02:57:25 PM »
Yeah, OK, this did ring a bell. The code uses the API's alerts / point endpoint to fetch alerts. E.g.

  https://api.weather.gov/alerts?active=1&point=34.2317,-119.0427

for your location. I noticed a while back that this will sometimes return alerts that are not for either my zone or county (I believe the extras are for other zones in my county, but I really don't want those in this place). So I added code to check to make sure that one of the local codes was included.

So where Ken's code checks for:

Code: [Select]
      if (time() < $expireUTC) {

I do this:

Code: [Select]
      if ( (time() < $expireUTC)  &&
        ( (in_array($META["forecastZone"], $ALERT["geocode"]["UGC"]) ) ||
          (in_array($META["countyZone"], $ALERT["geocode"]["UGC"]) ) ) )
      {

It occurs to me that I should also add "fireWeatherZone" to this. It didn't originally because our fire zones == the forecast zones, but that isn't always true.

I also added on my site the ability to grab forecasts from elsewhere, so if you go to:

  https://lexmaweather.info/forecast.php?lat=34.2317&long=-119.0427

you'll see this in action, showing only the Heat Advisory (if you check really soon).

I think I mentioned all this to Ken when I was futzing with it, but I'm old and don't remember everything.  :lol:
https://lexmaweather.info
On Mastodon: @LexMAWeather@toot.community

Offline K6GKM

  • CamWX.com
  • Contributor
  • ***
  • Posts: 125
    • CamWX
Re: advforecast2.php returning waaaay too many alerts
« Reply #4 on: June 07, 2020, 03:09:12 PM »
Boom!  Perfect.  As you predicted, it's not supporting the fire weather zone.  As you pointed out, my NWSAlertCodes array does have to list both forecast zone and fire weather zone due to the NWS' practice of differentiating fire weather zones (CAZ240) from forecast zones (CAZ040) in my area.  I'm not overly concerned about it, any RFW's get covered by the NWS Alerts script on the index.  It'd be nice, but it's not something I'm going to lose a bunch of sleep over. (Thats not to say I wouldn't turn down a fix if you happen to come up with one. :-) )


Thanks again!

-Grant
Grant Miles
Camarillo, CA, USA
Owner/Admin - CamWX.com
SKYWARN Spotter
Station Hardware: Davis Vantage Pro2 Plus w/ 24hr FARS
Station Software: Weather Display, Weather Message, FWI Calculator, StartWatch, with social media & messaging automation using Make.com, Twilio, and Brevo.


Online Jasiu

  • Forecaster
  • *****
  • Posts: 951
    • LexMAWeather
Re: advforecast2.php returning waaaay too many alerts
« Reply #5 on: June 07, 2020, 03:14:23 PM »
I just added the one line to my code...

Code: [Select]
      if ( (time() < $expireUTC)  &&
        ( (in_array($META["forecastZone"], $ALERT["geocode"]["UGC"]) ) ||
          (in_array($META["fireWeatherZone"], $ALERT["geocode"]["UGC"]) ) ||
          (in_array($META["countyZone"], $ALERT["geocode"]["UGC"]) ) ) )
      {

So if you substitute that for the line in Ken's code I noted upstream, that should make it so that the forecast script only shows alerts that explicitly include your zone code, fire code, or county code.
https://lexmaweather.info
On Mastodon: @LexMAWeather@toot.community

Offline K6GKM

  • CamWX.com
  • Contributor
  • ***
  • Posts: 125
    • CamWX
Re: advforecast2.php returning waaaay too many alerts
« Reply #6 on: June 07, 2020, 03:17:24 PM »
Jasiu, you're a gentleman.  Thanks so much for your help. 

-Grant
Grant Miles
Camarillo, CA, USA
Owner/Admin - CamWX.com
SKYWARN Spotter
Station Hardware: Davis Vantage Pro2 Plus w/ 24hr FARS
Station Software: Weather Display, Weather Message, FWI Calculator, StartWatch, with social media & messaging automation using Make.com, Twilio, and Brevo.


Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9297
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: SOLVED - advforecast2.php returning waaaay too many alerts
« Reply #7 on: June 07, 2020, 07:30:11 PM »
Thank you, Jasiu!  I'll be doing an update with that fix incorporated...

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