WXforum.net

Web Weather => Weather Website PHP/AJAX scripting => Topic started by: gwwilk on March 14, 2016, 03:42:46 PM

Title: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: gwwilk on March 14, 2016, 03:42:46 PM
With Tom at My Mishawaka Weather's assistance I've combined a number of selected NOAA-NWS Forecast Office Text Products into one script (http://www.gwwilkins.org/wxnoaaproducts.php).  The script includes Forecast Discussions, Public Information Statements, Hazardous Weather Outlooks, etc.

No attempt has been made to include more than the latest of any of these text products because the link at the bottom of each page will display the relevant page where old products are available.

The settings are few:
Code: [Select]
/******************************* Settings *********************************/
$divWidth = 656; // Narrow style width
// Enter Default Station
$wfo = "OAX";
$product = 'HWO'; // Default NWS Product to display
/* These are the products available in this script
    "AFD" - Forecast Discussion
    "CF6" - WFO Monthly Preliminary Report
    "FFS" - Flash Flood Statement
    "FLW" - Flood Warning
    "HWO" - Hazardous Weather Outlook
    "HYD" - Daily Hydrometeorology
    "LSR" - Local Storm Report
    "MAP" - Mean Areal Precipitation
    "NOW" - Short Term Forecast
    "NPW" - Non-Precip. Wrn./Wtch./Adv.
    "PNS" - Public Information Statement
    "REC" - Recreational Forecast
    "RWS" - Regional Weather Summary
    "WSW" - Winter Storm Wrn./Wtch./Adv."
*/
// Enter the path to the map file. Un-comment only 1 line out of the 2 lines below.
// $mappath = './';            // map is in the same folder as this file
$mapPath = './images/';  // map is in the images folder. Change images  to the folder where the map is located
$leftMargin = 60; // Set left margin of text output here
/***************************** End Settings *******************************/

The '$leftMargin' parameter affects only the text product appearance, and enables fine-tuning the display to your taste.  I just didn't like the text crowded up on the left with no margin, so this solves that problem.

The map and the option list are both functional, and the option list defaults to the current selection.  This makes it easier to use the option list to select nearby WFO's rather than always scrolling from the top of the list.

Version 1, while functional, omitted the $mapPath and $leftMargin Settings.

Naturally, product availability varies with seasons, forecast office, and weather.

I should warn you that the products are cached, each product seen for each site visited.  Once in a while a cleanup of old cache files in your cache directory (set to './cache/' if not in a template - see line 580 in 'inc-show-wfo-products.php' V2c) would be advisable.

Edit 2016 March 16 & 17:  Tulsa, OK was omitted in versions prior to Version 2d (http://www.wxforum.net/index.php?topic=28967.msg282799#msg282799).  Version 2c contained a couple more bugs.  If you use this script please update to Version 2d.
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: mikeym2m on March 15, 2016, 10:17:16 AM
Another nice script Jerry Thanks

For some reason not all the weather offices will show up on the clickable map - ie Binghamton NY and State College PA aren't clickable, but Pittsburgh PA is - any ideas?

Thanks

Cheers

MikeyM
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: gwwilk on March 15, 2016, 10:36:25 AM
Another nice script Jerry Thanks

For some reason not all the weather offices will show up on the clickable map - ie Binghamton NY and State College PA aren't clickable, but Pittsburgh PA is - any ideas?

Thanks

Cheers

MikeyM
The map coordinate polygons loaded from your site's 'inc-wfo-show-products.php (http://mikeymsweather.com/inc-show-wfo-products.php?sce=view)' are incomplete when compared with mine (http://gwwilkins.org/inc-show-wfo-products.php?sce=view), i.e. many, many are missing.  Try saving mine (CTRL-s) without the '.txt' and then re-upload 'inc-show-wfo-products.php' again.
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: mikeym2m on March 15, 2016, 10:56:57 AM
Jerry

Thanks that was a quick fix. I'm not sure why the "inc" didn't have all the map coordinates  :?


Thanks again for another very nice script.   =D>

Cheers

 :grin:

MikeyM
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: jgillett on March 16, 2016, 02:11:44 AM
Jerry, thanks for yet another good script. But... mine's not happy with PSR as the default wfo setting. Always displays Omaha (but I can select Phoenix from the dropdown).

Thanks.
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: wvdkuil on March 16, 2016, 04:49:17 AM
Very fine script, easy to integrate. Two small changes for the next version:

Line 45/46 in wxnoaaproductsV2.php are not needed and should be commented / removed.
For stand-alone use = non-Saratoga environments, they result in a 500 error.
For Saratoga the same lines are also at 64/65.

The $mapPath setting in line 100/101 in wxnoaaproductsV2.php has no effect as it is replaced by line 24 in inc-show-wfo-products.php.
So stand-alone users should comment that line also.
===
I added the script inside an iframe and looks fine to me. http://weather-template.nl/weather28/?p=ws_wfo&lang=en&wp=WS 
Do not look at colors and backgrounds , it is a demo site.

Wim
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: gwwilk on March 16, 2016, 10:11:35 AM
John, I think your problem may have been caused by the debugging code at the start of the includes script.  If the revisions to the attached V2b doesn't solve the problem, I've included instructions to comment out this debugging code in 'inc-show-wfo-products.php' by removing one slash.  This debugging code may also have caused some confusion for you, Wim.

I must confess I never tested the Stand Alone (http://www.gwwilkins.org/wxnoaaproducts-SA.php) code, Wim. :oops:  You're absolutely right about those two lines at 45/46.  They have been removed in Version 2a attached.  There was also a problem with the centering of the NWS link at the bottom of the Stand Alone page, and this has been corrected as well. 

I've omitted the display of previous versions of these NWS products because of frequent redundant entries that differ only by time posted.  These are easily accessed by using the NWS link at the bottom of the page.  I've also included a hint about the best way to view these past versions.

Edit 2016 March 16:  Tulsa, OK was omitted in versions prior to Version 2c which still contained a couple of bugs.  Version 2d (http://www.wxforum.net/index.php?topic=28967.msg282799#msg282799) fixes those bugs as well.
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: mikeym2m on March 16, 2016, 10:37:08 AM
Jerry

Thanks for the update (V2b)!

Great script!

Cheers

 :grin:

MikeyM
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: gwwilk on March 16, 2016, 11:35:13 AM
And we have another error in the script.  I somehow omitted Tulsa, OK from the list of WFO's.  Version 2c corrected this problem, but Version 2d (http://www.wxforum.net/index.php?topic=28967.msg282799#msg282799) corrects a couple of other bugs.

If you use this script, I would urge you to update to Version 2d.
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: Otis on March 16, 2016, 01:08:17 PM
Nice job on this Jerry, I like this comprehensive approach.
Thanks for your continued efforts and contributions.
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: jgillett on March 16, 2016, 05:14:07 PM
2c up and working.

Thanks, Jerry.
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: Breezy on March 17, 2016, 10:30:15 AM
Hi Jerry,

Another very nice script. One problem that I have is the WFO keeps defaulting to Omaha. I've set mine to "ALY". It must be a Peyton Manning thing.

http://indiantrailweather.com/wxnoaaproducts.php

Great job ...  =D>

Jeff
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: mikeym2m on March 17, 2016, 10:35:27 AM
HI Jeff

You have to set "ALY" both in the wxnoaaproducts.php" and the "inc" script. Found that the hard why myself hee hee

Cheers

 :grin:

MikeyM
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: Breezy on March 17, 2016, 10:42:55 AM
Duh ............ Good morning Mike ! I missed that one.  :oops:    Thanks.  \:D/    It's a sunny day in Hessville ...

Have a nice day.

Jeff
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: gwwilk on March 17, 2016, 10:45:32 AM
You really only need to set it on line 79 in 'Settings' in 'wxnoaaproducts.php' because the '$wfo' setting in 'inc-show-wfo-products.php' line 23 is only used for debugging when 'inc-show-wfo-products.php' is run alone in which case neither '$wfo' nor '$product' will be set by '$_POST...' or on 'wxnoaaproducts.php' script startup.
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: Breezy on March 17, 2016, 10:52:47 AM
Jerry, thanks for the clarification and explanation ... 

 :-)

Jeff
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: mikeym2m on March 17, 2016, 10:57:53 AM
Thanks Jerry

MikeyM
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: ValentineWeather on March 17, 2016, 11:24:34 AM
Jerry any idea why map doesn't show? http://www.valentinenebraska.net/wxnoaaproducts.php
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: wvdkuil on March 17, 2016, 11:29:25 AM
Jerry any idea why map doesn't show? http://www.valentinenebraska.net/wxnoaaproducts.php
It is looking for the map in   http://www.valentinenebraska.net/images/cwa2.png
But the response is: Failed to load resource: the server responded with a status of 404 (Not Found)
The map is in http://www.valentinenebraska.net/cwa2.png
So either move the map to that folder are adept the setting in wxnoaaproducts.php
Code: [Select]
$mapPath = './';  // map is in the images folder. Change  images  to the folder where the map is locatedWim
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: ValentineWeather on March 17, 2016, 11:32:28 AM
Thank you.
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: ValentineWeather on March 17, 2016, 11:47:57 AM
Jerry thanks for the script.
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: jgillett on March 17, 2016, 12:19:09 PM
You really only need to set it on line 79 in 'Settings' in 'wxnoaaproducts.php' because the '$wfo' setting in 'inc-show-wfo-products.php' line 23 is only used for debugging when 'inc-show-wfo-products.php' is run alone in which case neither '$wfo' nor '$product' will be set by '$_POST...' or on 'wxnoaaproducts.php' script startup.
Jerry, with all due respect (honest!), I have found if it's not set in both scripts it (at least mine) will not show what I want as the default, in my case PSR.
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: ValentineWeather on March 17, 2016, 12:32:01 PM
I had to set mine in both places also. No biggie, easy enough it wanted to use Omaha otherwise.
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: Otis on March 17, 2016, 12:42:38 PM
Me too, had to set in both places - no big deal.
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: jgillett on March 17, 2016, 12:46:24 PM
Agreed, no big deal. Just had to get my 2¢ in...   :grin:
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: Otis on March 17, 2016, 12:46:57 PM
 :lol:
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: gus on March 17, 2016, 12:55:43 PM
 :grin:
Jerry had the quick fix is in the instructions

/************************** Version 2c 20160316 **************************/
/* The following code sets defaults for testing only.
    If these defaults adversely affect your production code, comment out
       this section by removing the slash behind this asterisk ->*/
if (!isset($_POST['wfo'])&&!isset($_POST['product'])) {
   $wfo='oax';
   $divWidth = '656';         // They are used for testing only
   $product = "HWO";
  $leftMargin = 50; // Left margin to display text
  $mapPath = './image/';
}
/* End of testing code defaults and section to comment out */
 
Per the instructions...
All is good if the slash behind the asterisk is removed.

Gus
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: gwwilk on March 17, 2016, 01:40:27 PM
 :oops: My code was faulty in a couple of places.  Firstly, I never assured that the default wfo, which I had set as "OAX", was moved to lower case, which it needs to be.  Secondly, my logic was faulty for entering the testing defaults in 'inc-show-wfo-products.php'.  This combination of errors allowed the script to run, but not really as desired.

I think these problems have been fixed in Version 2d.  The 'inc-show-wfo-products.php' $wfo is set to 'lix', New Orleans.
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: jgillett on March 17, 2016, 02:07:41 PM
2d working fine with just the one wfo setting.

Tank U!  :roll:
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: ValentineWeather on February 27, 2018, 04:55:07 PM
Just heads up these are no longer working with changes made today. wxnoaadiscuss.php
wxnoaaproducts.php
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: saratogaWX on February 27, 2018, 05:05:39 PM
He can update with V1.06 of forecast-discussion.php 'guts' and it should work again.

https://saratoga-weather.org/scripts-NWSmisc.php
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: gwwilk on February 27, 2018, 06:30:20 PM
I'm off to a brass group rehearsal, and won't have time to do this right now.  Later...
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: gwwilk on February 27, 2018, 10:11:11 PM
Thanks to Ken, this script has been updated (https://www.gwwilkins.org/wxnoaaproducts.php).  You can download it here (https://www.gwwilkins.org/gwwScripts.php).

EDIT 2018 Feb 28:
CAUTION:  To get updated texts you may need to delete the related WFO-tagged file(s) from your cache directory!

Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: jgillett on February 27, 2018, 10:35:25 PM
Thanks, Ken and Jerry. Working nicely at http://tiggrweather.net/wxnoaaproducts.php.

I don't have a WFO directory but all seems well.
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: jgillett on February 28, 2018, 01:35:07 AM
My 'WFO' directory is './cache/WFO'.  You should have a similar one.
That's exactly where I looked but tain't there.
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: gwwilk on February 28, 2018, 07:58:25 AM
My 'WFO' directory is './cache/WFO'.  You should have a similar one.
That's exactly where I looked but tain't there.
Now it makes sense to me! #-o When testing the script's includes file my './cache/WFO' directory is used, but not when the main script is run because that setting is superseded by the Settings cache declaration.  The possibly hundreds of cache files generated by this script will get dumped into your normal cache directory.  Purging that directory of the WFO-tagged .txt files is a little more difficult.

Sorry for the confusion. (Message removed.)
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: jgillett on February 28, 2018, 12:31:16 PM
Now it makes sense to me! #-o When testing the script's includes file my './cache/WFO' directory is used, but not when the main script is run because that setting is superseded by the Settings cache declaration.  The possibly hundreds of cache files generated by this script will get dumped into your normal cache directory.  Purging that directory of the WFO-tagged .txt files is a little more difficult.
I had one -WFO file in /cache/ last night but it's gone today.
Sorry for the confusion. (Message removed.)
Not a problem. Mine seems to be working and that's the bottom line.

Thanks.
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: W3DRM on March 02, 2018, 02:37:04 PM
Great new addition to the menus! Had to add some sub-folders to the cache folder to get it to run without errors. The sub-folders I added were as follows:
NOTE: Some of these sub-folders have periods (.) and spaces between the words. They must be exactly as shown above.
I found them by selecting each of the products one at a time and watching for errors on the resulting page.
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: gwwilk on March 17, 2018, 10:27:48 AM
Tom Abell pointed out that Honolulu, HI was incorrectly identified as 'hnl' rather than 'hfo' in the script.  This has been corrected in the latest zip found on my site (https://www.gwwilkins.org/gwwScripts.php).

Thanks, Tom!
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: jgillett on March 17, 2018, 11:59:03 AM
Thanks, Jerry. It's a great combo of features.
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: gwwilk on June 25, 2018, 05:19:15 PM
At the urging of Thomas Abell I've modified the script to use a different font in the text display (https://www.gwwilkins.org/wxnoaaproducts.php).  The trick was to change the html <pre> tag by inserting a 'pre' style in the main script, 'wxnoaaproducts.php' thus overriding the <pre> tag.

In context, this is the current style with one alternative commented out:
Code: [Select]
<style type="text/css">
div.center {
width:100%;
margin-left: auto;
margin-right: auto;
}
pre { /* Choose a font, or insert your own to display the text products */
/* font: 15px arial, sans-serif; */
font-style: italic; font-size: 15px; font-family: Comic Sans MS, Cursive, Sans-Serif;
}
</style>
</head>
<body>

This is the only modification to the script in addition to the version date, which is available on my scripts page (https://www.gwwilkins.org/gwwScripts.php).
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: gwwilk on July 11, 2018, 09:05:19 AM
I noticed when loading this script (https://www.gwwilkins.org/wxnoaaproducts.php) this morning that the area polygons on the US Map stopped aligning, and I wondered why.  It turns out that Chrome stopped recognizing the height and width of the US Map when specified as follows:
Code: [Select]
<img src="<?php echo $mapPath ?>cwa2.png" alt="County Warning Area MAP" usemap="#cwamap" height="410" width="535" />
Instead Chrome now requires a CSS style to specify the map dimensions:
Code: [Select]
<img src="<?php echo $mapPath ?>cwa2.png" alt="County Warning Area MAP" usemap="#cwamap" style="width:535px; height:410px"/>
An updated zip (https://www.gwwilkins.org/gwwScripts.php) is available.
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: gwwilk on November 27, 2018, 09:37:15 AM
A user has experienced problems with this script because of a jQuery conflict.  Attached is a version of wxnoaaproducts.php, wxnoaaproducts-jq.php, that should avoid this difficulty.  You can use it whether or not there's a jQuery conflict on the page that contains the script.

Edit 2019 March 9:  This script has been updated to include the missing 'Paducah, KY' entry.
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: gwwilk on March 09, 2019, 12:20:34 PM
I discovered today while working on an addition to this script that Paducah, KY was missing!

This has been corrected in an updated wxnoaaproducts (https://www.gwwilkins.org/wxnoaaproducts.php).zip on my scripts page (https://www.gwwilkins.org/gwwScripts.php).  The -jq version (https://www.gwwilkins.org/wxnoaaproducts-jq.php) has also been updated and is included.

There's also an experimental version with a Graphical Enhanced Hazardous Weather Outlook (EHWO) that some WFO's are creating.  This version isn't yet on my menu system because these graphics aren't yet operational, but it can be viewed from here and from my scripts page.  Oddly neither Tom Abell nor myself can figure out how to detect whether or not these graphical images are on any given WFO's site.  Every attempt returns '403 Forbidden'!  Hence the script can't generate a separate message informing the viewer that the graphic is missing.  Only the 'alt="..."' message appears.  The includes file is still littered with these failed attempts all commented out. :-(  This script isn't available any more.

It turns out that I didn't appreciate the full complexity of the EHWO display.  An iframe displays it best so that the interactive graphics can be accessed because these are a key component of this project/product.  Accordingly, I've placed a site-specific iframed version of the EHWO's (https://www.gwwilkins.org/wxEHWO-byWFO.php) on my site with the script available on my scripts page (https://www.gwwilkins.org/gwwScripts.php).  The script must be set to your appropriate WFO, and I've included a link to the NWS's PDF that lists all participating WFO's.

EDIT: 2019 March 9, 4:45 pm CST
The iframe dimensions in the iframed script don't fit lots of the participating WFO's pages!  Manipulating the CSS and page width can help with this problem, but it's not a trivial exercise.  Perhaps the best solution for now in these cases is a link to the WFO's EHWO page?  Given time to mess around, I might be able to devise a solution, but it would be a tedious and time-consuming job.
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: rrrick8 on April 06, 2019, 09:25:52 AM
Jerry, I wouldn't mind tinkering around a bit with the script version that has the drop down wfo select array like you have on your site.
Can you pm that file to me if you don't mind. My particular wfo doesn't use it yet but a couple surrounding ones do so would like to experiment a bit with it.

Thanks,
Rick
 
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: gwwilk on April 06, 2019, 09:49:45 AM
Jerry, I wouldn't ming tinkering around a bit with the script version that has the drop down wfo select array like you have on your site.
Can you pm that file to me if you don't mind. My particular wfo doesn't use it yet but a couple surrounding ones do so would like to experiment a bit with it.

Thanks,
Rick
I've uploaded a zip of the selectable wxEHWO-byWFO script to my scripts page (https://www.gwwilkins.org/gwwScripts.php) so that anyone who's interested might play around with it as well.  This supersedes the prior single WFO version.
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: rrrick8 on April 06, 2019, 09:52:12 AM
Thanks Jerry. I like the concept and hope more offices, including mine (ILX) use it.
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: gwwilk on January 30, 2021, 08:44:17 AM
I've added the Regional Min/Max Temperature and Precipitation Table to the script.  This is a very informative table that includes some local snow depths, not just snow depths as measured at the WFO site.

As usual, the updated script is available on my scripts page (https://www.gwwilkins.org/gwwScripts.php) as 'wxnoaaproducts.zip'.
Title: Re: Unified Script to Display Select NOAA-NWS Forecast Office Text Products
Post by: mikeym2m on January 30, 2021, 09:02:51 AM
Thanks Jerry   [tup]

MikeyM