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.
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
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.
431
FXUS66 KMTR 161150
AFDMTR
Area Forecast Discussion
National Weather Service San Francisco CA
450 AM PDT Sun Mar 16 2025
...New AVIATION, MARINE, BEACHES...
.SYNOPSIS...
Issued at 132 AM PDT Sun Mar 16 2025
Light showers across the North Bay this morning, with steady rain
and gusty winds spreading into the Bay Area and Central Coast later
this afternoon into Monday. Light rain is possible in the Bay Area
on Wednesday and again towards the end of the week. Temperatures
remain cool to average through the forecast period.
&&
.SHORT TERM...
(Today and tonight)
Issued at 132 AM PDT Sun Mar 16 2025
Patchy low stratus covers the Bay Area, with light showers reported
across the North Bay. The short term weather forecast is dominated
by an approaching cold front from a low pressure system located
around 900 miles west of Cape Mendocino, expected to move due east
over the next 24 hours. The approach of the low pressure system will
enhance the pressure gradient, causing winds to strengthen through
the day. The Wind Advisory for the North Bay mountains has been
extended to cover the North Bay valleys and coast; it is still valid
from 11 AM to 11 PM today. In addition, a second Wind Advisory has
been issued for the city of San Francisco, the San Mateo Peninsula,
the Santa Cruz Mountains, and the East Bay, valid from 5 PM this
evening to 2 AM Monday morning. In both cases, strong southerly
gusts up to 45 to 50 miles per hour are expected, with the
possibility for gusts up to 60 miles per hour in favored locations
along the coast and through passes and gaps. Gusty winds are also
expected in the Central Coast, especially along the coast and at the
ridgelines, but there is not enough confidence to issue a Wind
Advisory for the region at this time.
Rain intensity will increase across the North Bay through the day,
and the main rain band will arrive later in the afternoon, passing
through the Bay Area in the evening hours and the Central Coast late
evening and overnight. The WPC has issued a Marginal Risk for
excessive rainfall for the northern half of Sonoma County, meaning
that there is at least a 5% probability of rainfall exceeding flash
flood guidance. Rain totals in the risk area range between 0.75" to
1" in the lower elevations, and 1.5-3" in the higher elevations,
with isolated totals of 4" possible in the Mayacamas. Elsewhere in
the region, rainfall totals will be generally beneficial, with
totals ranging from 0.25" to 0.5" in the lower elevations of the Bay
Area and Central Coast, with totals as high as 0.75" in the North
Bay valleys and coastal Santa Cruz County, and up to 2" possible in
the coastal ranges.
Chilly lows persist in the extreme southern regions of Monterey
County where this morning`s lows dip in to the mid 30s. Elsewhere,
lows this morning range from the upper 30s to the middle 40s in the
inland valleys, and the middle 40s to near 50 along the coast. High
temperatures range from the middle to upper 60s in the interior
valleys of the Bay Area and Central Coast, the upper 50s to lower
60s in the North Bay valleys, the Bayshore, and the coast, and into
the lower to middle 50s in the higher elevations.
&&
.LONG TERM...
(Monday through Saturday)
Issued at 132 AM PDT Sun Mar 16 2025
Scattered showers persist through the day on Monday, with a chance
that some of them could bring convective activity to the region. The
SPC has placed the Bay Area and interior Central Coast in a general
risk for non-severe thunderstorms for Monday. At this time, the
current forecast brings the greatest chances for thunder into the
Bay Area through the daytime hours, with 10-20% probabilities for
thunder continuing into the afternoon before diminishing in the
evening. The most likely impacts include small hail, locally heavy
downpours, and localized strong gusts.
A new storm system does arrive Wednesday, but because the storm
track is shifted to the north, the Pacific Northwest and northern
California will bear the brunt of the impacts with only minor
impacts expected in the North Bay, with up to a half of an inch in
the coastal ranges, and significantly less (up to 0.3") in the
valleys and Bay Area and virtually nothing for the Central Coast.
Another system is possible heading towards the latter part of the
week into the upcoming weekend. Confidence in the specific impacts
remains low, but indications from the model ensemble clusters point
to the greatest impacts being confined to the North Bay.
Throughout all of this, temperatures remain cool to near the
seasonal average across the region. The incoming system knocks
temperatures back down on Monday, with the inland valleys dropping
into the upper 50s while coastal regions see highs in the lower to
middle 50s. Afterwards, the temperatures will slowly climb, and by
the upcoming weekend, temperatures will warm to near or slightly
above the seasonal average with the inland valleys reaching the
upper 60s to near 70, while the Pacific coast sees highs in the
upper 50s to the middle 60s.
&&
.AVIATION...
(12Z TAFS)
Issued at 434 AM PDT Sun Mar 16 2025
With the exception of KSTS this morning and early this afternoon
will be a watch and wait scenario as we wait for a cold front to
approach from the NW. Very shallow showers well ahead of the main
front continue to stream over KSTS with periods of -ra to -shra.
This will be the case through this afternoon. Southerly flow will
ramp up as cigs form and lower this afternoon/evening with MVFR
initially. A mix of IFR to MVFR conditions with rain and wind
Sunday evening and overnight with -shra and lifting cigs by early
Monday.
Vicinity of SFO...VFR cigs with moderate winds through 18-19Z.
There after, do have some cigs developing around MVFR with gusts
approaching 30kts. Given the wind direction and speed...west plan
will likely be switched to east impacting operations. On top of
that, moderate to heavy rain arrives 6-9Z Monday. Despite the
uptick in wind conf is only about 30-40% of exceeding 35kts.
Therefore, will hold off on AWW for now.
SFO Bridge Approach...Similar to SFO.
Monterey Bay Terminals...ASOS finally caught on that cigs were not
occurring. VFR with SKC expect this morning. A few showers
possible late this afternoon, but light rain more likely after
00Z. Winds will be gustier at KSNS given the SE flow.
&&
.MARINE...
(Today through Friday)
Issued at 434 AM PDT Sun Mar 16 2025
Southerly winds will increase over the coastal waters and bays as
a cold front approaches from the NW today. The increasing winds
will result in hazardous conditions with steep wind waves with a
deteoriating sea state. The cold front will also usher in rain,
heavy at times, Sunday afternoon through Monday. A slight chance
for thunderstorms will be possible on Monday for the northern
waters. Southerly winds briefly ease late Sunday night before
northwest winds increase behind the cold front.
&&
.BEACHES...
Issued at 445 AM PDT Sun Mar 15 2025
If you`re thinking of hitting the beaches before the rain arrives
use caution today. An energetic surf zone will develop as a
moderate period swell will create increase shore break with low
end sneaker wave threat. As always, please remember to stay off
of rocks and jetties, keep pets on a leash, and never turn your
back on the ocean!
&&
.MTR WATCHES/WARNINGS/ADVISORIES...
CA...Wind Advisory from 5 PM this afternoon to 2 AM PDT Monday for
CAZ006-508>510-512-515.
Wind Advisory from 11 AM this morning to 11 PM PDT this evening
for CAZ502>506.
PZ...Gale Warning from 9 AM this morning to 9 PM PDT this evening 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-SF Bay N of Bay Bridge.
Small Craft Advisory from 9 AM this morning to 3 AM PDT Monday
for Mry Bay-Pigeon Pt to Pt Pinos 0-10 nm-Pigeon Pt to Pt
Pinos 10-60 NM.
Small Craft Advisory until 9 AM PDT this morning 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.
Small Craft Advisory from 3 PM this afternoon to 3 AM PDT Monday
for Pt Pinos to Pt Piedras Blancas 0-10 nm.
&&
$$
SHORT TERM...DialH
LONG TERM....DialH
AVIATION...MM
MARINE...MM
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:
- Browse to www.weather.gov
- Use the search box on the left to search for your city, state
- Look at the URL in the 'Forecast Discussion' link near the bottom of the page
- Use the 3-character abbreviation is in the &issuedby=XXX parameter on the
Forecast Discussion link (XXX will be your local office)
- 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 Friday, March 14, 2025
High Temperature
106°F at Cotulla La Salle County Ap, TX
106°F at Faith Ranch Airport, TX
Low Temperature
5°F at Eureka Airport, NV
5°F at Wolf Creek Pass, CO
5°F at Pinedale Ralph Wenz Field Ap, WY
High Precipatation
2.06in at Cahokia St Louis Downtown Ap, IL
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 = '°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).