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.

780
FXUS66 KMTR 231637
AFDMTR

Area Forecast Discussion
National Weather Service San Francisco CA
937 AM PDT Fri May 23 2025

...New UPDATE, MARINE...

.SYNOPSIS...
Issued at 358 AM PDT Fri May 23 2025

Breezy conditions linger into this weekend as temps cool slightly.
Subtle warming trend kicks off Saturday as a fairly quiet pattern
ensues. Above normal high temperatures on tap towards the end of
the month.

&&

.UPDATE...
Issued at 937 AM PDT Fri May 23 2025

As we head into this holiday weekend we have two things to keep in
mind. The first is that although air temperatures will be warm,
ocean temperatures are still chilly in the low to mid 50s. These
temperatures can cause incapacitation within a few minutes for even
experiences swimmers and result in cold water drowning. The second
is a reminder that a lot of our smaller fuels (i.e. grasses) are
either dry or in the process of drying out. If you are outdoors
using a campfire or some sort of stove remember to exercise caution
and prevent sparks from flying. One less spark, one less wildfire!
Otherwise the forecast remains on track with seasonal temperatures
and breezy afternoon/evening winds.

&&

.SHORT TERM...
(Today and tonight)
Issued at 358 AM PDT Fri May 23 2025

Subtle upper level trough set to move through today amid a robust NW
flow regime, which has been keeping us rather breezy through this
week. Today will largely be a fair weather day aside from the breezy
conditions this afternoon along the coast and NW-SE oriented
valleys. Cooler temps as well today just a few degrees below
seasonal normals across the region. As the recent few days have
shown, grasses and fine fuels are cured and ready to burn, despite
onshore wind and relatively cool temps. It won`t take much for
grasses to light up and spread quickly while the winds are breezy.

&&

.LONG TERM...
(Saturday through Thursday)
Issued at 358 AM PDT Fri May 23 2025

Another breezy day Saturday, albeit less so. Gust NW flow lingers
into the weekend but continues to wind down as high pressure
builds aloft. From Saturday, we`ll kick off a subtle warming trend
that lasts through the extended period. Ensemble guidance
basically advertises a subtle ridge-trough-ridge pattern with a
stronger ridge building over the western US into Canada by the end
of the month. It is advertised well by cluster analysis (high
confidence) that there is a high likelihood of above average
temperatures by the end of the current 7 day forecast period.
We`ll reassess when we get closer, but until then, heavier fuels
and timber and actually in decent shape in terms of moisture. As
previously mentioned, however, grasses are becoming very dry as we
have seen with a few grass fires over the past few days. Now is
the time in the season to prepare before we have anything more to
worry about. Understand your risk, evaluate your defensible space,
stay weather aware, and remember, "one less spark!"

&&

.AVIATION...
(12Z TAFS)
Issued at 254 AM PDT Fri May 23 2025

A few areas of coastal stratus /MVFR-IFR/ are forming early this
morning, including some inland formation of stratus clouds /MVFR/
as well, otherwise it`s VFR. The northerly and westerly pressure
gradients (and winds) will be weighted more equally today with
the gradients approx 3 to 4 mb from ACV to SFO and from SFO to
SAC. Surface to near surface cool air advection predominates from
the San Francisco Peninsula over to the East Bay and the South Bay
to the northern Monterey Bay Area early this morning which is
helping to bring the air to saturation forming areas of stratus.
During the daylight hours, mixing will increase and reduce the
areal coverage of stratus, then with cooling tonight and early
Saturday coastal stratus and fog /IFR-LIFR/ will develop; the
lower level temperature inversion strengthening and compressing
the marine layer.

Vicinity of SFO...Gusty west wind will transport stratus /MVFR-
IFR/ to the terminal this morning until mixing out to VFR at 16z.
West wind gusty today with gusts near 30 knots during the afternoon
and early evening. HREF output shows stratus /IFR/ returning tonight
and Saturday morning. The marine layer will compress tonight and
Saturday morning increasing the probability that the stratus ceiling
will be IFR.

SFO Bridge Approach...Similar to SFO.

Monterey Bay Terminals...Stratus /MVFR-IFR/ is continuing to form
early this morning. MVFR-IFR until later this morning with stratus
then mixing out to MVFR-VFR for the afternoon, then HREF output
shows stratus /IFR/ redeveloping this evening and continuing
overnight to Saturday morning. Onshore winds 5 to 10 knots except
10 to 20 knots in the afternoon and early evening.

&&

.MARINE...
(Today through Wednesday)
Issued at 937 AM PDT Fri May 23 2025

Hazardous marine conditions continue across the waters as strong
northwesterly breezes with near gale to gale force gusts and rough
seas persist. Fresh to strong northwesterly breezes and moderate
to rough seas will prevail through Monday.

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
CA...None.
PZ...Small Craft Advisory from 3 PM this afternoon to 9 PM PDT this
     evening for SF Bay N of Bay Bridge.

     Small Craft Advisory until 9 PM PDT this evening for Mry Bay-
     Pigeon Pt to Pt Pinos 0-10 nm.

     Gale Warning until 3 AM PDT Saturday for Pt Arena to Pt Reyes 0-
     10 nm-Pt Arena to Pt Reyes 10-60 NM-Pt Pinos to Pt Piedras
     Blancas 0-10 nm-Pt Reyes to Pigeon Pt 0-10 nm.

     Small Craft Advisory until 9 PM PDT Saturday for Pigeon Pt to Pt
     Pinos 10-60 NM.

&&

$$

SHORT TERM...Behringer
LONG TERM....Behringer
AVIATION...Canepa
MARINE...Murdock

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 Thursday, May 22, 2025

High Temperature

107°F at Needles, CA

Low Temperature

22°F at Angel Fire Airport, NM

High Precipatation

4.27in at Vineyard Haven Marthas Vineyard Ap, MA

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