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.
774
FXUS66 KMTR 081718
AFDMTR
Area Forecast Discussion
National Weather Service San Francisco CA
918 AM PST Sat Feb 8 2025
...New AVIATION...
.SYNOPSIS...
Issued at 1207 AM PST Sat Feb 8 2025
Mostly clear skies and cold mornings will persist through early next
week. The colder inland areas will drop below freezing each night.
An atmospheric river will bring significant rain from Wednesday-
Thursday.
&&
.UPDATE...
Issued at 857 AM PST Sat Feb 8 2025
This morning`s frost and freeze products are allowed to expire at
9AM. No other changes to the forecast were made at this time.
&&
.SHORT TERM...
(Today and tonight)
Issued at 1207 AM PST Sat Feb 8 2025
The GOES West night fog product shows mostly clear skies across the
Bay Area, with some patches of stratus over the Central Coast. The
clear skies are allowing enhanced radiational cooling, and
several inland areas are already in the 30s. As the temperature
drops to the dew point, the rate of cooling will likely slow
through the morning, although the air mass is also on a drying
trend, so this moderating effect won`t be as pronounced as
normal. Overall the observed temperature is matching the hourly
forecast well and the frost/freeze products remain unchanged.
After the sun comes up, the clear skies will allow temperature
will begin to climb, but we`ll only reach the mid-50s this
afternoon for most populated areas. Higher terrain won`t get out
of the 40s.
&&
.LONG TERM...
(Sunday through Friday)
Issued at 1207 AM PST Sat Feb 8 2025
Why is it getting so cold? After all the deep air mass isn`t that
cold. The 850 mb temperature is only in the 10-25th percentile
this weekend. This cooling is driven more by dry air supporting
enhanced radiational cooling. As the surface dew points drop into
the 20s-30s under clear skies, there is nothing to slow down
nocturnal cooling. Lower level winds will shift to light offshore
Sunday, causing the air mass to dry further. The PWAT looks very
likely to drop below 0.2", which is in the bottom 2% for
February. This very dry air mass will continue to support clear
skies and very cold mornings through early next week. Sunday and
Monday look to be the coldest. Our official forecast brings
downtown San Francisco to 39 Monday morning. That mark is roughly
10 degrees below normal, and has only been reached 3 times in the
last decade (2/23/23, 2/24/23, 3/1/23). Meanwhile San Jose has a
60% chance of dropping below freezing for the first time since
2017.
Everything changes on Wednesday. The winds will shift from
northerly to southerly as low pressure system moves over the
Pacific Northwest. An associated warm front and cold front will
both push through California, bringing a prolonged period of
moderate to occasionally heavy rain that will linger into Friday.
The heaviest period currently looks to be from late Wednesday
through late Thursday, when 1-3" of rain is expected in the
lowlands with more in the coastal mountains. This will likely
cause some flooding issues for urban environments and smaller
streams. The USGS has also informed us that soil moisture sensors
are indicating shallow landslides are likely if the rain rates get
high enough. This system will also bring some wind, though with
the actual low pressure center much further north than the most
recent storm, the pressure gradient and wind potential are
somewhat lower. Things currently look to dry out Friday before a
dry weekend, but that`s not a guarantee as the uncertainty remains
high.
&&
.AVIATION...
(18Z TAFS)
Issued at 917 AM PST Sat Feb 8 2025
High confidence VFR through the TAF period for most terminals
except KLVK, where LIFR conditions continue. Fog should clear up
shortly after 18Z. Winds will remain relatively light to moderate
through the TAF period.
Vicinity of SFO...High confidence VFR with light to moderate winds
through the TAF period.
SFO Bridge Approach...Similar to SFO.
Monterey Bay Terminals...VFR through the TAF period. Winds will have
southerly direction overnight. but speeds will remain mostly light
to moderate through the TAF period.
&&
.MARINE...
(Today through Thursday)
Issued at 857 AM PST Sat Feb 8 2025
Strong northerly winds will prevail through Tuesday with the bays
remaining sheltered from the strongest gusts. Significant wave
heights will remain in the moderate to rough realm. An approaching
low will bring rain Tuesday night through Friday morning.
&&
.MTR WATCHES/WARNINGS/ADVISORIES...
CA...Frost Advisory from 1 AM to 9 AM PST Sunday for CAZ502>504-508-
510-512-513-528>530.
Freeze Warning from 1 AM to 9 AM PST Sunday for CAZ506-514>518.
PZ...Small Craft Advisory until 3 AM PST Sunday for Pigeon Pt to Pt
Pinos 0-10 nm-Pt Arena to Pt Reyes 0-10 nm-Pt Reyes to
Pigeon Pt 0-10 nm.
Small Craft Advisory until 9 PM PST Sunday for Pt Pinos to Pt
Piedras Blancas 0-10 nm.
Small Craft Advisory until 9 AM PST Monday for Pigeon Pt to Pt
Pinos 10-60 NM-Pt Arena to Pt Reyes 10-60 NM.
&&
$$
SHORT TERM...Flynn
LONG TERM....Flynn
AVIATION...SO
MARINE...SO
Visit us at www.weather.gov/sanfrancisco
Follow us on Facebook, Twitter, and YouTube at:
www.facebook.com/nwsbayarea
www.twitter.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, February 7, 2025
High Temperature
95°F at Fort Stockton Pecos County Ap, TX
Low Temperature
-17°F at Malta, MT
High Precipatation
0.79in at Blue Canyon Nyack Ap, CA
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).