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.

689
FXUS66 KMTR 090451
AFDMTR

Area Forecast Discussion
National Weather Service San Francisco CA
951 PM PDT Sun Mar 8 2026

...New AVIATION...

.KEY MESSAGES...
Updated at 132 PM PDT Sun Mar 8 2026

 - Near normal temperatures Monday and Tuesday.

 - Breezy conditions along the coast and coastal mountains
   Monday.

 - Warming conditions Wednesday through Friday.

&&

.UPDATE...
Issued at 844 PM PDT Sun Mar 8 2026

After the brief dip in temperatures Monday and Tuesday, the
warm weather returns by mid week. The pattern is different,
however. The weekend warmth was mainly driven by offshore winds.
These dry winds warm adiabatically as they move downslope and
compress under the higher pressure at lower altitudes. Contrast
that with the upcoming pattern that will be driven by a pure ridge
in the long wave pattern. This still warms the air from adiabatic
compression, but the sinking is large scale and doesn`t rely on
terrain or wind. This means lighter winds, clear skies and cool
mornings. One important difference between the 2 types of warm
patterns is the micro climates. Offshore winds bring warm and
clear conditions all the way to the beach. Ridging allows a
shallow marine layer to form and bring cooler, more humid
conditions to low-lying coastal areas (think June Gloom).

The strength of this ridge is noteworthy. By next weekend, there is
a 90% chance we set the daily record for 500 mb height, and a 50%
chance we set the monthly record for all March soundings (nearly
5,000 observations going back to 1948). There`s still some
uncertainty as to what that means for surface temperatures. The NBM
ensemble mean is roughly 5 degrees above the deterministic run by
the end of the week. We`ll likely be in the 80s across the interior
next weekend.

&&

.SHORT TERM...
Issued at 132 PM PDT Sun Mar 8 2026
(Tonight through Monday)

High pressure aloft that has been nosing over our service area the
last couple days is slowly weakening while retreating out to sea.
This has allowed for weak upper ridge axis to establish just off
the coast with a weak thermal trough surface reflection. This
thermal trough will be fairly short lived, but is has allowed weak
offshore flow to remain just a little longer than expected. As the
afternoon ticks on the ridge will continue to retreat, eroding the
offshore thermal trough. Heating across the land areas will
generate another thermal through and help to induce onshore flow
to develop. This has already begun in some areas. Onshore flow
will impact all regions of our service area by early this evening.
As a result, expect low clouds and some patchy fog to develop this
evening and overnight. This marine layer should be about 1000-1500
feet in depth and should erode fairly quickly tomorrow morning as
weak offshore winds at 925 mb develops for a short time. After the
morning low clouds and fog erode, Monday will be another nice day,
but on the cooler side. Relative to what we`ve had of course.
Temperatures will drift towards climatology the next couple days.
As part of this gentle pattern shift, we`ll see a weak dry
boundary (seen in OPC charts) come into the area on Monday. Given
that high pressure remains anchored and stout over the Eastern
Pacific, low pressure over us means a tightening pressure gradient
over the coastal waters. In turn, this means increasing winds out
of the Northwest for Monday. Look for breezy conditions along the
coast and the coastal mountains through the day on Monday.

&&

.LONG TERM...
Issued at 132 PM PDT Sun Mar 8 2026
(Monday night through next Saturday)

Monday night will bring another night of low clouds and fog for
the service area. Tuesday will be the closest we get to seasonal
normal temperatures as a broad upper trough passes just North of
the area. On the backside of the upper trough another upper ridge
will build. Unlike the last one with a West  East orientation,
the one building midweek will have a classic North-South ridge
axis. This will bring rapidly warming temperatures to our entire
area with the highest temperatures in East and South Bays and the
Central Coast. While models are consistent with the warm up, the
closer to water, the wider the spectrum of solutions. Inland
locations have fairly tight spreads of probabilities. In general
Wed-Fri, models have spread of temperature from the mid 70s to the
upper 80s, depending on location. Temps should moderate next
weekend as the ridge retreats slightly before building back
stronger the week of the 15th. The next shot at any liquid water
falling from the sky won`t be until the last week of March and
into April. By that point the odds of receiving beneficial
amounts starts to plummet. As of Sat 7 Mar, our service is
standing about 75-125% of normal on the water year, which began 1
Oct 2025.

&&

.AVIATION...
(06Z TAFS)
Issued at 948 PM PDT Sun Mar 8 2026

Onshore winds have returned to the area, bringing cooler and more
humid air to the coastal boundary layer. A narrow cloud deck is
already impacting HAF, MRY and SNS. The big question tonight is if
this cloud deck will expand to reach the busier Bay Area airports
or not. The trend in guidance has been marginally better over my
shift, but there is still nearly a 30% chance that the big 3
airports see ceilings around 13-17Z. If ceilings form, they will
likely be IFR based on the current impacts along the coast.

Vicinity of SFO...The terminal is clear for now, with stronger than
expected winds funneling through the San Bruno Gap. The surface
humidity has responded to the shift from offshore to onshore winds
this evening. At 3:20 PM the dew point depression was 27 degrees.
Now its down to 3 degrees. That means stratus has the potential to
surprise us and just form over the terminal, rather than advect in.
Otherwise strong WNW winds are expected Monday afternoon after any
low clouds clear.

Monterey Bay Terminals...While the Monterey Bay eddy hasn`t
developed yet, the southern half of the bay did fill with stratus as
of 04Z, and ceilings are slowly working their way south. These
impacts will persist through the night before gradually improving in
the late morning Monday.

&&

.MARINE...
(Tonight through next Saturday)
Issued at 844 PM PDT Sun Mar 8 2026

Building high pressure over the Eastern Pacific will generate
strong to near gale force northerly winds through Wednesday
morning. These winds will build very rough seas of 12 to 15 feet
in exposed waters. Conditions will improve somewhat later in the
week, but will remain hazardous to small craft.

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
CA...None.
PZ...Small Craft Advisory from 3 PM to 9 PM PDT Monday for Mry Bay.

     Small Craft Advisory until 3 PM PDT Tuesday for Pt Arena to Pt
     Reyes 0-10 nm-Pt Reyes to Pigeon Pt 0-10 nm.

     Small Craft Advisory from 9 AM Monday to 3 PM PDT Tuesday for
     Pigeon Pt to Pt Pinos 0-10 nm-Pt Pinos to Pt Piedras
     Blancas 0-10 nm.

     Gale Warning until 3 PM PDT Tuesday for Pt Arena to Pt Reyes 10-
     60 NM.

     Small Craft Advisory until 3 AM PDT Monday for Pigeon Pt to Pt
     Pinos 10-60 NM.

     Gale Warning from 3 AM Monday to 9 AM PDT Tuesday for Pigeon Pt
     to Pt Pinos 10-60 NM.

&&

$$

SHORT TERM...BFG
LONG TERM....BFG
AVIATION...Flynn
MARINE...Flynn

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

High Temperature

95°F at Zapata County Airport, TX

Low Temperature

-6°F at Walden Jackson County Airport, CO

High Precipatation

10.04in at Hampton Roads Executive Airport, VA

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