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 Saturday, 15-Mar-2014 2:17 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.

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: 2:28 pm PDT Oct 22, 2014

Saratoga
 
Tonight

Partly Cloudy
Partly
Cloudy
Thursday

Mostly Sunny
Mostly
Sunny
Thursday
Night

Partly Cloudy
Partly
Cloudy
Friday

Mostly Sunny
Mostly
Sunny
Friday
Night

Partly Cloudy
Partly
Cloudy
Saturday

Showers Likely. Chance for Measurable Precipitation 60%
Showers
Likely
Saturday
Night

Chance Showers. Chance for Measurable Precipitation 30%
Chance
Showers
Sunday

Mostly Sunny
Mostly
Sunny
Sunday
Night

Mostly Clear
Mostly
Clear
Lo 54 °F Hi 79 °F Lo 55 °F Hi 80 °F Lo 55 °F Hi 72 °F Lo 53 °F Hi 72 °F Lo 50 °F

 

Tonight
 
Partly cloudy, with a low around 54. North northwest wind around 6 mph becoming calm in the evening.
Thursday
 
Mostly sunny, with a high near 79. Calm wind becoming north around 5 mph in the afternoon.
Thursday Night
 
Partly cloudy, with a low around 55. North wind around 6 mph becoming calm in the evening.
Friday
 
Mostly sunny, with a high near 80. Calm wind.
Friday Night
 
Partly cloudy, with a low around 55. South wind 6 to 9 mph.
Saturday
 
A chance of rain before noon, then showers likely after noon. Partly sunny, with a high near 72. Chance of precipitation is 60%.
Saturday Night
 
A 30 percent chance of showers. Partly cloudy, with a low around 53.
Sunday
 
Mostly sunny, with a high near 72.
Sunday Night
 
Mostly clear, with a low around 50.
Monday
 
Sunny, with a high near 74.
Monday Night
 
Mostly clear, with a low around 52.
Tuesday
 
Sunny, with a high near 75.
Tuesday Night
 
Partly cloudy, with a low around 53.
Wednesday
 
Sunny, with a high near 76.

 

Forecast from NOAA-NWS for Saratoga CA.

National Weather Service Forecast for: Saratoga CA
Issued by: National Weather Service San Francisco Bay Area/Monterey, CA
Updated: 2:28 pm PDT Oct 22, 2014

Saratoga
 
Tonight

Partly Cloudy
Partly
Cloudy
Thursday

Mostly Sunny
Mostly
Sunny
Thursday
Night

Partly Cloudy
Partly
Cloudy
Friday

Mostly Sunny
Mostly
Sunny
Friday
Night

Partly Cloudy
Partly
Cloudy
Saturday

Showers Likely. Chance for Measurable Precipitation 60%
Showers
Likely
Saturday
Night

Chance Showers. Chance for Measurable Precipitation 30%
Chance
Showers
Sunday

Mostly Sunny
Mostly
Sunny
Sunday
Night

Mostly Clear
Mostly
Clear
Lo 54 °F Hi 79 °F Lo 55 °F Hi 80 °F Lo 55 °F Hi 72 °F Lo 53 °F Hi 72 °F Lo 50 °F

 

Tonight
 
Partly cloudy, with a low around 54. North northwest wind around 6 mph becoming calm in the evening.
Thursday
 
Mostly sunny, with a high near 79. Calm wind becoming north around 5 mph in the afternoon.
Thursday Night
 
Partly cloudy, with a low around 55. North wind around 6 mph becoming calm in the evening.
Friday
 
Mostly sunny, with a high near 80. Calm wind.
Friday Night
 
Partly cloudy, with a low around 55. South wind 6 to 9 mph.
Saturday
 
A chance of rain before noon, then showers likely after noon. Partly sunny, with a high near 72. Chance of precipitation is 60%.
Saturday Night
 
A 30 percent chance of showers. Partly cloudy, with a low around 53.
Sunday
 
Mostly sunny, with a high near 72.
Sunday Night
 
Mostly clear, with a low around 50.
Monday
 
Sunny, with a high near 74.
Monday Night
 
Mostly clear, with a low around 52.
Tuesday
 
Sunny, with a high near 75.
Tuesday Night
 
Partly cloudy, with a low around 53.
Wednesday
 
Sunny, with a high near 76.

 

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>
Tonight

Partly Cloudy
Partly
Cloudy
Thursday

Mostly Sunny
Mostly
Sunny
Lo 54 °FHi 79 °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>

Tonight

Partly Cloudy
Partly
Cloudy
Lo 54 °F
Partly cloudy, with a low around 54. North northwest wind around 6 mph becoming calm in the evening.
Thursday

Mostly Sunny
Mostly
Sunny
Hi 79 °F
Mostly sunny, with a high near 79. Calm wind becoming north around 5 mph in the afternoon.

Download: advforecast2.php (V3.12 - 15-Mar-2014) (Special thanks to Curly from RicksTurf.com for the multi-zone forecast code!)
Download: Icon Set (upload to your website in the /forecast/images directory)


advisory.php (NOAA Advisory/Warning script)

This is a small mod to Tom's advisory script to eliminate some strange characters that began appearing just before the first line of the script output. This script is meant to be included in a webpage, not run as a separate page. (See the discussion at http://www.wxforum.net/viewtopic.php?t=539

Download: testadvisory.php

deformed-offering