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.

114
FXUS66 KMTR 171142
AFDMTR

Area Forecast Discussion
National Weather Service San Francisco CA
442 AM PDT Tue Jun 17 2025

...New AVIATION...

.SYNOPSIS...
Issued at 305 AM PDT Tue Jun 17 2025

Quiet weather continues with a slight warmup today and tomorrow,
with temperatures gradually falling back to near normal or slightly
below normal for the end of the week and weekend.

&&

.SHORT TERM...
(Today and tonight)
Issued at 305 AM PDT Tue Jun 17 2025

Temperatures warm to slightly above normal today and tomorrow with
progressive upper level shortwave ridging across our area today. Very
dry air above the marine layer remains in place helping to limit low
stratus over our coastal areas, with bright sunshine inland. As the
upper ridging shifts east, zonal flow sets up across our area late
tonight when the marine layer deepens with more widespread coastal
low marine layer stratus expected to return overnight into early
Wednesday morning.

&&

.LONG TERM...
(Wednesday through Monday)
Issued at 305 AM PDT Tue Jun 17 2025

Primarily zonal upper flow across our area on Wednesday will result
in the warmest day of the week before a deepening trough leads to
height falls, cooler temperatures and a more robust marine layer
intruding farther inland for Thursday and beyond. Temperatures will
cool back down to seasonal averages or slightly below. The upper low
over the Pacific Northwest will gradually shift inland on Friday
into the weekend. Gusty onshore flow for the end of the week and
weekend will lead to winds up to 40 MPH at times for higher
elevations, passes and gaps on Saturday, easing Saturday night.

&&

.AVIATION...
(12Z TAFS)
Issued at 442 AM PDT Tue Jun 17 2025

Widespread VFR continues across the CWA. Night Fog shows a small
patch of clouds in the northern Monterey Bay but confidence is low
that it will impact MRY and SNS this morning. VFR conditions persist
through much of the day before CIGs start to build in again late
this evening into the overnight hours. Highest confidence in IFR
CIGs at HAF, MRY, and SNS with moderate confidence in IFR CIGs
reaching OAK tonight. Guidance does show some potential for MVFR
conditions to reach SFO after 09Z but confidence remains low in this
scenario. Winds remain onshore (southwest to northwest) through the
forecast period with breezy winds during the afternoon/evening
easing and becoming light/variable overnight.

Vicinity of SFO...VFR through the TAF period. Not anticipating
stratus to develop this morning but some potential exists for
stratus to develop tonight. LAMP guidance indicates stratus
potential increases from 09Z to 17Z with any CIGs that do develop
likely to be MVFR. For now, leaned more towards high resolution
guidance offered by the HRRR which suggests stratus will fill in
through the Golden Gate Gap and over OAK but not reach SFO. Gusts
are expected to peak around 33 knots during the afternoon/evening at
SFO today before winds ease overnight into tomorrow.

SFO Bridge Approach...Similar to SFO.

Monterey Bay Terminals...VFR becoming IFR tonight into tomorrow
morning. Highest confidence in IFR CIGs moving in between 06Z-08Z
tonight with stratus reaching MRY first then SNS second. CIGs are
likely to persist through mid to late morning before clearing
tomorrow afternoon. Moderate west to northwest winds are expected
this afternoon and evening before winds ease and shift slightly
southwesterly overnight.

&&

.MARINE...
(Tonight through next Sunday)
Issued at 1028 PM PDT Mon Jun 16 2025

Gusty northwest winds continue across most of the waters along
with moderate to rough seas. These conditions look to last
through the week and into the weekend with slightly increased
swell heights. Gale force gusts will occur near the coastal jet
regions of Point Reyes and Point Sur in the afternoons and look to
linger into the evenings for much of the forecast.

&&

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

     Small Craft Advisory until 3 PM PDT this afternoon for Pt Arena
     to Pt Reyes 0-10 nm.

     Gale Warning from 3 PM this afternoon to 9 PM PDT this evening
     for Pt Arena to Pt Reyes 0-10 nm.

     Small Craft Advisory until 3 PM PDT Wednesday for Pigeon Pt to
     Pt Pinos 0-10 nm-Pigeon Pt to Pt Pinos 10-60 NM-Pt Reyes to
     Pigeon Pt 0-10 nm.

     Gale Warning until 3 AM PDT Wednesday for Pt Pinos to Pt Piedras
     Blancas 0-10 nm.

     Small Craft Advisory until 9 PM PDT this evening for Pt Arena to
     Pt Reyes 10-60 NM.

     Gale Warning from 9 PM this evening to 3 PM PDT Wednesday for Pt
     Arena to Pt Reyes 10-60 NM.

&&

$$

SHORT TERM...JM
LONG TERM....JM
AVIATION...Kennedy
MARINE...Kennedy

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 Sunday, June 15, 2025

High Temperature

117°F at Needles, CA

Low Temperature

32°F at Leadville, CO
32°F at Angel Fire Airport, NM
32°F at Dixon Airport, WY
32°F at Truckee Airport, CA

High Precipatation

3.02in at Edenton Northeast Regional Airport, NC

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