Weather station scripts

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.

Many of these scripts are now available on GitHub at

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 and Weather-Watch forums and saratogaWXPHP Twitter account as they become available.

This page was updated Sunday, 10-Feb-2019 7:10 PM

PHP for NWS Area Forecast Discussion

This PHP script will fetch and cache the Forecast Area Discussion issued by your local NWS office.
Thanks to Mike Challis of Long Beach, WA for the inspiration for and enhancement of this script.

FXUS66 KMTR 252055

Area Forecast Discussion
National Weather Service San Francisco Bay Area
155 PM PDT Sun Aug 25 2019

.SYNOPSIS...High pressure will produce warmer temperatures through
early next week, especially across inland areas where very warm
temperatures are forecast. The marine layer will persist along the
coast, along with light onshore flow, resulting in relatively
mild temperatures near the ocean and bays. Moisture from Tropical
Storm Ivo may pass across our area from Tuesday afternoon into
Wednesday, bringing increasing clouds and higher humidity. Cooler
temperatures are forecast for the second half of next week.

&& of 1:55 PM PDT Sunday...The low clouds from
earlier this morning have retreated back to the immediate
coastline, providing mostly sunny skies for much of the San
Francisco Bay Area. Visible satellite shows the remaining marine
stratus at locations such as Point Reyes, Ocean Beach in San
Francisco, Half Moon Bay, and Moss Landing. Temperatures are
generally running about 2 to 5 degrees F warmer than they were 24
hours ago, consistent with the expected trends by the time the
afternoon wraps up. High temperatures along the coast will
register in 60s/70s with inland locations warming the upper 80s to
90s. Some of the region`s hottest locations such as Pinnacles
National Park and extreme southern Monterey County will approach
and possibly exceed 100 degrees.

A broad 594 dm ridge at 500 mb is largely responsible for the warm
to hot weather across the region. With gradual warming at 850 mb
forecast over the next 24 hours, surface temperatures on Monday
afternoon will at least match and likely exceed today`s readings
by at least a few to several degrees. The marine layer is not
expected to get any deeper than its present 1,000 ft depth with
the ridge firmly overhead; therefore, any stratus coverage on
Monday morning will likely be limited to the shorelines. Though
high temperatures will be around 5-10 degrees above late August
climatological normals both today and tomorrow, most population
centers will benefit from appreciable overnight cooling that will
prevent heat risks from going beyond the moderate category for
interior communities. Locations at/above 750-1000 ft elevation
will be the isolated spots that can expect mild overnight lows in
mid 60s to 70s.

The much discussed now Tropical Depression Ivo continues its
northbound trajectory in the eastern Pacific, presently situated
about 500 miles WNW of the southern tip of the Baja California
Peninsula. Further weakening is expected as it is forecast to
become a remnant low later today. The leftover moisture from Ivo
will continue north over the next several days, and will parallel
the California coast by late Tuesday and into Wednesday. The 12Z
models keep the bulk of moisture and best instability offshore;
however, the latest NAM does try to bring some of the higher RH
values and mid-level instability to northern California on
Wednesday afternoon. The present forecast would provide locations
north of Sonoma County the best potential for any scattered
showers/storms, but this is subject to change, particularly if the
remnant moisture tracks east by 50 to 100 miles. The most likely
impacts at this point for much of the San Francisco Bay Area and
central California coast will be increased cloudiness in the mid-
levels as well as higher dewpoints at the surface.

Temperatures are forecast to moderate by the end of the week with
more seasonable highs expected as trough approaches the Pacific
Northwest. The latest Climate Prediction Center 6-10 day outlook
does paint a large area with increased probabilities of above
normal temperatures for the West Coast for the beginning of
September as the ridge begins to rebuild.


.AVIATION...As of 10:40 AM PDT Sunday...For 18Z TAFs. Current
satellite imagery shows stratus clearing to the coast. VFR
conditions are expected for the rest of the day but patchy stratus
and possible fog will return again tonight most areas. Light
winds this morning to increase and turn onshore this afternoon
10-15 kt with occasional higher gusts possible.

Vicinity of KSFO...VFR conditions through the evening. Patchy
stratus to return overnight. W to NW winds around 10 kt this
morning increasing to 15 kt this afternoon.

SFO Bridge Approach...Low clouds still clearing over the approach.
Otherwise, similar to KSFO.

Monterey Bay Terminals...VFR conditions with IFR cigs potentially
returning early this evening. Onshore winds this afternoon 10-15

&& of 8:26 AM PDT Sunday...Weakening high pressure over
the eastern Pacific will keep light winds over the coastal waters
through early to mid next week. Sea breezes will develop in the
afternoons and evenings over the San Francisco Bay to the Delta.
Southerly swell will increase to 2 to 3 feet today and persist
through early next week as a tropical system west of the Baja
Peninsula progresses northward. Additionally, light to moderate
northwest swell will continue through the period.





Visit us at

Follow us on Facebook, Twitter, and YouTube at:

NWS MTR Office Area Forecast Discussion

To use, include the output of the script on your webpage by using

$doIncludeFD = true;
include("forecast-discussion.php"); ?>

to perform the include. Settings inside the script are:

// settings:
//  change myNWS to abbreviation for your local NWS office
//    other settings are optional
    $myNWS = 'MTR';   // San Francisco, NWS office
//  $myNWS = 'PQR';   // Portland, OR
//  $myNWS = 'OAX';   // Omaha, NE (Carter Lake, IA)
$cacheName = "forecast-discussion.txt"; // used to store the file so we don't have to // fetch it each time $refetchSeconds = 1800; // refetch every nnnn seconds
$cacheFileDir = './'; // default cache file directory // end of settings

The only required setting is for $myNWS which designates the local NWS office.
To find the 3-character abbreviation for your local NWS office for the $myNWS variable, follow these steps:

  1. Browse to
  2. Use the search box on the left to search for your city, state
  3. Look at the URL in the 'Forecast Discussion' link near the bottom of the page
  4. Use the 3-character abbreviation is in the &issuedby=XXX parameter on the Forecast Discussion link (XXX will be your local office)
  5. put the XXX in the $myNWS = 'XXX'; statement

The script has two optional parameters when you call it by URL from your website::

Will return the contents without the surrounding <html><head></head><body> and </body></html> tags
Will override the default $refetchSeconds=1800 so that the cache is refreshed immediately

NWS Area Forecast Discussion PHP script Demo and Download (1.06 - 27-Feb-2018 see history).

PHP for NWS CPC USA Extremes

This script was originated by Michael of and has been rewritten to use the NWS Climate Prediction Center's One Day Old Daily Data Summary text file for the USA. The script does not produce output (other than HTML comments for status), so you are free to include it in a page, and format the text output as you desire. The script returns data in four variables:

$usahigh - contains the text of the high temperature station(s) (value and station name from the NWS)
$usalow - contains the text of the low temperature station(s) (value and station name from the NWS)
$usaprecip - contains the text of the high precipitation station(s) (value and station name from the NWS)
$reportDate - contains the text of the date for the report (default format is 'Dayname, Month day, Year')

You can run the script by using:


print "<p>USA Extremes for $reportDate</p>\n";
print "<p>High Temperature<br/><br/>$usahigh</p>\n";
print "<p>Low Temperature<br/><br/>$usalow</p>\n";
print "<p>High Precipatation<br/><br/>$usaprecip</p>\n";
print "<p><small>Data courtsey of <a href=\"";
print "";
print "\">NWS-CPC</a></small></p>\n";


which produces this result (with live data):

USA Extremes for Saturday, August 24, 2019

High Temperature

106°F at Las Vegas/Mccarran Int, NV
106°F at Needles Airport, CA

Low Temperature

33°F at Big Piney Amos, WY

High Precipatation

3.48in at Ft Smith/Muni, AR

Data courtsey of NWS-CPC

The script has internal settings which you can adjust. If run in a Saratoga template, the cache file will be stored in the ./cache/ directory based on $SITE['cacheFileDir'] in Settings.php.

// Site to Parse
$url2 = "";
// Name of cache file  --  This file must be set to CHMOD-666
$cacheFileDir = './'; // directory to store cache file in.
$cacheFile2 = "usaextremesCache4.txt";  
// Age of cache file before re-fetch caching time, in seconds (3600 = 1 hour)
$cache_life = '3600';
$reportDateFormat = "l, F j, Y"; // Day, Month d, yyyy 
$tUOM = '&deg;F'; // or ='' for no temperature unit display
$rUOM = 'in';     // or ='' for no rain unit display
$ignoreStations = array('99NRB'); // Station numbers to ignore, Array of station numbers

NWS CPC One Day Extremes PHP script Download (4.03e - 09-Feb-2019 see history).