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.

639
FXUS66 KMTR 081702
AFDMTR

Area Forecast Discussion
National Weather Service San Francisco CA
902 AM PST Sun Nov 8 2026

...New UPDATE, MARINE...

.KEY MESSAGES...
Updated at 1128 AM PST Sat Nov 7 2026

 - Slightly warmer and dry weather through the middle of the
   upcoming week

 - Coastal flooding due to high tides through Friday (11/13)

 - Hazardous beach conditions through Monday

 - Unsettled weather returns by late week

&&

.UPDATE...
Issued at 901 AM PST Sun Nov 8 2026

Patchy to areas of dense fog were reported this morning across the
North Bay Valleys, Russian River valley, in and around Livermore,
locations such as Marina, and down in the southern Salinas Valley
(around King City). These conditions are improving currently and
expected to continue to do so through mid-to-late morning as surface
temperatures warm throughout the afternoon. The cold front to our
north is dissipating and will have only minor impacts to this
afternoon`s forecast maximum temperatures.  However, high clouds
will continue over the North Bay and Bay Area through much of the
day. That said, no updates are anticipated at this time.

RGass

&&

.SHORT TERM...
Issued at 1133 PM PST Sat Nov 7 2026
(Tonight through Monday)

A cold front is forecast to move onshore early Sunday morning,
mainly impacting the Pacific Northwest and Northern California. As
it moves on land, it will dissipate rather quickly, therefore no
rain is expected in our area with this system. Ahead of the front
however, high and low cloud cover has increased across the Bay Area
and Central Coast. While low clouds are forecast to burn off by
Sunday morning, high clouds will remain. Weak cold air advection
along with an enhanced moisture flux (from the low clouds) will be
sufficient to slightly decrease temperatures Sunday through Monday
along the coast and across the Bay Area. Despite this cooling,
maximum temperatures remain 5-10 deg F above normal at the
aforementioned locations. The interior South Bay and Central Coast
valleys are likely to experience temperatures 10-15 deg F above
normal through Monday.

Got beach plans? Check out the BEACHES section of the AFD for safety
tips and more information on the Beach Hazards Statement and Coastal
Flood Advisory.

&&

.LONG TERM...
Issued at 1133 PM PST Sat Nov 7 2026
(Monday night through next Saturday)

High pressure builds over the region as zonal to weak ridging
reforms in the wake of Sunday`s frontal passage. This pattern will
support another round of gentle offshore flow beginning Monday
night. As a result, above normal temperatures persist through
Wednesday.

Thursday is roughly when we can expect conditions to begin to
change. A deep mid to upper level trough approaches our coast
allowing winds to shift south-southwesterly. This wind direction may
assist in drawing in moisture from the Eastern Pacific, though
confidence remains low on exactly how much transport will occur.
Both the ensemble ECMWF and GFS members advertise precipitable water
values around the 75th percentile late next week with a *very* low,
non-zero chance for thunderstorm activity. The potential for rain
enters the chat as early as Friday and is likely to persist into the
weekend. As we get closer to the event, the exact details on the
system`s trajectory and expected rainfall amounts will be refined.
In the meantime, it is advised to begin preparations for the winter
season.

&&

.AVIATION...
(12Z TAFS)
Issued at 338 AM PST Sun Nov 8 2026

Definitely a mixed bag overnight and early this morning as a weak
front approaches from the N. Patchy stratus developed early in
the night and these patches have be transient with some terminals
remaining cloudy and others SCT out. Additionally, patchy dense
fog continues to impact the N Bay with LIFR. Needless to say, low
conf forecast this morning. Regardless, any impacts to flight CAT
will improve mid morning 16-17Z. Expect VFR this afternoon and
early tonight.

Vicinity of SFO...MVFR cigs have given way to VFR. Latest SAT/CAM
trends shows VFR should hold into the AM.  VFR this afternoon.

SFO Bridge Approach...Far SE are of approach has the best chc at
shallow CIGS.

Monterey Bay Terminals...VFR as earlier CIGs cleared. Some
additional CIG develop is poss at SNS this AM. VFR this afternoon
with MVFR CIGs returning late tonight.

&&

.MARINE...
(Today through Friday)
Issued at 901 AM PST Sun Nov 8 2026

Moderate to fresh northerly breezes over the coastal waters will
persist into the beginning of the upcoming work week with rough to
very rough seas and hazardous conditions for small craft.
Elevated mixed long period swell will continue through the week,
increasing further by the end of the forecast period.

&&

.BEACHES...
Issued at 350 AM PST Sun Nov 8 2026

Final day of the weekend and beach weather will be rather nice.
However, the surf zone won`t be nice. In case you missed it, a Beach
Hazard Statement remains in effect. Latest buoy obs show the surf
zone remains energetic due to mixed swells and longer periods. As
such, large shore break, sneaker waves, and stronger rip currents
will be possible. Breaking waves of 12 to 16 feet are expected at
exposed beaches and up to 18 ft at favored break point. Spring
tides will also increase the currents and bring higher tides than
normal. Waves can sweep across the shoreline without warning,
pulling people into the sea from beaches, jetties, and rocks. Stay
off of jetties, piers, rocks, and other waterside infrastructure.
Remain out of the water if you`re not an experienced swimmer to
avoid hazardous surf and never turn your back on the ocean! There
may be a lull in wave activity early next week, but longer range
forecasts show additional swells impacting the coast late next
week.

Coastal Flood Advisory:

A combination of high astronomical tides and thermal expansion from
warmer than normal water will result in tidal flooding concerns
across Bayshore locations in the San Francisco, San Pablo, and
Monterey Bays. At the San Francisco tide gauge, high tide is
expected to be 1.6 ft above normal (7.4 ft MLLW) at 10:06 AM Sunday
11/8, 1.6 ft above normal (7.4 ft MLLW) at 10:35 AM Monday 11/9, 1.5
ft above normal (7.3 ft MLLW) at 11:04 AM Tuesday 11/10, 1.4 ft
above normal (7.2 ft MLLW) at 11:35 AM Wednesday 11/11, 1.4 ft above
normal (7.2 ft MLLW) at 12:10 PM Thursday 11/12, 1.2 ft above normal
(7.0 ft MLLW) at 12:49 PM Friday 11/13. These predictions include up
to 1.5 ft of surge that will enhance the astronomical tide and
flooding threat. High tide varies up to 90 minutes earlier or later
along the Pacific Coast and through the San Francisco Bay,
respectively. In addition, long-period swell will create hazardous
conditions along the Pacific coast beaches with an increased risk of
sneaker waves and rip currents.

These Spring Tides are due to a new moon on Monday, which is much
lower in the sky this time of year compared to a full moon. In 2
weeks, the astronomical tides will be about 0.8` higher than this
round, and the total water level could be more than a foot higher if
we get SW winds and/or lower pressure. This combination would bring
the total water level near the 1% annual exceedance probability
(2.85` above normal), or a 1 in 100 year event. Something to keep an
eye on for the week of Thanksgiving.

Sarment/Flynn/MM

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
CA...Beach Hazards Statement through Monday evening for CAZ006-505-
     509-529-530.

     Coastal Flood Advisory until 4 PM PST Friday for CAZ006-506-508-
     530.

     Coastal Flood Advisory until noon PST Tuesday for CAZ505-509-529.

PZ...Small Craft Advisory until 9 PM PST Monday for Mry Bay-Pigeon Pt
     to Pt Pinos 0-10 nm-Pigeon Pt to Pt Pinos 10-60 NM-Pt Pinos
     to Pt Piedras Blancas 0-10 nm.

     Small Craft Advisory until 3 PM PST Monday for Pt Arena to Pt
     Reyes 0-10 nm-Pt Arena to Pt Reyes 10-60 NM-Pt Reyes to
     Pigeon Pt 0-10 nm.

&&

$$

SHORT TERM...Navarrete
LONG TERM....Navarrete
AVIATION...MM
MARINE...JM

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 Saturday, November 7, 2026

High Temperature

89°F at Roosevelt Roads, PR
89°F at Majuro Atoll/Nws, MH

Low Temperature

15°F at Leadville, CO

High Precipatation

1.38in at Kerrville Municipal Ap, TX

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