room
room
room
room

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 https://github.com/ktrue

Buy Me A Coffee 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.

Note: Twitter widget has been disabled 3-Jul-2023 since it no longer displays the recent update Tweets.

This page was updated Friday, 22-May-2026 5:50 AM

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.

502
FXUS66 KMTR 150054
AFDMTR

Area Forecast Discussion
National Weather Service San Francisco CA
554 PM PDT Mon Sep 14 2026

...New AVIATION...

.KEY MESSAGES...
Updated at 1206 PM PDT Mon Sep 14 2026

 - Cooling trend and below normal temperatures through mid-week;
   return to seasonal temperatures late week into weekend

&&

.SHORT TERM...
Issued at 1206 PM PDT Mon Sep 14 2026
(This evening through Tuesday night)

Today will be the warmest day of the upcoming week with a slight
cooling trend kicking off tomorrow. The upper level trough that
brought us cooler weather last week has progressed eastward towards
the Intermountain West. In its place, zonal flow has developed over
Central California with slight troughing to redevelop Tuesday. The
transition from more zonal flow to slight troughing will see
temperatures cool 2-5 degrees across the region. This will bring
interior temperatures down from the mid to upper 80s today to the
low to mid 80s tomorrow. Coastal areas stay cooler with highs in the
60s to 70s.

Moderate offshore winds were observed along the ridgeline of the
Vaca Range early this morning but have since been trending
downwards. Mt. St. Helena (elevation of 4340 ft) reported a NNE gust
of 40 mph at 2:40 AM which was the strongest wind gust observed from
this event. The SFO-WMC gradient peaked at -6.10 around 7AM this
morning and has since dropped to -4.90 as of 10AM. It is forecast to
shift positive (onshore) by late this afternoon with light onshore
winds returning everywhere. The return of onshore winds should help
marine stratus to redevelop/move inland tonight. The only caveat to
this is we currently have a dry airmass over us which could keep
stratus development limited for one more night. Breezy onshore winds
redevelop Tuesday afternoon and evening with gusts to around 20-30
mph most likely in the East Bay Valleys, Salinas Valley, higher
elevations, and directly along the coast.

&&

.LONG TERM...
Issued at 1206 PM PDT Mon Sep 14 2026
(Wednesday through next Sunday)

Troughing becomes more dominant by Wednesday as another upper level
low pushes into the Oregon/California border. We are not
anticipating any rain or thunderstorms for this system across our
region but it will bring an unusually cold airmass across our
region. High temperatures Wednesday and Thursday will be running 5-6
degrees below normal across the lower elevations and closer to 10-15
degrees below normal in the higher elevations and along the coast.
This will keep interior temperatures securely in the 70s and coastal
temperatures in the low to mid 60s. Favored hotspots across the
interior Bay Area and Central Coast will reach the low 80s. The
upper level low deepens and tries to become cut-off from the jet
stream Thursday into Friday. Fortunately, it is a quick moving
system and maintains a neutral tilt. If it took a more positive tilt
and dug in more over NE California/Nevada then it would be more
reminiscent of an inside slider which would raise offshore wind
concerns. As it stands right now, this system will just bring a
round of gusty onshore winds Wednesday into Thursday with gusts
peaking between 20 to 30 mph. Locally higher gusts are possible at
favored windy locations (Altamont Pass, higher elevations, etc.).
The passage of the upper level trough will allow the marine layer to
deepen and see a return of our nightly/early morning stratus along
the coast and portions of the interior.

Troughing influence wanes Friday into the weekend as weak ridging
builds in over California. This will see a gradual return to more
seasonal temperatures in the low to mid 80s across the interior, 60s
to 70s along the coast, and upper 80s to low 90s across favored hot
spots in the Bay Area and interior Central Coast. Even though the
ridge is weak, it will still compress the marine layer and most
likely result in less stratus cover across the interior.

&&

.AVIATION...
(00Z TAFS)
Issued at 553 PM PDT Mon Sep 14 2026

Widespread VFR through the evening with moderate onshore winds.
Winds become gentle overnight with interior valleys developing a
land breeze. Moderate onshore winds settle in again by late Tuesday
morning. Stratus coverage will not be widespread this TAF period
given the persistent, yet weak, offshore flow aloft. This will be
enough to keep stratus out of the interior North, East, and South
Bay valley terminals. High confidence for borderline MVFR-IFR
ceilings to develop tonight at coastal sites first, followed by APC
early Tuesday morning. Low to medium confidence for MVFR ceilings to
develop over south San Francisco Bay after midnight.

Vicinity of SFO...VFR with moderate to fresh westerly breezes
prevailing into the evening. Winds ease after sunset and shift west
to southwest. Low to medium confidence on MVFR ceilings early
Tuesday morning. Any ceiling that develops will likely be short-
lived due to the presence of a weak offshore flow. VFR prevails by
late Tuesday morning into the evening with an increase in moderate
westerly winds.

SFO Bridge Approach...Stratus coverage may be patchy overnight.
Otherwise, similar to SFO.

Monterey Bay Terminals...Clear skies continue into the evening with
gentle onshore breezes. The marine layer will bring IFR ceilings
late tonight and persists into late Tuesday morning. Medium
confidence on exact timing of stratus arrival.

&&

.MARINE...
(Today through Saturday)
Issued at 1004 AM PDT Mon Sep 14 2026

Hazardous conditions for small craft will continue for the coastal
waters and Monterey Bay early in the week due to a northwesterly
moderate to fresh breeze with strong gusts. Northwest winds will
ease by mid-week. Moderate to rough seas will prevail through
Tuesday before subsiding Wednesday.

&&

.FIRE WEATHER...
Issued at 436 AM PDT Mon Sep 14 2026

A few patches of coastal stratus have developed overnight. North
to northeast breezes have developed in the higher terrain. Offshore
winds will diminish by late morning or early afternoon and return
to diurnally breezy onshore winds in the afternoon and evening. A
surface to lower level trough of low pressure will develop along
the north Central Coast Tuesday through Tuesday night. Surface to
lower level troughing will expand to include the Bay Area Wednesday
through Thursday. This will bring higher humidity with good recoveries
from sea level to lower elevations to around 2500 feet, however above
this elevation especially along the higher ridgetops thermal ridging
and much lower humidity will persist during mid-week.

As such, areas above the marine layer often experience nocturnal
drying that will likely continue through early this upcoming week.

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
CA...None.
PZ...Small Craft Advisory until 9 PM PDT this evening for Mry Bay-
     Pigeon Pt to Pt Pinos 0-10 nm.

     Small Craft Advisory until 3 AM PDT Tuesday for Pt Arena to Pt
     Reyes 0-10 nm-Pt Pinos to Pt Piedras Blancas 0-10 nm.

     Small Craft Advisory until 3 AM PDT Wednesday for Pt Arena to Pt
     Reyes 10-60 NM.

     Small Craft Advisory until 9 AM PDT Tuesday for Pigeon Pt to Pt
     Pinos 10-60 NM.

&&

$$

SHORT TERM...Kennedy
LONG TERM....Kennedy
AVIATION...Navarrete
MARINE...RGass

Visit us at www.weather.gov/sanfrancisco

Follow us on Facebook, X, and YouTube at:
www.facebook.com/nwsbayarea
x.com/nwsbayarea
www.youtube.com/nwsbayarea

NWS MTR Office Area Forecast Discussion

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

<?php
$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 www.weather.gov
  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::

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

NWS Area Forecast Discussion PHP script Demo and Download (Version 1.07 - 21-May-2026 see history).

PHP for NWS CPC World Extremes

This script was originated by Michael of Relayweather.com and has been rewritten to use the NWS Climate Prediction Center's CSV file for world observations. 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 variables:

$omittedCountry (text list of countries excluded from $world high/low/precip scans)
Note: the setting $ignoreCountrys is the array of country names to to exclude
$worldhigh
$worldlow
$worldprecip

$selectedCountry (setting: country name for selected country high/low/precip)
Note: run http://your.site.com/worldextremes.php?list to see the list of country names to use
$countryhigh
$countrylow
$countryprecip

$usahigh (Note: for lower-48 USA states)
$usalow (Note: for lower-48 USA states)
$usaprecip (Note: for lower-48 USA states)

$selectedState (setting: USA state 2-character name abbreviation in settings area)
$selectState (a copy of $selectedState for compatibility with old stateextremes.php)
$statehigh
$statelow
$stateprecip

$reportDate (nicely formatted date of the report)
$stateReportDate (a copy of $reportDate for compatibility with old stateextremes.php)

You can run the script by using:

<?php
include_once("worldextremes.php");

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 courtesy of <a href=\"";
print "https://www.cpc.ncep.noaa.gov/products/cadb/";
print "\">NWS-CPC</a></small></p>\n";

?>

which produces this result (with live data):

USA Extremes for Sunday, September 13, 2026

High Temperature

107°F at Imperial County Ap, CA

Low Temperature

10°F at Fritzsche Aaf, CA

High Precipatation

4.33in at Igor I Sikorsky Memorial Airport, CT

Data courtesy 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.

$cacheFileDir = './'; // directory to store cache file in.
$cacheFile2 = "worldextremesCache.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 (display in C is default)
$rUOM = 'in';     // or ='' for no rain unit display (display in mm is default)
#
$ignoreCountrys = array('Antarctica','Greenland');     // for world extremes - exclude these country(s)
$ignoreStations = array('99KLRJ');     // list of stn_id (field 0) to ignore for bogus data
$tempDiffAllowed = 40; // max difference Tmax-Tmin (C) for valid data
$selectedCountry = 'Canada'; // for country max/min/precip in $country* variables
// note: the $usa* variables will have the min/max/precip for the lower-48 states
$selectedState   = 'CA';  // for USA state max/min/precip in $state* variables

Note that $cacheFileDir, $tUOM, $rUOM will use the Saratoga template Settings.php values if used in a Saratoga template.

NWS CPC One Day Extremes PHP script Download (Version 5.05 - 21-May-2026 see history).

deformed-offering