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.

000
FXUS66 KMTR 030544
AFDMTR

Area Forecast Discussion
National Weather Service San Francisco CA
944 PM PST Sat Dec 2 2023

...New AVIATION...

.SYNOPSIS...
Issued at 233 AM PST Sat Dec 2 2023

Cool, unsettled weather for the next few days followed by a
warming trend into early next week. An approaching trough of low
pressure towards the middle of the upcoming week will bring the
return of unsettled weather.

&&

.UPDATE...
Issued at 816 PM PST Sat Dec 2 2023

Spotty light showers continue across the Bay Area this evening.
Light measurable amounts in the 0.01" to 0.1" range were noted
over portions of the region during the past 3 hours, with a few
localized spots in the Sonoma Coastal Range picking up a bit more.
Measurable amounts should become much harder to come by later tonight
but there may be enough to wet the pavement in spots here and
there. Shower chance will gradually wane south of the Golden Gate
into Sunday as high pressure builds in from the southwest. The
going forecast captures all this quite well and no changes are
needed this evening.

&&

.SHORT TERM...
(This evening through Sunday)
Issued at 110 PM PST Sat Dec 2 2023

KMUX radar continues to pick up widely scattered showers moving
through the Bay Area (Monterey/San Benito still dry) this
afternoon. Automated sensors have tipped a few hundredths since
this morning. Despite scattered showers moving through the region
there are pockets of sunshine peeking through the clouds.
Temperatures this afternoon will top out in the 50s and 60s, which
is close to or below seasonal averages for early December.

Tonight through Sunday...the shower activity that made it as far
south as Santa Cruz will begin to move northward this
evening/tonight as high pressure aloft begins to slowly build in
from the SW. Sunday will be split with shower chances: south of
the Golden Gate will be dry while the North Bay could still see
some showers through Sunday evening.

&&

.LONG TERM...
(Sunday night through next Friday)
Issued at 150 PM PST Sat Dec 2 2023

All shower activity tapers off Sunday night into Monday as the
upper level ridge strengthens over the region. Drier weather
warmer temperatures to start the work week. In fact, pretty solid
warm up by Tuesday with highs reaching the upper 60s to mid 70s,
which is above normal for this time of year.

The warm and dry weather quickly comes to an end Tuesday night
into Wednesday as a cold front approaches from the NW. This front
will bring precip back into the forecast by early Wednesday. Rain
will initially be possible over the North Bay on Wednesday morning
before spreading south through the day. Wet weather will linger
into Friday. Once again, not a big rain maker but 0.01"-0.25"
most areas and 0.25"-1.0" North Bay. Unlike the last system the
late week system will usher in a much colder airmass. Snow levels
will actually drop Thursday night into Friday to near 4k feet.
Therefore, cannot rule out some wet snow over the highest peaks.
At this point, not expecting any accumulation, but some snow is
possible.

The bigger concerns with the colder airmass will be the overnight
lows Friday night and beyond. The coast and bays will be spared
from the real cold temperatures, but interior valleys will be in
the low to mid 30s with a few isolated spots in the upper 20s.

&&

.AVIATION...
(06Z TAFS)
Issued at 944 PM PST Sat Dec 2 2023

This forecast has proven to be very challenging as guidance has
greatly differed from one hour to the next and clouds have scattered
out that were forecast to stick around. APC will be in IFR territory
between 11Z and 18Z and STS will be in LIFR territory between 8Z and
17Z. While OAK and SFO are in close proximity, it is looking like
OAK will be receiving the brunt of things as they are forecast to
stay MVFR between now and 20Z while SFO is now forecast to escape
ceilings due to confidence being too low.

Vicinity of SFO... Currently VFR. Guidance has differed every hour
on what the terminal is going to see in the way of MVFR ceilings.
There is now too low of confidence to include MVFR ceilings in the
TAF as the consensus blend of high resolution models is now only
highlighting it for the hour of 15Z and GFS LAMP has also
significantly backed off with their probabilities with their
timeframe potentially being 14Z-16Z. There are ceilings of about
2,000 feet upstream so it is not out of the realm of possibility
that SFO may see something, but it is seeming more unlikely. Winds
tomorrow will be breezy and onshore.

SFO Bridge Approach...Similar to SFO.

Monterey Bay Terminals...Currently VFR at MRY and MVFR at SNS.
Climatological models and the RAP are showing IFR ceilings for the
terminals overnight while the consensus blend of high resolution
models is keeping the IFR ceilings in the Central Monterey Bay Area.
That being said, confidence was not high enough to include IFR
ceilings in the TAFs down here, but a low scattered group was
included. Both terminals will experience E/SE winds overnight before
switching to breezy onshore flow after the clearing of ceilings in
the late morning.

&&

.MARINE...
(Tonight through next Thursday)
Issued at 816 PM PST Sat Dec 2 2023

Gentle to moderate westerly breezes will persist through the
weekend along with periodic chances for light showers. Northwest
swell will persist into Monday with elevated seas, particularly
over the northern offshore waters. Another northwest swell will
follow, creating larger waves with 16-21 second periods through
the upcoming week. Hazardous conditions for small craft operators
are anticipated.

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
CA...None.
PZ...Small Craft Advisory until 3 PM PST Monday for Pt Arena to Pt
     Reyes 10-60 NM.

     Small Craft Advisory from 3 AM to 3 PM PST Sunday for Pigeon Pt
     to Pt Pinos 10-60 NM.

&&

$$

SHORT TERM...MM
LONG TERM....MM
AVIATION...Sarment
MARINE...SPM

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:

  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 Friday, December 1, 2023

High Temperature

89°F at Henry E. Rohlsen Airport, VI

Low Temperature

-0°F at Riverton Regional Ap, WY

High Precipatation

6.58in 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 = '&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