deformed-offering

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.

259
FXUS66 KMTR 050532
AFDMTR

Area Forecast Discussion
National Weather Service San Francisco CA
932 PM PST Wed Mar 4 2026

...New AVIATION...

.KEY MESSAGES...
Updated at 1204 PM PST Wed Mar 4 2026

 - Moderate to strong winds along the coast and at higher
   elevations through Saturday

 - Offshore winds bring warmer and drier weather this weekend into
   early part of next week

&&

.UPDATE...
Issued at 852 PM PST Wed Mar 4 2026

No changes to the forecast this evening. Blustery winds will
continue across our area overnight into Thursday, especially along
the coast and higher elevations of the East Bay Hills and southern
San Benito county. The strongest gusts today were mostly over the
coastal ranges this morning as the cold front began to move
through and in the post frontal environment. Marin County saw the
most gusts in the mid-upper 40s MPH but were isolated. A few
elevated locations in the East Bay Hills exceeded 40 MPH but
otherwise the rest of our area away from the coastal ranges saw
gusts peak in the mid-upper 20s MPH range. The gusty winds will
persist through Thursday and Friday, however today will likely be
the most dynamic of the three days with the frontal passage. The
gusty winds and gradual temperature increases Thursday and Friday
will continue to dry fuels ahead of an offshore flow event during
the weekend. Although fire weather concerns are low at the moment,
fuels will continue to dry at an accelerated pace through the
extended forecast with the CPC predicting warmer and drier
conditions through much of March.

&&

.SHORT TERM...
Issued at 1204 PM PST Wed Mar 4 2026
(This evening through Thursday)

A dry cold front associated with a low pressure system moving into
the Pacific Northwest is moving through the Bay Area, with some
lingering low level clouds across the Bay Area that should dissipate
through the early afternoon hours. The main forecast issue is the
breezy winds that will develop through the day today and last for
the next couple of days, as the low pressure system moves inland and
turns to the southeast into the Great Basin, strengthening the
pressure gradient and promoting stronger winds across the region.
Northwesterly wind gusts today will top out around 20 to 30 mph
across the valleys, and reach 35 to 45 mph in exposed coastal areas
and the higher elevations. Overnight, winds will abate in the valley
regions, but remain breezy and gusty in the coastal and higher
terrain areas, where wind gusts remain in the 30 to 40 mph range as
the wind turns to come from the north. This should promote low level
mixing overnight and thus help to disrupt stratus formation that
would otherwise occur. On Thursday, the wind gusts will resume from
the north in the valleys, with gust speeds around the same as those
seen today.

High temperatures for the next couple of days across the region
range from the lower to middle 60s in the lower elevations, with
patches of warm spots in the upper 60s, to the upper 40s and 50s
across the higher elevations. Low temperatures hover in the upper
30s to lower 40s away from the immediate coast, where low
temperatures in the upper 40s to lower 50s persist.

&&

.LONG TERM...
Issued at 1204 PM PST Wed Mar 4 2026
(Thursday night through next Tuesday)

Breezy and gusty winds will continue through Friday and Saturday as
a branch of the low pressure system retrogrades from the Great Basin
into the Desert Southwest, before emerging as a cut-off low that
traverses the northern end of Baja California and pauses just off the
coast. The interaction between this low and high pressure from the
eastern Pacific building into the Great Basin will result in an
inside slider pattern that will continue veering the winds to a
northeast flow late on Friday into Saturday. For context, as of the
last available report at 8 AM today, the SFO-WMC gradient was +7.6
mb (an onshore pressure gradient). The PG&E WRF ensemble model is
showing this reversing to around -8 mb (offshore) by the latter part
of Friday into Saturday, with the European and American global
ensemble models showing a slightly stronger offshore gradient at
around -10 mb at the same time. Thus, a warming and drying pattern
is expected where high temperatures rise into the lower to middle
70s for the valley regions, and even patches along the coast, for
the upcoming weekend.

As the eastern Pacific high starts to diminish and the cut-off low
moves eastwards again, the gradients will relax beginning on Sunday
and will result in calmer winds heading into the early part of next
week. Clouds may return to the region as the upper level flow shifts
to a more zonal pattern, but temperatures remain seasonably warm
and no rain is in sight for the foreseeable future, including
beyond the 7-day forecast as CPC outlooks suggest that
temperatures above seasonal averages and precipitation totals
below seasonal averages are likely towards the middle of March and
ensemble model means show a strong signal for ridging across the
western United States around this time.

&&

.AVIATION...
(06Z TAFS)
Issued at 932 PM PST Wed Mar 4 2026

The ACV-SFO pressure gradient has strengthened to 5.2 mb while
the SFO-SAC pressure gradient is 1.9 mb. Drier northwesterly
winds support VFR tonight and Thursday. A few areas of low clouds
continue over the higher coastal terrain otherwise it`s mainly
clear to clear. Breezy to gusty northwest to north winds are
forecast tonight and Thursday.

Vicinity of SFO...VFR. West wind 15 to 25 knots.

SFO Bridge Approach...Similar to SFO.

Monterey Bay Terminals...VFR. West to northwest wind 10 to 20
knots with occasional gusts to 25 knots.

&&

.MARINE...
(Tonight through next Tuesday)
Issued at 852 PM PST Wed Mar 4 2026

Gale force north-northwest winds this evening continue into
Thursday. These winds will build very rough seas of 12 to 15 feet
across exposed waters Thursday through Friday. Conditions will
gradually improve through the weekend as winds diminish and seas
subside.

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
CA...None.
PZ...Small Craft Advisory until 3 AM PST Thursday for SF Bay N of Bay
     Bridge.

     Small Craft Advisory until 9 PM PST Thursday for Mry Bay.

     Small Craft Advisory until 9 AM PST Friday for Pt Arena to Pt
     Reyes 0-10 nm.

     Gale Warning until 9 AM PST Thursday for Pigeon Pt to Pt Pinos 0-
     10 nm-Pt Pinos to Pt Piedras Blancas 0-10 nm-Pt Reyes to
     Pigeon Pt 0-10 nm.

     Small Craft Advisory until 9 AM PST Thursday for Pt Arena to Pt
     Reyes 10-60 NM.

     Gale Warning from 9 AM Thursday to 9 AM PST Friday for Pt Arena
     to Pt Reyes 10-60 NM.

     Gale Warning until 3 AM PST Friday for Pigeon Pt to Pt Pinos 10-
     60 NM.

&&

$$

SHORT TERM...DialH
LONG TERM....DialH
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:

  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 Tuesday, March 3, 2026

High Temperature

95°F at Castroville Muni Tx, TX

Low Temperature

-14°F at Berlin Municipal, NH

High Precipatation

2.69in at Indianapolis Intl Ap, IN

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