deformed-offering

Weather station scripts - NWS Forecast

They're free, but use at your own risk

The scripts referenced here are used in the operation of this weather station, and may be freely copied and used to support your station. Please note that you use these scripts at your own risk. No warranty is expressed or implied. I accept no liability for any damages that may ensue from their use.
You will need to configure them for your own particular weather station website.
RSS feed for Scripts Updates A RSS Feed is available to help keep you informed on updates to the scripts.

If you find one or more of the scripts useful to you, please consider making a donation to help offset the routine expenses of operation of this website.
Thanks for your kind support!

A Version History is available -- check back from time to time to see if there are updates to scripts you have downloaded earlier. Announcements of version updates and new scripts are made on WXForum.net and Weather-Watch forums and saratogaWXPHP Twitter account as they become available.

This page was updated Wednesday, 11-Oct-2017 12:40 PM

Carterlake.org scripts with a few mods...

Tom at carterlake.org has done a great job generating and freely sharing his PHP scripts for other sites to use. I started my own journey with PHP programming by using his scripts (and Larry's at Anole Computer) as learning examples, and I can't thank them enough for their sharing! With Tom's permission (and some encouragement), I've set up this page to have links to the carterlake scripts that I've modified for various puposes. Most of the mods have to do with formatting for XHTML 1.0-Strict output (even when the source page was not).

advforecast.php (NOAA Forecast for all NWS areas)

Note: as of 12-Mar-2007, the Western Region website (www.wrh.noaa.gov) now offers the point-printable forecasts in the same format as the other regional websites, so this script now works for WRH, ERH, SRH and CRH websites.

Tom's advforecast.php script takes the point-printable forecast from NOAA for Western, Eastern, Southern and Central region NOAA websites, and converts to a set of icons/conditions/temperatures and text forecast for inclusion on your webpage. My mods add XHTML 1.0-Strict output and the ability to handle a redirection for county forecasts (offered by www.crh.noaa.gov) in case a point-printable forecast is not available. See these threads for the erh2crh version (http://www.wxforum.net/viewtopic.php?p=3768, and http://www.weather-watch.com/smf/index.php/topic,22504.0.html ) The latest version of this script also offers automatic failover to the Zone forecast if the point-printable forecast is not available. Set "$NOAAZone = 'ssZnnn';" in the code for your NOAA warning zone.

The script supports the ?force=1 parameter to reload the cache file, and also a ?force=2 to load the cache file from the backup County Zone forecast.

To use, you'll need an icon set uploaded in the /forecast/images directory on your website, and to set the $fileName variable inside the script to the URL for the point-printable forecast.

With V2.06 and up, the new parsing of the failover Zone forecast requires additional icons (available below) to be placed on your website.

In July, 2015, the NOAA-NWS updated the icon set and provided a new dual-image icon to display 6-hour conditions for the 12-hour forecast icon. This icon is dynamically generated by a DualImage.php script (available below in the UPDATES file). With the DualImage.php script and associated icon templates installed, the V4.00+ version of advforecast2.php will support dynamic generation of dual images when needed. The script will fall-back to showing just the first 6-hour image if the DualImage.php is not available, OR if the meteotriviglio animated GIF images are used.

In June, 2017, the NWS forecast.weather.gov website has planned a major renovation and deprecated the use of /MapClick.php?lat={latitude}&lon={longitude} for finding the weather at your location. V5.00 of advforecast2.php now uses the new api.weather.gov JSON feeds to generate the icons/forecast text as the V4.x and prior scripts will no longer work via page-scraping.
The V5.00 advforecast2.php script provides automatic conversion of old-format URLs using MapClick.php arguments into API requests, and provides a conversion utility (via advforecast2.php?convert) to display the new settings based on your current settings for the script (both standalone and in a site running the Saratoga templates. The $forecast... variables are unchanged so the script is backward-compatible with prior versions of the script.
Also new is the number of icons available rose from 9 to 14 and the option to display the old-format 9 icons or the new format with two rows of (up-to) 8 icons is controlled by one switch variable ($showTwoIconRows in the script, or $SITE['showTwoIconRows'] in Settings.php).

Sample included with:

<?php
$doIncludeNWS = true;
include("advforecast2.php"); ?>

will show

National Weather Service Forecast for: Saratoga, CA
Issued by: National Weather Service San Francisco Bay Area/Monterey, CA
Updated: Mon, 20-Nov-2017 1:09pm PST

Saratoga
 
This
Afternoon
This Afternoon: Partly Sunny
Partly Sunny
Tuesday

Tuesday: Mostly Sunny
Mostly Sunny
Wednesday

Wednesday: Mostly Sunny
Mostly Sunny
Thanksgiving
Day
Thanksgiving Day: Mostly Sunny
Mostly Sunny
Friday

Friday: Partly Sunny
Partly Sunny
Saturday

Saturday: Partly Sunny
Partly Sunny
Sunday

Sunday: Partly Sunny
Partly Sunny
 
Hi 70 °F ↓ Hi 75 °F ↓ Hi 74 °F Hi 72 °F Hi 71 °F Hi 69 °F Hi 67 °F  
 
Tonight

Tonight: Mostly Cloudy
Mostly Cloudy
Tuesday
Night
Tuesday Night: Partly Cloudy
Partly Cloudy
Wednesday
Night
Wednesday Night: Partly Cloudy
Partly Cloudy
Thursday
Night
Thursday Night: Partly Cloudy
Partly Cloudy
Friday
Night
Friday Night: Mostly Cloudy
Mostly Cloudy
Saturday
Night
Saturday Night: Mostly Cloudy
Mostly Cloudy
Sunday
Night
Sunday Night: Mostly Cloudy then Slight Chance Light Rain
Mostly Cloudy then Slight Chance Light Rain
 
Lo 54 °F Lo 55 °F Lo 56 °F Lo 55 °F Lo 53 °F Lo 53 °F Lo 52 °F  

 

This Afternoon
 
Partly sunny. High near 70, with temperatures falling to around 64 in the afternoon. North wind around 5 mph.
Tonight
 
Mostly cloudy, with a low around 54. North wind 1 to 5 mph.
Tuesday
 
Mostly sunny. High near 75, with temperatures falling to around 68 in the afternoon. North northeast wind 1 to 7 mph.
Tuesday Night
 
Partly cloudy, with a low around 55. North northwest wind 1 to 6 mph.
Wednesday
 
Mostly sunny, with a high near 74. North northwest wind 2 to 6 mph.
Wednesday Night
 
Partly cloudy, with a low around 56.
Thanksgiving Day
 
Mostly sunny, with a high near 72.
Thursday Night
 
Partly cloudy, with a low around 55.
Friday
 
Partly sunny, with a high near 71.
Friday Night
 
Mostly cloudy, with a low around 53.
Saturday
 
Partly sunny, with a high near 69.
Saturday Night
 
Mostly cloudy, with a low around 53.
Sunday
 
Partly sunny, with a high near 67.
Sunday Night
 
A slight chance of rain after 4am. Mostly cloudy, with a low around 52. Chance of precipitation is 20%.

 

Forecast from NOAA-NWS for Saratoga, CA.

You can also include it 'silently' and print just a few (or all) the contents where you'd like it on the page

<?php
$doPrintNWS = false;
require("advforecast2.php"); ?>

then on your page, the following code would display just the current and next time period forecast:

 <table>
<tr align="center" valign="top">
<?php print "<td>$forecasticons[0]</td><td>$forecasticons[1]</td>\n"; ?>
</tr>
<tr align="center" valign="top">
<?php print "<td>$forecasttemp[0]</td><td>$forecasttemp[1]</td>\n"; ?>
</tr>
</table>
This
Afternoon
This Afternoon: Partly Sunny
Partly Sunny
Tonight

Tonight: Mostly Cloudy
Mostly Cloudy
Hi 70 °F ↓Lo 54 °F

Or if you'd like to include the immediate forecast with text for the next two cycles:

<table>
<tr valign="top">
<?php print "<td align=\"center\">$forecasticons[0]<br />$forecasttemp[0]</td>\n"; ?>
<?php print "<td align=\"left\" valign=\"middle\">$forecasttext[0]</td>\n"; ?>
</tr>
<tr valign="top">
<?php print "<td align=\"center\">$forecasticons[1]<br />$forecasttemp[1]</td>\n"; ?>
<?php print "<td align=\"left\" valign=\"middle\">$forecasttext[1]</td>\n"; ?>
</tr>
</table>

This
Afternoon
This Afternoon: Partly Sunny
Partly Sunny

Hi 70 °F ↓
Partly sunny. High near 70, with temperatures falling to around 64 in the afternoon. North wind around 5 mph.
Tonight

Tonight: Mostly Cloudy
Mostly Cloudy

Lo 54 °F
Mostly cloudy, with a low around 54. North wind 1 to 5 mph.

Download: advforecast2.php (V5.04 - 11-Oct-2017) (Special thanks to Curly from RicksTurf.com for the multi-zone forecast code!)
Download: Icon Set (V2 for NWS 55x55 icons) (upload to your website in the /forecast/images directory)
Download: Icon Set UPDATES July-2015 and DualImage.php script
Download:
Icon Set UPDATES April-2017 and DualImage.php script (upload to your website and preserve the directory names - included with Base-USA template)

deformed-offering