WXforum.net
Web Weather => Weather Website PHP/AJAX scripting => Topic started 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:/******************************* 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.
-
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
-
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.
-
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
-
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.
-
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
-
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.
-
Jerry
Thanks for the update (V2b)!
Great script!
Cheers
:grin:
MikeyM
-
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.
-
Nice job on this Jerry, I like this comprehensive approach.
Thanks for your continued efforts and contributions.
-
2c up and working.
Thanks, Jerry.
-
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
-
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
-
Duh ............ Good morning Mike ! I missed that one. :oops: Thanks. \:D/ It's a sunny day in Hessville ...
Have a nice day.
Jeff
-
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, thanks for the clarification and explanation ...
:-)
Jeff
-
Thanks Jerry
MikeyM
-
Jerry any idea why map doesn't show? http://www.valentinenebraska.net/wxnoaaproducts.php
-
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$mapPath = './'; // map is in the images folder. Change images to the folder where the map is located
Wim
-
Thank you.
-
Jerry thanks for the script.
-
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.
-
I had to set mine in both places also. No biggie, easy enough it wanted to use Omaha otherwise.
-
Me too, had to set in both places - no big deal.
-
Agreed, no big deal. Just had to get my 2¢ in... :grin:
-
:lol:
-
: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
-
: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.
-
2d working fine with just the one wfo setting.
Tank U! :roll:
-
Just heads up these are no longer working with changes made today. wxnoaadiscuss.php
wxnoaaproducts.php
-
He can update with V1.06 of forecast-discussion.php 'guts' and it should work again.
https://saratoga-weather.org/scripts-NWSmisc.php
-
I'm off to a brass group rehearsal, and won't have time to do this right now. Later...
-
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!
-
Thanks, Ken and Jerry. Working nicely at http://tiggrweather.net/wxnoaaproducts.php.
I don't have a WFO directory but all seems well.
-
My 'WFO' directory is './cache/WFO'. You should have a similar one.
That's exactly where I looked but tain't there.
-
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.)
-
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.
-
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:
- WFO
- WFO/Winter Storm Wrn.
- WFO/Winter Storm Wrn./Wtch.
- WFO/Non-Precip. Wrn.
- WFO/Non-Precip. Wrn./Wtch.
- WFO/Non-Precip. Wrn./Wtch/Adv.
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.
-
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!
-
Thanks, Jerry. It's a great combo of features.
-
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:<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).
-
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:
<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:<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.
-
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.
-
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.
-
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
-
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.
-
Thanks Jerry. I like the concept and hope more offices, including mine (ILX) use it.
-
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'.
-
Thanks Jerry [tup]
MikeyM