WXforum.net

Web Weather => Weather Website PHP/AJAX scripting => Topic started by: MackerelSky on May 29, 2019, 11:03:38 AM

Title: Question about the alerts and forecasts
Post by: MackerelSky on May 29, 2019, 11:03:38 AM
Hi Ken and All,

I did a search, prolly not long enough, but it's bugged me for a while now.

Living in the mountains of NW Pa., a 'Hazardous Weather Outlook' from our NWS office in State College Pa. always precedes a watch or a warning, and contains some helpful info for upcoming weather.

So where I'm heading is that the advforecast2.php script picks up the outlook, but my top warning for the home page nor the new Curly's forecast do. I was wondering if someone could point me in the right direction that I could do some fiddling and try an get them involved? Zone and County are all pulled from the Settings.php.

My home page then
advforecast2.php page https://www.mckeanweather.com/mwforecast.php
Curly's forecast https://www.mckeanweather.com/mwCforecast.php

I've included a screen grab of all three taken at the same time.

Thanks for having a look
Brad
Title: Re: Question about the alerts and forecasts
Post by: Jasiu on May 29, 2019, 11:54:55 AM
The short answer is that the Hazardous Weather Outlook link appears in the HTML page that is scraped for the old version of the forecast but isn't included in the JSON forecast data. So that's why it doesn't appear.

To duplicate that feature in the new script, the code would have to check to see if there is an active HWO for the office that issues the forecast. That information under the new API is at:

   https://api.weather.gov/products/types/HWO/locations/[office code]

and a second fetch is then necessary to get the actual HWO text. That fetch would only have to be done if the latest HWO listed in the results from the first fetch is current. What "current" means isn't clear to me as there is an "issuance time" for each outlook but no expiration time. Maybe if within 24 hours??
Title: Re: Question about the alerts and forecasts
Post by: MackerelSky on May 29, 2019, 12:16:53 PM
Thanks for the response Jasiu,

https://api.weather.gov/products/types/HWO/locations/CTP shows the last 7 HWO's, with the current one on the top as seen by the date and time, 2019-05-29T07:36:00+00:00

Current text can be found at https://forecast.weather.gov/product.php?site=NWS&issuedby=CTP&product=HWO
Edit: Actual HWO is at this URL. https://forecast.weather.gov/showsigwx.php?warnzone=PAZ005&warncounty=PAC083&firewxzone=PAZ005&local_place1=Smethport+PA&product1=Hazardous+Weather+Outlook#.XO6y_hZKjb0
Now I just have to put the two together somehow? Not the sharpest nail in the pouch when it comes to the API's, but I'll give it a look and see what I can come up with.

Brad
Title: Re: Question about the alerts and forecasts
Post by: AWL on May 29, 2019, 01:00:36 PM
Don't know if this is any help but you can modify Ken's forecast discussion script to grab the HWO. Never tried to combine it with any other script.

Doug
Title: Re: Question about the alerts and forecasts
Post by: MackerelSky on May 29, 2019, 03:01:52 PM
Don't know if this is any help but you can modify Ken's forecast discussion script to grab the HWO. Never tried to combine it with any other script.

Doug
Thanks Doug,

Stopped working on it to take the better 2/3 to lunch. Squall line came thru with tornado watches/warnings, thankfully no damage, but now all alerts and HWO's are cancelled.
Will have to wait until later tonight or tomorrow when the next round of storms approach.

Thanks Again...
Brad