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

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.

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 121143
AFDMTR

Area Forecast Discussion
National Weather Service San Francisco Bay Area
443 AM PDT Wed May 12 2021

.SYNOPSIS...The cooling trend that began near the coast on Tuesday
will gradually spread inland through rest of the work week. Also,
there will be an increase in night/morning low clouds through
Friday. Near to slightly below normal daytime temperatures will
then persist into the upcoming weekend, along with mainly dry
weather conditions.

&&

.DISCUSSION...As of 3:15 AM PDT Wednesday...May Gray is in full
effect overnight with widespread stratus along the coast and
locally inland. Lingering upper level high pressure is keeping the
depth and inland push of the low clouds in check, but low clouds
are moving up the entire Salinas Valley nonetheless. Fort Ord
profiler holds the stratus depth at 1,000 feet. Given the slightly
compressed nature of the stratus some sensors are reporting
patchy fog, some of it locally dense and less than 1/4 of a mile.
Morning low clouds and patchy fog will linger through mid-morning
for inland areas, but the coast line will hold onto the clouds
through the day. The subtle cooling trend noticed on Tuesday will
continue on Wednesday and become more widespread with 50s/60s near
the coast and 70s/80s inland. A few far interior locations have a
chance at exceeding 90 degrees.

To round out the work week, further cooling is expected with more
widespread night/morning low clouds. High pressure overhead will
weaken and flow becomes more zonal allowing for a deeper marine
layer and stronger onshore flow. Some of the hi-res models even
suggest at some coastal drizzle, which is definitely plausible.
High temperatures will drop an additional 5-15 degrees with highs
70s/80s interior.

For the weekend, a low confidence high impact scenario. Medium
range models have been showing an upper low pivoting over the Bay
Area and tonight`s model run is no different. The overall
development of an upper low Friday night into Saturday passing
over the Bay Area has pretty decent model agreement. The upper low
will keep low clouds in place and and temperatures on the cooler
side. The one question that remains is precip. Will the upper low
kick off any showers? The 00 and 06z runs of the deterministic and
ensembles are trending toward yes. The latest EC/GFS both
generate some scattered showers Friday night and early Saturday.
The National Blend is less enthusiastic, but the ensembles do
have a few members showing precip. If precip does it occur it will
be more on the convective side with showers and possibly thunder.
At this rate, it`s still a few days out, but upper level
instability is there with high modified total totals and decent
MUCAPE. Will continue to assess the situation, but if the trend
continues showers will be added and if thunder is added fire
weather concerns will ultimately increase. Stay tuned...

After the upper low exits to the south on Sunday conditions reamin
seasonably cool with night and morning clouds heading into next
week.

&&

.AVIATION...As of 04:42 AM PDT Wednesday...For the 12z TAFs. The
North Bay and Monterey Bay has terminals that are LIFR. VFR
elsewhere, but there is a thick deck of stratus sitting through
the Golden Gate extending to the East Bay. There is still a chance
for IFR conditions at KOAK, but confidence is decreasing for
KSFO. Given the dense nature of the cloud deck, adjust times for
clearing slightly later than the 06Z TAFs to between 17Z and 18Z.
VFR expected Wednesday afternoon with moderately breezy onshore
winds. Low clouds are expected to return Wednesday night, earlier
over the Central Coast and just after 06Z in the SF Bay. The reach
of the clouds will likely be more widespread yet not all the way
to KLVK, yet IFR cigs are forecast with a chance of reduced vis.

Vicinity of KSFO...As low clouds surround the terminal along the
California Coast and over in the East Bay, the terminal remains
with only a FEW low clouds and VFR. A TEMPO group was left in the
TAF until 16Z for reduced conditions give satellite showing a weak
signal for clouds developing on the western Bay shore. VFR and
onshore winds between 15 to 20 kts Wednesday afternoon. Low
clouds will return to the SF Bay, with a late push to make it into
KSFO at the end of the TAF period.

SFO Bridge Approach...Similar to KSFO.

Monterey Bay Terminals...LIFR with low clouds and occasional
reduced vis. Late clearing after 18Z. Minimal period of VFR
conditions from 18Z to 00Z as models show the stratus returning to
the terminals much sooner on Wednesday night. IFR/LIFR is
currently projected for conditions Wednesday evening into Thursday
morning.

&&

.MARINE...as of 02:42 AM PDT Wednesday...Light, mixed northwest
and southerly swells prevail with mostly light northwest winds
over the waters for Wednesday and Thursday. As the next system
approaches the waters late Thursday/early Friday, winds will
increase over the northern outer waters generating steep, fresh
swell making for hazardous conditions for smaller vessels into the
weekend.

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
     .Tday...NONE.

&&

$$

PUBLIC FORECAST: MM
AVIATION: DK
MARINE: DK

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 Monday, May 10, 2021

High Temperature

102°F at Laredo Intl Airport, TX

Low Temperature

14°F at Berthoud Pass, CO

High Precipatation

4.10in at New Orleans 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