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.
467
FXUS66 KMTR 140706
AFDMTR
Area Forecast Discussion
National Weather Service San Francisco CA
1206 AM PDT Sun Jun 14 2026
...New SHORT TERM, LONG TERM...
.KEY MESSAGES...
Updated at 1202 AM PDT Sun Jun 14 2026
- Minor coastal flooding due to higher than normal high tides
anticipated across low-lying coastal areas.
- Hazardous beach conditions through Tuesday with increased risk
of sneaker waves and strong rip currents.
- Minor to locally Moderate HeatRisk through the middle of the
week with seasonable June temperatures.
&&
.SHORT TERM...
Issued at 1202 AM PDT Sun Jun 14 2026
(Today and tonight)
Marine stratus continues o expand over the San Francisco Bay Area
and Central California Coast this early Saturday morning. With
the marine layer ever-so gradually deepening over the last few
days, interior locations such as Livermore and Concord are finally
realizing the marine-cooled influence where temperatures running
4-8 deg F cooler compared to 24 hours ago. By sunrise, expect the
classic June stratus for many communities.
The eastern Pacific ridge has been the driving synoptic feature
for California over the last several days. This will change today
as a weak disturbance develops over NorCal, disrupting the ridge`s
scope temporarily. While minimal day-to-day changes are forecast
along the coast, interior locations can expect several degrees of
cooling from Saturday to today. This will result more widespread
Minor HeatRisk throughout the Bay Area and Central Coast, with
Moderate HeatRisk reserved for the Central Valley and very
isolated East/South Bay locations.
High tide coastal flooding will continue to occur nightly along
the low-lying areas of the Bayshore and the Pacific Coast through
the middle of the week. Tide levels are forecast to rise up to 2.0
feet above normal into the middle of the week. This increase is
driven by multiple contributing factors, including Sunday`s new
moon and lunar perigee, ~ 7 inches of tidal anomaly from storm
surge and thermal expansion in the Eastern Pacific, and ~ 2 inches
of sea level rise since vertical datums were established in the
1980s/1990s. While lower than the historic tidal flooding in
January (which peaked at 2.6 ft), these tides could end up being
the highest observed in the summer, beating the current record of
1.7 ft from July 2022.
&&
.LONG TERM...
Issued at 1202 AM PDT Sun Jun 14 2026
(Monday through Saturday)
Eastern Pacific ridge will attempt to re-establish itself on
Monday and Tuesday. Temperatures in some interior locations may
subtly nudge upward as a result, but nothing that reintroduces new
HeatRisk categories -- still anticipating widespread Minor to
locally Moderate. The ordinary marine status should continue to
blanket the usual spots through much of the week.
&&
.AVIATION...
(06Z TAFS)
Issued at 947 PM PDT Sat Jun 13 2026
Satellite imagery highlights the marine stratus filling in across
adjacent coastal valleys and gaps. Status is projected to fill in
across the San Francisco Bay from KOAK down to KSFO and through the
North Bay valleys overnight. More restrictive visibilities will be
pinned to the immediate coast and through the Santa Rosa Plain and
Salinas Valley. There is some forecast uncertainty regarding the
immediate coast (specifically KHAF) regarding how well the stratus
deck will scatter out in the afternoon. Outgoing TAFs will carry a
pessimistic outlook holding the stratus over the terminal, but it is
possible the cloud cover will erode and hold just offshore by the
afternoon. Otherwise, light overnight winds will give way to breezy
onshore conditions again tomorrow afternoon as marine stratus erodes
for most locations.
Vicinity of SFO... Moderate confidence regarding the expansion of
stratus to fill in across the Bay and KSFO through the mid-morning
hours. Any stratus observed will erode through daylight hours as
wind speeds pick up, ranging from the northwest between 15-20 knots
by the afternoon.
SFO Bridge Approach... Similar to SFO
Vicinity of SJC and OAK... For OAK, status is expected to fill in
this morning bringing IFR conditions before mixing out between 17-
19Z. For SJC, while VFR is currently highlighted, there is a window
between 10Z-16Z where marine stratus could briefly press far enough
south to induce periodic IFR ceilings. Confidence in this
outcome is low at this time.
Monterey Bay Terminals... High confidence persistence forecast for
KMRY and KSNS as the marine layer remains deeply entrenched across
the bay. IFR to LIFR ceilings will be likely through the night
before diurnal heating clears out the stratus deck.
&&
.MARINE...
(Tonight through next Friday)
Issued at 947 PM PDT Sat Jun 13 2026
Gentle southerly breezes and moderate to rough seas with a low
south-southwesterly swell persist across most of the coastal
waters. Winds will remain fairly consistent through the weekend
as the seas subside. Fresh to strong north winds will develop in
the northern outer waters towards the middle of the week.
&&
.BEACHES...
Issued at 1230 PM PDT Sat Jun 13 2026
Long period southerly swell will continue through the weekend,
especially for south and southwest facing beaches. Hazardous beach
conditions are advertised, specifically for moderate to steeply
sloped beaches along the Pacific Coast of the North Bay, San Mateo,
Santa Cruz counties. A Beach Hazards Statement is in effect for
Pacific coast beaches along the central coast and the Bay Area
coast from late tonight through late Tuesday night. Be sure check
beach conditions before you head out. Sneaker waves will run up
the beach much farther than other waves, potentially catching
beachgoers by surprise and resulting in people being swept into
the water. Rip currents are strong enough to pull the strongest
swimmers away from shore. Swim near a lifeguard if possible. Stay
back from the beach, and away from jetties, piers, beachside
rocks, and other infrastructure near the water. Never turn your
back to the ocean!
&&
.MTR WATCHES/WARNINGS/ADVISORIES...
CA...Coastal Flood Advisory until 3 AM PDT Wednesday for CAZ006-506-
508.
Beach Hazards Statement through late Tuesday night for CAZ006-
505-509-529-530.
Coastal Flood Advisory until 3 AM PDT Tuesday for CAZ505-509-529-
530.
PZ...None.
&&
$$
SHORT TERM...Rowe
LONG TERM....Rowe
AVIATION...AM
MARINE...DialH
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, June 12, 2026
High Temperature
111°F at Lake Havasu City Az, AZ
111°F at Laughlin Bullhead Intl Ap, AZ
Low Temperature
24°F at Dixon Airport, WY
High Precipatation
3.69in at Punta Gorda Charlotte County Ap, 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).