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.

280
FXUS66 KMTR 131206
AFDMTR

Area Forecast Discussion
National Weather Service San Francisco CA
506 AM PDT Thu Mar 13 2025

...New AVIATION...

.SYNOPSIS...
Issued at 1251 AM PDT Thu Mar 13 2025

Scattered showers and a chance of thunderstorms continue into the
morning before diminishing through the afternoon. Another system
arrives Friday, with unsettled weather through the next week.

&&

.SHORT TERM...
(Today and tonight)
Issued at 1251 AM PDT Thu Mar 13 2025

The main frontal rain band has moved through the region and into the
Central Valley and Southern California, leaving a patchwork of
scattered showers in its wake. These showers are expected to
continue through the morning hours before the coverage decreases in
the afternoon. With the cold air advection allowing lapse rates to
increase, the chance for some of those showers to turn into
thunderstorms continues. The Storm Prediction Center maintains a
general risk of thunderstorms through the day today, with a 20-30%
probability of thunderstorms through the afternoon hours. Locally
heavy downpours and small hail will be the main threats. Remember,
when thunder roars, go indoors! Or, see a flash, dash inside!

The cold air will also allow a chance for snow across the higher
elevations, with snow levels descending to around 3000 feet. Cameras
at Chews Ridge and Palo Escrito captured snowfall at both peaks
before sunrise yesterday, and conditions remain favorable for
continuing snowfall in the higher elevations through the morning.

Chilly temperatures continue today with many areas within the lower
elevations seeing high temperatures around 8 to 15 degrees below
seasonal averages. The inland valleys reach the mid 50s, the Pacific
coast around the low 50s, and perhaps into the 40s or the upper 30s
across the higher elevations. Breezy northwesterly winds will
develop this afternoon, although we are not expecting conditions
that would require a Wind Advisory today, as gusts generally reach
20 to 25 miles per hour. The winds do shift towards a more southerly
direction this evening, the first harbinger of another round of
storms.

&&

.LONG TERM...
(Friday through Wednesday)
Issued at 1251 AM PDT Thu Mar 13 2025

The active weather pattern continues through the week as a series of
upper level troughs impacts the region. The next system is expected
on Friday as another frontal system arrives after midnight and moves
through the region through Friday morning, with lingering showers
through the rest of the day. This system is not expected to be as
intense as the one that came through yesterday, with rain totals
generally 0.25-0.5" in the valleys and up to 1" across the higher
elevations and wind gusts reaching 30-35 miles per hour across the
ridgelines.

Saturday should be a break for most people, with the only rain
accumulations being a few hundredths of an inch in the Sonoma
coastal ranges, before a second system comes through the region on
Sunday into Monday morning. The North Bay looks to see more rainfall
from this system with the current forecast calling for 0.5-1" in the
valleys, while the Bay Area and Monterey Bay regions are anticipated
to see 0.25-0.5" across the lower elevations and up to 0.75" in the
coastal ranges, while locations in the southern Salinas Valley might
not break a tenth of an inch of rain. There`s still some time to
refine the rainfall totals from this system, so keep an eye on the
forecast updates. Ensemble model cluster analysis suggests that
relatively subtle changes in the positioning of the trough could
swing rainfall totals across the North Bay by as much as an inch.
Behind this system, ensemble models are picking up on another upper
level trough towards the latter part of next week, but it`s too
early to pinpoint any specific impacts.

Temperatures remain rather chilly through the week, slowly warming
through Sunday when the interior valleys reach the seasonal average
highs within the middle to upper 60s before dropping back down on
Monday, and warming back again into the upcoming Wednesday and
Thursday when the inland valleys again reach the mid to upper 60s.
The North bay sees a more muted rise in temperatures with highs in
the inland valleys reaching the upper 50s to lower 60s this weekend,
while coastal areas remain in the middle 50s to near 60
throughout.

&&

.AVIATION...
(12Z TAFS)
Issued at 443 AM PDT Thu Mar 13 2025

A very dynamic set of TAFs was issued this morning, with a lot of
changes to the weather pattern over the next 30 hours. Scattered
showers will continue through the morning before decreasing in
coverage and intensity through the afternoon as a drier air mass
briefly settles in. Winds will shift from W to S and increase in
speed through the second half of the day ahead of a second cold
front that will bring rain back overnight.

Vicinity of SFO...Scattered showers are ongoing, though it appears
the post-frontal trough axis moved through in the 11-12Z hour.
With drier air filtering in through the day and lack of triggers,
the showers should start to wane. There is still a chance for
thunderstorms as cold upper air settles in, but we didn`t see any
overnight and the other ingredients (moisture, trigger) are
becoming less favorable. Strong westerly winds this afternoon will
gradually shift to strong southerlies overnight as more steady
rain begins ahead of the next cold front.

SFO Bridge Approach... Similar to SFO.

Monterey Bay Terminals... Scattered showers will hold on a little
longer across the Monterey Bay Terminals as the trough is still
offshore. Otherwise the story is similar to the rest of the
region with a drying trend today and strong westerly winds in the
afternoon. MVFR conditions and strong southerly winds will move
in overnight as light, but more steady rain begins to fall ahead
of the next cold front.

&&

.MARINE...
(Tonight through next Tuesday)
Issued at 1027 PM PDT Wed Mar 12 2025

Fresh to strong breezes across the waters continue to create
hazardous conditions for small craft. Scattered showers continue
through Thursday with chances for thunderstorms and associated
stronger gusts. Seas will remain rough into next week as a series
of storms moves through.

&&

.BEACHES...
Issued at 1156 AM PDT Wed Mar 12 2025

Hazardous beach conditions are expected Wednesday and Thursday
as moderate period westerly swell builds to support breaking
waves up to 15 feet. Additional hazardous surf will be possible
again this Sunday. As always, please remember to stay off of
rocks and jetties, keep pets on a leash, and never turn your back
on the ocean!

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
CA...Frost Advisory from 11 PM this evening to 9 AM PDT Friday for
     CAZ516>518.

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

     Small Craft Advisory until 9 PM PDT Friday for Pigeon Pt to Pt
     Pinos 10-60 NM-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.

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

&&

$$

SHORT TERM...DialH
LONG TERM....DialH
AVIATION...Flynn
MARINE...DialH

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 Wednesday, March 12, 2025

High Temperature

103°F at Miami Kendall Tamiami Exec Ap, FL

Low Temperature

-0°F at Presque Isle Awos, ME
-0°F at Clayton Lake, ME

High Precipatation

2.57in at Crescent City Mcnamara 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 = '&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