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 191146
AFDMTR
Area Forecast Discussion
National Weather Service San Francisco CA
446 AM PDT Tue Mar 19 2024
...New AVIATION...
.SYNOPSIS...
Issued at 301 AM PDT Tue Mar 19 2024
Despite the increase in coastal stratus, rain will stay out of the
forecast through Thursday. By Friday, a cold front will bring
periods of light to moderate rain and cooler temperatures through
the weekend.
&&
.SHORT TERM...
(Today and tonight)
Issued at 301 AM PDT Tue Mar 19 2024
The current low-cloud enhanced IR satellite image looks a lot like
early summer with a stratus-filled marine layer intruding into
coastal areas and neighboring valleys. The cloud base is a few
hundred feet lower than yesterday, and the Ft. Ord profiler is
measuring the marine layer depth at around 1,000 ft. This makes
patchy fog possible later this morning, and there is some
indication of mist beginning to form on regional traffic cameras.
The HRRR has a great handle on the current stratus coverage, and
suggests the low clouds will break by mid-day, allowing another
sunny and warm afternoon.
&&
.LONG TERM...
(Wednesday through Monday)
Issued at 301 AM PDT Tue Mar 19 2024
Wednesday and Thursday will be similar to Tuesday. Marine layer
stratus and patchy fog in the morning will give way to clear
afternoons and warmer than average temperatures. The pattern will
change on Friday as a cold front approaches from the Eastern
Pacific. Moderate southerly winds will shift to westerly in the
afternoon. Light to moderate rain is also expected on Friday,
although a few stronger showers are possible as the surface front
moves through. Unsettled weather will persist Saturday, although
precipitation will be more hit-or-miss showers compared to Friday.
Lingering light showers will likely persist into Sunday. In
addition to the rain and wind, the temperature will be noticeably
colder this weekend. Expect coastal areas to stay in the 50s,
while some inland valleys break into the low 60s. As an example of
this cool-down, Pinnacles National Park recorded a high
temperature of 79F Monday. The forecast high for Sunday is only
59F.
&&
.AVIATION...
(12Z TAFS)
Issued at 446 AM PDT Tue Mar 19 2024
IFR to LIFR conditions across the board. Primarily stratus
throughout the Bay Area and Central Coast with patches of fog mixed
in. Fog is starting to develop at STS with visibility rapidly
dropping over the last hour. Increased chances for temporary fog
development at SNS to continue through the early morning hours
with temporary dips in visibility and ceiling height possible.
Elsewhere, visibilities are expected to stay above 6SM but
temporary drops in visibility may be possible. VFR conditions will
return by mid to late morning between 17-19Z. Winds are light and
primarily out of the NW tonight with stronger W to SW winds
expected to return during the day. Guidance is hinting that
stratus is likely to return after 06Z tomorrow with some potential
for fog development in the North Bay.
Vicinity of SFO...IFR conditions. Conditions will start to improve
by 20Z with guidance suggesting conditions may start improving as
early as 18Z. Light SW winds overnight will strengthen to moderate W
to NW winds during the day and continue overnight. Moderate
confidence that stratus will return to SFO by 10Z tomorrow with
guidance hinting decreases in ceiling heights are likely.
SFO Bridge Approach...Similar to SFO.
Monterey Bay Terminals...IFR to LIFR conditions to continue through
the remainder of the night. Patchy fog has been moving in and out of
SNS overnight. Some potential remains through 14-16Z for temporary
drops in visibility and ceiling heights at SNS as patchy fog moves
over the airport. At MRY, fog development is not expected but
temporary decreases in visibility may be possible between 13-16Z.
Light, variable winds overnight with winds strengthening and turning
westerly to northwesterly during the day. Tomorrow night, winds will
become light and variable again with stratus likely to return
between 04-06Z.
&&
.MARINE...
(Today through Sunday)
Issued at 301 AM PDT Tue Mar 19 2024
High pressure to continue through mid week with an incoming low
pressure system moving into the area on Thursday. Gentle NW winds
and dry conditions will linger through Wednesday before winds
strengthen and become more southerly late Wednesday into Thursday.
Rain chances will increase over the waters late Thursday with
elevated precipitation chances continuing into the weekend. A
moderate period northwesterly swell continues to diminish with a
new, longer period northwesterly swell train arriving Thursday.
&&
.MTR WATCHES/WARNINGS/ADVISORIES...
CA...None.
PZ...Small Craft Advisory from 9 AM this morning to 9 AM PDT
Wednesday for Pt Pinos to Pt Piedras Blancas 0-10 nm.
&&
$$
SHORT TERM...Flynn
LONG TERM....Flynn
AVIATION...Kennedy
MARINE...Kennedy
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 Monday, March 18, 2024
High Temperature
93°F at Boca Raton Airport, FL
93°F at Fort Lauderdale Executive Ap, FL
Low Temperature
1°F at Burlington Carson Ap, CO
1°F at Imperial Beach Ream Field Nas, CA
High Precipatation
0.81in at Harlingen Rio Grande Valley Intl Ap, TX
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).