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.
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
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.
346
FXUS66 KMTR 171158
AFDMTR
Area Forecast Discussion
National Weather Service San Francisco CA
458 AM PDT Sat Oct 17 2026
...New AVIATION...
.KEY MESSAGES...
Updated at 1053 PM PDT Fri Oct 16 2026
- Warm temperatures continue Saturday
- Near critical fire weather conditions Saturday across higher
elevations
- Much cooler weather arrives Sunday with rain chances mid-week
&&
.SHORT TERM...
Issued at 1053 PM PDT Fri Oct 16 2026
(Tonight through Sunday)
Clear skies continue this evening, but the offshore winds have
calmed substantially. The SFO-WMC gradient peaked at -13.7 mb
Friday morning and has since weakened to -7.8 mb. 24 hours ago Mt.
St. Helena was reporting NNE winds of 44 mph. Now it`s NW at 5.
The 500 mb ridge over northern California is weakening. The 00Z
balloon measured the 500 mb height at 5910m, down from 5930m at
12Z. That`s still above the 90th percentile for this time of year,
but the trend will accelerate through the day Saturday as the
Channel Islands cut-off low gets absorbed back into the jet
stream, bringing more zonal flow to the upper levels.
At the surface this means the return of onshore winds and the
start of a cooling trend. Max temperatures Saturday are expected
to be a couple degrees cooler than Friday. It will still be a
warm, sunny day for everyone. The bigger change is Sunday. A new
deep low pressure system approaches from the west. This system
will bring back the marine layer and drop the max temperatures by
another 10-15 degrees. It will also bring another round of wind,
but from the west this time. Our current forecast shows gusts up
to 50 mph through Altamont Pass Sunday night. That`s the outlier.
Most places will have gusts in the 15-25 mph range.
&&
.LONG TERM...
Issued at 1053 PM PDT Fri Oct 16 2026
(Sunday night through next Friday)
A brief period of zonal flow aloft gets interrupted on Monday as an
upper-level trough pushes southward along the California coast.
Ahead of the low pressure system, onshore winds increase across the
Bay Area and Central Coast with a deepening marine layer, resulting
in cooling to near seasonal temperatures. The trough becomes a cut-
off low by Tuesday and lingers off the Central Californian coast
before gradually propagating inland through Southern California
Wednesday evening into Thursday. The system`s position allows for
the reinforcement of cold air advection across the Bay Area and
Monterey Bay regions through the end of next week.
In terms of precipitation chances, light rain showers are possible
Tuesday through Thursday across the Bay Area and Monterey Bay
regions. The coastline and southernmost extent of the Central Coast
have a 40-60% probability of light rain meanwhile the North, East,
and South Bay have a 20-40% chance. In addition to rain, there is
potential for thunderstorm development during the aforementioned
time period. The three main ingredients required for thunderstorm
development are instability, lift, and moisture. Given the complex
terrain within the region, we can guarantee some degree of
orographic lifting as the system moves inland. Both the European and
GFS ensemble members are hinting at precipitable water values around
the 75th percentile for this time of year, so we can also check
moisture off our thunderstorm ingredient list. Finally, we have
instability. European ensemble members are exhibiting 500 mb
temperatures around -15 to -20 degrees Celsius, which falls below
the 10th percentile for this time of year. Meanwhile, the 850 mb
temperatures are around the seasonal normal of 9 to 12 degrees
Celsius. Atmospheric instability may arise from the mixing of air
masses, particularly when a cold air mass sits on top of a warm air
mass. Since cold air is more dense than warm air, it will sink to
the surface while forcing the ascent of warm air. As warm air rises,
it cools adiabatically and condenses, resulting in latent heat
release, which further warms the surrounding air allowing for
increased vertical mixing. This process is dependent on other
thermodynamic factors, however the structure of our cut-off low
supports an unstable system due to vertical mixing.
Despite all of the above, there is still high uncertainty regarding
the rainfall and thunderstorm potential as it is dependent on the
exact trajectory of the cut-off low and the alignment of various
elements. Be sure to check back on the forecast for updated
information.
&&
.AVIATION...
(12Z TAFS)
Issued at 457 AM PDT Sat Oct 17 2026
No major changes to the TAF package this morning. Light offshore
flow is expected this morning, with onshore flow returning this
afternoon. We`ll still have to work through some drier air so VFR
conditions are expected to prevail. The marine layer is expected to
establish to around 500-1000ft by 12Z so we could see some stratus
develop along the coast.
Vicinity of SFO...Winds are expected to become offshore for a few
hours this morning, with onshore flow returning by the afternoon.
Some guidance shows the potential for a reduced visibility, which
would coincide with the marine layer getting to around 500-1000ft.
Opted to keep KSFO and KOAK VFR for the time being.
SFO Bridge Approach...Similar to SFO.
Monterey Bay Terminals...Light offshore winds will continue this
morning, with onshore winds returning later this afternoon. The
marine layer starts to re-establish and bring reduced visibility to
the region. This appears to have the best chance around sunrise,
opted to start hinting at the potential since it is just outside the
TAF cycle.
&&
.MARINE...
(Today through Thursday)
Issued at 255 AM PDT Sat Oct 17 2026
Gentle to moderate northerly breezes this morning, with winds
gradually increasing as a cold front sweeps through this weekend.
Northerly winds will become strong across the northern outer
waters this evening and then hold through Sunday. Moderate to
fresh northwesterly breezes Monday will diminish and back toOffshore winds are expected for through the
morning with onshore winds by late morning or early afternoon.
Onshore flow should continue through the early evening, before
another round of offshore winds returns late evening and into early
Saturday morning. VFR conditions will prevail. become westerly
Tuesday. Moderate seas will prevail through today, but will
gradually be building and become rough across the outer waters
tonight through Tuesday. Light rain is expected Monday into
Tuesday.
&&
.FIRE WEATHER...
Issued at 1053 PM PDT Fri Oct 16 2026
While the offshore winds have calmed substantially, hot and dry
conditions will continue through Saturday. Max temperatures will
be in the mid 80s to low 90s with RH dropping into the the teens
for nearly all areas away from the immediate coast. A significant
cool-down arrives Sunday through Monday with light rain possible
mid-week.
&&
.BEACHES...
Issued at 919 PM PDT Sat Oct 16 2026
Temps cool on Saturday, but still pleasant weather. People may
head to beaches to recreate, but should use caution. Hazardous
beach conditions will develop at Pacific Coast beaches this
weekend and likely into next week. Long period (17 seconds)
southerly/southwesterly swell will bring an increased risk for
sneaker waves and strong rip currents with breaking waves of 7 to
12 feet. Remain off of jetties, piers, rocks, and other waterside
infrastructure as waves can sweep across the shoreline without
warning, pulling people into the sea. Never turn your back on the
ocean!
MM/Sarment
&&
.MTR WATCHES/WARNINGS/ADVISORIES...
CA...Beach Hazards Statement through Sunday evening for CAZ006-505-
509-529-530.
PZ...Small Craft Advisory from 3 AM to 9 AM PDT Sunday for Pt Arena
to Pt Reyes 0-10 nm.
Small Craft Advisory until 9 AM PDT Sunday for Pt Arena to Pt
Reyes 10-60 NM.
&&
$$
SHORT TERM...Flynn
LONG TERM....Navarrete
AVIATION...KR
MARINE...KR
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:
- Browse to www.weather.gov
- Use the search box on the left to search for your city, state
- Look at the URL in the 'Forecast Discussion' link near the bottom of the page
- Use the 3-character abbreviation is in the &issuedby=XXX parameter on the
Forecast Discussion link (XXX will be your local office)
- 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 Friday, October 16, 2026
High Temperature
100°F at Phoenix Williams Gateway Ap, AZ
Low Temperature
14°F at Leadville, CO
14°F at Berthoud Pass, CO
High Precipatation
1.83in at Pompano Beach Airpark, FL
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 = '°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).