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.

598
FXUS66 KMTR 170534
AFDMTR

Area Forecast Discussion
National Weather Service San Francisco CA
934 PM PST Tue Dec 16 2025

...New UPDATE, AVIATION, MARINE...

.KEY MESSAGES...
Updated at 251 PM PST Tue Dec 16 2025

 - Light rain will spread into the North Bay and portions of the
   rest of the Bay Area tonight into tomorrow.

 - A second system arrives late Thursday with beneficial rain
   continuing through Saturday.

 - Confidence continues to increase that a stronger, impactful
   system will arrive late weekend and continue into next week.

&&

.UPDATE...
Issued at 929 PM PST Tue Dec 16 2025

A mix of low and high clouds comes over the Bay Area tonight and
will continue to develop into the Central Coast as the frontal
boundary moves across the region. Radar returns show the band of
rain traveling mainly west-to-east across Mendocino County into
the northern Central Valley, and the latest high resolution model
guidance suggests that the band will begin to enter the North bay
in the pre-dawn hours of Wednesday morning before progressing
through the Bay Area, beginning to dissipate as it reaches the
South Bay and Santa Cruz County in the late morning and early
afternoon hours.

DialH

&&

.SHORT TERM...
Issued at 251 PM PST Tue Dec 16 2025
(This evening through Wednesday)

A weak system is currently bringing light rain to the North Bay.
Showers have been fairly isolated so only a few locations in
northern Sonoma and Napa counties reporting totals of a few
hundredths of an inch. Scattered showers will continue through this
afternoon/evening with the bulk of the precipitation to our north
over Mendocino and Humboldt counties. This precipitation will shift
southwards overnight, but, it won`t be as widespread with showers
largely diminishing/falling apart as they move into the North Bay.
Not much change to rain totals for this event, totals continue to be
highest in the North Bay with up to 0.1" in the valleys and 0.2"-
0.3" in the coastal mountain ranges. Showers will move south of the
Golden Gate Bridge by mid to late tomorrow morning with the
potential for up to 0.1" along the Bay Shoreline and San
Francisco/San Mateo peninsula. Overall, this is a light and
beneficial rain system and leaves the storm door open behind it for
additional systems to enter California.

Residents of the North and East Bays may notice it is less foggy
today than it has been for the past few days. Tule Fog has been the
talk of the last few weeks as it persisted over the Central Valley
and portions of the Bay Area. If you`re tired of the gloom of fog,
you`re in luck. This system reduces fog chances across the Bay Area
but you may not see the sun just yet as generally overcast
conditions persist while this system rolls through. Given morning
fog and overcast skies, lowered the forecast high temperatures for
the North Bay into the mid 50s from the upper 50s. This should be
the last day requiring major adjustments to the temperature given
the series of incoming systems (Long Term) and more zonal upper
level flow compressing high pressure/diminishing fog potential.

&&

.LONG TERM...
Issued at 251 PM PST Tue Dec 16 2025
(Wednesday night through next Monday)

Things remain active in the long term with a second system expected
late week and a third system expected next week. Rain from the first
system (Tuesday - Wednesday) will diminish by Wednesday afternoon
with dry weather and upper level ridging briefly rebounding. The sun
may even briefly come out Wednesday afternoon in this break between
systems. By early Thursday morning, the next system will arrive and
bring with it renewed, more widespread rain chances across the
entire Bay Area and portions of the Central Coast. This system is
associated with a surface low pressure system and slight upper level
trough moving into the Pacific Northwest. This system will help to
compress surface high pressure and replace upper level ridging with
more zonal upper level flow. PWAT values associated with this system
peak around 1.5" to 1.6" with IVT values ranging from 250 to 500
kg/ms. The PWAT plume initially stays to our north before moving
into our CWA Friday this plume then lingers over the Bay Area and
Central Coast for much of the weekend. QPF totals have gone up for
this system with between 2.0"-2.5" across the North Bay Coastal
Mountains, 1"-1.5" for interior Marin and the North Bay Valleys, 0.5-
1.0" south of the Golden Gate, and up to 0.25" across the Central
Coast. These values may be further refined as we get closer to
Friday with NBM percentile guidance suggesting the current forecast
is on the lower end. While this system is not expected to be the
strongest of the three, preparations for wet weather should be
completed by Thursday as the second and third systems do not have a
defined break between them.

The third system is expected to be the most impactful, but, there is
still some forecast uncertainty as it is a more prolonged system and
is not entirely within our 7-day forecast period. Beginning Sunday,
a stronger, deep upper level trough will approach the West Coast and
bring a renewed source of tropical moisture into the region. This
storm will bring potentially moderate to heavy rain with the highest
rain totals in the North Bay. Given that totals continue to
fluctuate, it is still too early to give exact totals for this
event. The key messages are as follows: confidence is increasing
that a potentially impactful atmospheric river will arrive Sunday
and continue for much of next week. This system will bring periods
of moderate to heavy rain and potentially impact holiday travel. If
you are traveling next week, make sure to check road conditions,
flight delays, and the most up to date weather forecast for both
here and the location that you are traveling to (especially if it is
within California). Winds look to strengthen next week with this
system but, in agreement with the previous forecaster, there is not
a clear signal that winds will meet wind advisory criteria. All in
all, this system bears keeping an eye on especially as the forecast
surrounding it becomes clearer. Make sure to stay up to date with
the forecast so you can best prepare for any upcoming holiday travel.

High temperatures rise slightly (particularly for regions that have
been foggy) with more seasonal high temperatures in the 50s to low
60s across the region. Morning low temperatures stay in the 40s to
low 50s with some patchy cooler temperatures in the interior
mountain ranges.

&&

.AVIATION...
(06Z TAFS)
Issued at 929 PM PST Tue Dec 16 2025

Generally MVFR-IFR ceilings are developing across the Bay Area as a
weak frontal boundary moves into the Bay Area overnight. Light rain
is expected to move into the North Bay imminently and progress
southward into the Bay Area through the late morning hours on
Wednesday. The boundary will dissipate as it reaches the Monterey
Bay region. Stratus coverage on Wednesday morning is a little
uncertain, especially for terminals close to the SF Bay, but expect
a gradual clearing through the late morning and early afternoon
hours. Recent rainfall combined with clearing skies will promote
stratus formation Wednesday night.

Vicinity of SFO... MVFR ceilings through the night with light rain
expected Wednesday morning, with IFR conditions possible as the rain
band moves through. Conditions will improve through Wednesday
morning and afternoon. The latest high resolution model guidance is
backing off on the stratus impacting the terminal, but will keep a
SCT group in the TAF for this update. Stratus returns to the
terminal late Wednesday night. At OAK, greater confidence in stratus
impacts through the day with stratus forming later Wednesday
evening. Light winds continue overnight, before gentle northwest
winds return Wednesday morning and afternoon.

SFO Bridge Approach... Low confidence that lingering stratus over
the SF Bay impacts the approach path through the day on Wednesday.
Otherwise, similar to SFO.

Monterey Bay Terminals... VFR conditions continue for the next few
hours before MVFR-IFR conditions develop tonight, with a low
confidence for drizzle at MRY Wednesday morning. Light drainage
winds develop overnight before northwest flow resumes Wednesday
morning as the skies begin to clear at SNS. For MRY, confidence is
increasing for a period of VFR conditions Wednesday afternoon.
Stratus returns to the terminals late Wednesday afternoon into the
evening, with moderate confidence on timing.

&&

.MARINE...
(Tonight through next Monday)
Issued at 929 PM PST Tue Dec 16 2025

Light rain travels over the northern waters tonight through
Wednesday afternoon as a plume of moisture arrives from the north.
Light to moderate west to northwesterly breezes also prevail
through Wednesday afternoon. Rain chances return by Thursday night
and increase into the upcoming weekend. Moderate seas will
prevail through the remainder of the week.

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
CA...None.
PZ...None.
&&

$$

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 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 = '&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