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.
000
FXUS66 KMTR 182348
AFDMTR
Area Forecast Discussion
National Weather Service San Francisco CA
448 PM PDT Mon Mar 18 2024
...New AVIATION, MARINE...
.SYNOPSIS...
Issued at 134 PM PDT Mon Mar 18 2024
Dry weather conditions will prevail through Thursday with a gradual
cooling trend. Expect periods of night time and morning low clouds
in the favored coastal and valley locations. Then, unsettled
conditions are projected to return by Friday and into the weekend.
&&
.SHORT TERM...
(This evening through Tuesday)
Issued at 134 PM PDT Mon Mar 18 2024
Satellite imagery is showing low clouds off of the coast from the
San Francisco Peninsula and points northward early this afternoon.
These clouds will spread back inland overnight and to the south into
tomorrow morning. Overnight lows are forecast range from the mid 40s
to lower 50s region-wide.
Once low clouds erode, tomorrow afternoon temperatures will warm
into the upper 50s to mid 60s near the coast and upper 60s to mid
70s across the interior.
&&
.LONG TERM...
(Tuesday night through Sunday)
Issued at 329 AM PDT Mon Mar 18 2024
There`s good global model agreement that a consolidation of a few
lows will take shape over the eastern Pacific Tuesday night into
Thursday. On Friday light to moderate rain will begin spreading
across the forecast area as the newly formed eastern Pacific low
gets nudged eastward. Wet weather is in store for late week and
the weekend, with highest rain totals 1" to 1.5" mainly along the
coast especially across the coastal hills and mountains.
Relatively lesser amounts of rain will fall over inland locations,
with the least amount of rain over the southern interior where a
few hundredths to a tenth of an inch are forecast. As always, the
forecast can change, especially if convection develops, this could
boost local rainfall amounts. Stay tuned to the latest updates.
If planning travel to or across the high mountain country check
with your local NWS office(s) or favorite media outlets for
forecast details, it`ll be cold enough for snow, please plan
accordingly if traveling.
&&
.AVIATION...
(00Z TAFS)
Issued at 446 PM PDT Mon Mar 18 2024
Currently VFR across the board. Fog is exclusively forecast for STS
with stratus forecast for the rest of the terminals. There is
moderate-high confidence that all terminals will see some form of
flight category reduction within the TAF period, with tonight
generally looking to be more of a ceiling restrictor than a
visibility restrictor. The signal tonight is quite similar to the
signal from last night; however, since models/guidance did not
handle last night`s scenario well, forecast tonight is less bullish
and more conservative while leaning on persistence. Widespread VFR
will prevail by tomorrow afternoon.
Vicinity of SFO...Currently VFR with breezy northwesterly flow.
Stratus will impact the terminal from the late hours of tonight into
the mid-morning hours of Tuesday. The westerly wind direction during
this time will facilitate a favorable environment for stratus to be
fed through the San Bruno Gap. Breezy westerly winds will prevail
tomorrow.
SFO Bridge Approach...Similar to SFO.
Monterey Bay Terminals...Currently VFR with breezy northwesterly
flow at both terminals. Stratus will impact the terminals overnight
and into the mid-morning hours with MRY becoming IFR and SNS
becoming MVFR. Breezy W/NW winds return to the terminals by mid-
morning tomorrow.
&&
.MARINE...
(Tonight through next Saturday)
Issued at 446 PM PDT Mon Mar 18 2024
High pressure over the region will continue the pattern of fair
and sunny weather through at least mid Thursday. Winds out of the
northwest and light to moderate through at least Wednesday. Come
late Thursday, chances of light rain begin initially over the
northern waters and winds turn to become more westerly. Through
the day Friday, rain begins to slowly move southward. Moderate NW
swell gives way to a new longer period NW swell train late today.
&&
.MTR WATCHES/WARNINGS/ADVISORIES...
CA...None.
PZ...None.
&&
$$
SHORT TERM...RGass
LONG TERM....Canepa
AVIATION...Sarment
MARINE...AC
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 Sunday, March 17, 2024
High Temperature
91°F at Fort Lauderdale Executive Ap, FL
Low Temperature
-0°F at Front Royal, VA
High Precipatation
1.83in at Lafayette Regional Ap, LA
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).