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

195
FXUS66 KMTR 181958
AFDMTR

Area Forecast Discussion
National Weather Service San Francisco CA
1258 PM PDT Mon May 18 2026

...New SHORT TERM, LONG TERM, FIRE WEATHER...

.KEY MESSAGES...
Updated at 1251 PM PDT Mon May 18 2026

 - Breezy to windy conditions, especially across the North, East,
   and South Bay Mountains and the Santa Cruz Mountains continue
   through tonight

 - Elevated fire weather concerns continue through today across
   the interior due to very dry conditions and breezy winds

 - Above normal temperatures continue through midweek with seasonal
   temperatures returning late week

&&

.SHORT TERM...
Issued at 1251 PM PDT Mon May 18 2026
(This evening through Tuesday)

Gusty offshore winds have started to come down across the region and
will continue to ease through the remainder of the day. Current
gusts across the lower elevations are peaking around 25-30 mph with
gusts across the higher elevations peaking between 35-45 mph. The
strongest gust observed during this wind event was 86 mph right
around midnight at Mt. Umunhum where the station is at an elevation
of 3319 feet. This tracks pretty well with when the SFO-WMC pressure
gradient peaked (-7.60 mb) around 1AM and again around 5AM. The SFO-
WMC gradient is currently around -4.3 mb and is expected to continue
easing through the remainder of the day. Winds remain lightly
offshore across the interior through the remainder of today into
tomorrow but winds will be weaker. We will see a return to our
normal breezy afternoon/evening winds that ease overnight starting
Tuesday.

Upper level ridging continues to dominate the Pacific Ocean while
broad upper level troughing prevails over the Western United States.
At the surface, high pressure prevails over the Pacific while a
coastal trough develops along the California coast. Warmer
temperatures are expected to continue Tuesday through Thursday. This
is thanks both to ridging offshore suppressing the marine layer and
a warmer, drier airmass moving in in the wake of this weekend`s
strong offshore winds. Interior high temperatures will generally be
in the 80s with the hottest portions of the North and East Bays in
the low 90s. Coastal areas will be slightly cooler in the 60s to mid
70s. Dry conditions are expected to prevail through much of the
upcoming week with daytime relative humidity values dropping into
the 10`s to 20`s. While fire weather concerns are lower now that the
winds are easing, fine fuels (grass, shrubs) are dried out and are
ready to burn. If you are engaging in any outdoor activities
involving flames or are towing something, keep a close eye on it and
prevent sparks from spreading.

&&

.LONG TERM...
Issued at 1251 PM PDT Mon May 18 2026
(Tuesday night through next Sunday)

The overall pattern remains the same for much of the upcoming week.
High temperatures will stay above seasonal normals through Thursday
with highs in the 80s to low 90s across the interior and 60s to 70s
along the coast. Patchy moderate heatrisk is forecast across urban
areas but it is note widespread enough to necessitate a Heat
Advisory. If you are spending time outdoors this week make sure to
drink plenty of water and take breaks in the shade as needed. Winds
generally remain offshore with diurnally breezy conditions expected.
Friday into the weekend a pattern change looks likely. Long range
guidance suggests upper level ridging will weaken and shift westward
over the Pacific while broad upper level troughing dominates the
West Coast. With high pressure shifting away, onshore winds return
and the marine layer will be able to redevelop by late week. A
shallow (~500 ft) marine layer will redevelop mid to late week but
will deepen to ~1000 ft by Friday. This, and receding high pressure,
will kick off a cooling trend with interior temperatures returning
to the 70s to low 80s and coastal areas to the 60s. The return of
the marine layer will help to alleviate dry daytime conditions,
further reducing fire risk late next week. &&

.AVIATION...
(18Z TAFS)
Issued at 1021 AM PDT Mon May 18 2026

VFR conditions prevail through the TAF period. Breezy and gusty
northeast winds will gradually diminish through the next couple of
hours as an onshore push returns to the coastal regions this
afternoon, with the coastal breeze continuing through the evening.
Breezy winds will continue across the interior mountains of the Bay
Area through the night, with northeast winds spreading across the
interior valleys Tuesday morning towards the end of the 24-hour TAF
period. Beyond that, Tuesday`s coastal breezes look to be stronger
than today`s.

Vicinity of SFO... VFR conditions through the TAF period. Breezy and
gusty northeast winds will turn more northwesterly through the
afternoon, before diminishing through the evening and remaining
light overnight through Tuesday morning. West-northwest winds will
resume on Tuesday afternoon.

SFO Bridge Approach... Similar to SFO.

Monterey Bay Terminals... VFR conditions through the TAF period.
Breezy northwest winds will develop imminently and continue into the
evening. Winds remain light overnight before resuming Tuesday
afternoon after the end of the TAF period.

&&

.MARINE...
(Today through Saturday)
Issued at 1021 AM PDT Mon May 18 2026

Winds continue to diminish throughout the marine environment, but
moderate to rough seas and moderate to fresh northwest breezes
will still offer hazardous conditions for small craft into the mid
weak before easing for most zones. Fresh to strong northwest
breezes will remain hazardous for small craft into the late week
for the northern outer zone.

&&

.FIRE WEATHER...
Issued at 1251 PM PDT Mon May 18 2026

Gusty north to northeast winds will continue through this
afternoon before easing tonight into tomorrow. Peak gusts between
35 to 45 mph are still possible across the higher elevations into
this evening. Daytime humidity retention remains poor with most
sites staying around 10-25% across the interior and higher peaks
with limited overnight recoveries. Winds ease by Tuesday but fire
weather concerns will linger through late week as light offshore
flow continues and daytime humidities remain poor.

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
CA...Coastal Flood Advisory until 3 AM PDT Tuesday for CAZ506.

PZ...Small Craft Advisory until 3 PM PDT this afternoon for SF Bay N
     of Bay Bridge.

     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 Reyes to Pigeon Pt 0-10 nm.

     Small Craft Advisory until 9 PM 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...DialH
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:

  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 (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 Sunday, May 17, 2026

High Temperature

102°F at Canadian, TX
102°F at Castroville Muni Tx, TX

Low Temperature

14°F at Stanley Ranger Station, ID

High Precipatation

2.53in at Miami Opa Locka 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 = '&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 (5.04 - 28-Jul-2020 see history).

deformed-offering