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
Tuesday, 28-Jul-2020 2:45 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.
595
FXUS66 KMTR 171132
AFDMTR
Area Forecast Discussion
National Weather Service San Francisco CA
332 AM PST Wed Dec 17 2025
...New AVIATION...
.KEY MESSAGES...
Updated at 304 AM PST Wed Dec 17 2025
- Beneficial, light rain showers today into tomorrow for the Bay
Area
- Widespread beneficial rainfall returns Friday into Saturday
- Rain, wind, and thunderstorms return Sunday
- Rainy and windy conditions are expected to continue into next
week, impacting the Christmas holiday travel
&&
.SHORT TERM...
Issued at 304 AM PST Wed Dec 17 2025
(Today and tonight)
A cold front will bring beneficial, light rain showers to the region
today. Most of the rain will fall in the morning with isolated to
scattered rain showers possible in the afternoon. Higher terrain of
the Bay Area can expect up to a quarter of an inch, the rest of the
Bay Area can expect a few hundredths, and the Central Coast can
expect drizzle at most. No adverse impacts are expected from this
round of rainfall.
&&
.LONG TERM...
Issued at 304 AM PST Wed Dec 17 2025
(Thursday through Tuesday)
Pre-frontal rain showers are expected Thursday. Once again, rainfall
will be beneficial and light with only up to a few hundredths
expected for the Bay Area with the Central Coast remaining dry
outside of some coastal/higher terrain drizzle. Widespread rainfall
returns Friday. The culprit is a conveyor belt of moisture that is
made possible by surface high pressure off the California/Mexico
border and surface low pressure off the coast of British Columbia.
The 80 member ensemble mean from the GEFS and ECMWF ensemble IVT
forecast depict values near 500 kg/ms with a gradient to near 250
kg/ms for the Central Coast. A cold front will provide the dynamics
necessary for precipitation and a corridor of increased winds. As of
now, everything through Friday looks beneficial and generally
unimpactful. We will have to monitor the evolution of the winds to
see if they trend more impactful (45+ mph), but there is moderate to
high confidence that the rain will be solely beneficial coming off
of a three week dry spell. Preparations should be made by Thursday
when it comes to making sure that gutters are cleaned out and loose
outdoor items are secured. Uncertainty begins to creep in Saturday
with some global ensemble members depicting that there may be a
break in the rainfall. A contributing factor is likely that the
deterministic ECMWF has a surface low developing and coming into
Northern California while the GFS does not have this feature. The
differences in the global models will have ramifications in the rest
of the long term forecast and even beyond into the holiday. While
seemingly little, this break will be consequential to the rest of
the forecast. Global ensemble clusters are in agreement that heights
will fall and widespread rainfall will return (if there is a break
on Saturday at all) Sunday. This is the part of the forecast where
impacts become more likely whether it be normal impacts from this
type of system, cumulative impacts from the preceding rainfall, or
holiday travel impacts. Rainfall is expected to increase in coverage
and intensity through the day Sunday as the aforementioned conveyor
belt of moisture gets reloaded and takes aim at the central part of
the state. Additional hazards on Sunday will be wind and a slight
(up to 20%) chance for thunderstorms. Rainy and windy conditions are
expected to continue into Monday and Tuesday as the firehose of
moisture slowly drifts north and then back south through the period.
It`s important to not get caught up in exact rainfall totals as they
are guaranteed to change between now and the event; however, for
context, San Francisco Downtown is expected to receive a month`s
(December average) worth of rainfall between now and Tuesday. HEFS
gives less than a 5% chance of mainstem river flooding over the next
10 days. More than likely what will happen is minor/nuisance
flooding in known problem areas like urban areas and flashy
creeks/streams. I will reiterate that home outdoor preparations need
to be made by Thursday. If you are travelling for the holiday like
many of us are, please take into account the weather and plan
accordingly by checking back with our forecast as well as the
forecast of the National Weather Service for the area to which you
are travelling to as well as the ones in between!
The Christmas holiday still remains outside of our official forecast
period. Everything that was said above in terms of confidence and
uncertainty apply here, even moreso. Global models continue their
disagreement into the holiday with the ECMWF providing a wetter and
more impactful solution by way of a longwave trough while the GFS
has a drier and less impactful solution with a cutoff low meandering
off of Point Conception. If rain happens immediately after the long
term forecast, it is expected to be more of a Central Coast event
than a North Bay event.
&&
.AVIATION...
(12Z TAFS)
Issued at 332 AM PST Wed Dec 17 2025
A cool front with low clouds, fog and periodic light rain/drizzle
/LIFR-IFR/ moves southward across the forecast area today. Partial
clearing in the late morning and afternoon from north to south. Low
clouds and patchy fog redevelop tonight and Thursday morning.
Vicinity of SFO...IFR with periodic light rain up to the arrival
of a cool front later in the morning. MVFR-VFR from late morning
through the afternoon and evening. Light and variable wind becoming
west near 10 knots from late morning through the evening.
SFO Bridge Approach...Similar to SFO.
Monterey Bay Terminals...Low clouds /IFR-MVFR/ increasing this
morning with periodic light rain/drizzle. Partial clearing
possible during the afternoon, otherwise IFR redeveloping tonight
and Thursday morning. Light and variable winds becoming northwest
near 10 knots during the afternoon and early evening.
&&
.MARINE...
(Today through Monday)
Issued at 304 AM PST Wed Dec 17 2025
A cool front with light rain will move southward over the coastal
waters and bays today. Periodic wet weather continues through late
week with additional rain arriving Saturday night through Sunday.
Moderate seas will prevail through the week.
&&
.MTR WATCHES/WARNINGS/ADVISORIES...
CA...None.
PZ...None.
&&
$$
SHORT TERM...Sarment
LONG TERM....Sarment
AVIATION...Canepa
MARINE...Canepa
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 (1.06 - 27-Feb-2018 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 Monday, December 15, 2025
High Temperature
88°F at Palm Springs Asos, CA
Low Temperature
-15°F at Mount Washington, NH
High Precipatation
2.76in at Shelton Ap, WA
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 (5.04 - 28-Jul-2020 see history).