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

Area Forecast Discussion
National Weather Service San Francisco Bay Area
842 AM PST Wed Dec 2 2020

.SYNOPSIS...High pressure, along with light offshore flow, will
maintain dry conditions across the region through the upcoming
weekend, and likely through at least the first half of next week.
Days will be mostly sunny and mild while nights will be clear and
cool.

&&

.DISCUSSION...as of 08:40 AM PST Wednesday...The potential for
low level moisture, as mentioned in the previous discussion, did
manifest itself as a few patches of dense fog in the North Bay
Valleys this morning. Luckliy, this fog stayed within the lowest
elevations and did not see widespread development. Offshore flow
and quickly warming conditions have already started to clear some
of these patches, setting the Bay Area up for another sunny and
clear afternoon. Morning lows again fell around 5 degrees below
average in several places, but with another sunny and dry
afternoon, these temperatures look to quickly turn around. The
gradient from WMC to SFO has increased since the last discussion,
and is up to 12.9mb. However, winds still look to remain moderate.

&&

.PREV DISCUSSION...As of 3:15 AM PST Wednesday...Skies remain mostly
clear early this morning, except for some passing high clouds.
This is in marked contrast to 24 hours ago when widespread low
clouds and fog blanketed the coast and were developing inland.
The difference this morning is that pressure gradients have turned
offshore, resulting in widespread north to northeast winds in the
hills with light offshore flow at several lower elevation
locations as well. Surface dewpoints are similar to yesterday
morning, so we may still see some patchy low clouds and fog
develop prior to sunrise, but it`s highly unlikely that that
anything other than patchy fog will form this morning given
offshore flow conditions.

Currently, the offshore pressure gradient from WMC to SFO stands
at a rather impressive 11.5 mb, but most of this gradient spans
the Sierra. Thus, only locally moderate offshore winds are
currently being observed in our hills, mainly at the higher
elevations of the North and East Bay where gusts of between 20 and
30 mph are being reported. Winds in the hills are expected to
peak over the next few hours and then subside for the balance of
the day. In fact, while southern California is expecting a
significant Santa Ana wind event over the next few days, offshore
flow in our area is forecast to remain mostly light in the short
term. Our recent prolonged period of dry weather is resulting in
fuels approaching near record dry levels for early December. Thus,
absent any precipitation, a strong offshore wind event at this
point would likely result in critical fire weather conditions. The
latest models indicate that after this morning, winds in our
hills will remain light through midday Sunday. However, the latest
GFS and ECMWF both indicate the potential for gusty offshore
winds in the hills of the SF Bay Area from Sunday afternoon
through Monday evening as an upper trough develops over the Great
Basin. Will need to monitor this closely for potential Fire
Weather Watches or Red Flag Warnings.

Other than potential fire weather concerns by late in the
weekend, and beach hazards over the next few days due to powerful
long period swell (see Beaches section below), our weather will be
uneventful through the forecast period as an upper ridge remains
over California and offshore flow prevails. Daytime temperatures
will remain mild and slightly above normal, while nights will
continue to be cool. No rain is expected over the next 7 days. A
frontal system currently offshore along 140W is forecast to wash
out as it comes up against the ridge late tonight and Thursday
morning. Rainfall with subsequent incoming systems is forecast to
remain to our north, at least through the middle of next week.

&&

.AVIATION...as of 4:42 AM PST Wednesday...For the 12z TAFs. VFR
is much more extensive this morning compared to yesterday at this
time. The 00z WRF model is currently over-forecasting coverage of
fog and low clouds over the coastal waters. Light offshore winds
and cold air drainage in the valleys has brought sufficiently drier
air to the coastline keeping VFR going at all terminals. VFR today
then low to moderate confidence VFR tonight and Thursday, though
offshore winds during this time should help keep VFR going.

Vicinity of KSFO...VFR. Calm to light northeast wind then a west
wind near 10 knots mid to late afternoon. Light and variable wind
tonight and Thursday morning.

SFO Bridge Approach...Similar to KSFO.

Monterey Bay Terminals...VFR. Mainly east to southeast winds 5 to
10 knots, winds becoming northwest 5 to 10 knots late afternoon.
East to southeast winds 5 to 10 knots tonight and Thursday morning.

&&

.BEACHES...as of 3:44 AM Wednesday...A very long period WNW swell
will impact the Sonoma to Big Sur coast today through Thursday
afternoon. Initial forerunner waves of 24 to 27 seconds will begin
to arrive along the Sonoma coast early this morning before
spreading southward through the day. The primary timeframe of
concern from this event will be midday today to Thursday morning
as the wave heights rise to 3 to 7 feet at a periodicity of 19 to
24 seconds. A high to extreme risk of sneaker waves will exist
during this timeframe. The largest energetic sneaker waves will
arrive irregularly every few minutes to as infrequently as once
every 30 minutes during otherwise deceptively calmer seas and
consequently may catch those on coastal jetties, rocks, piers, or
shorelines offguard and may injure them or knock them into the
cold, turbulent ocean. Beachcombing is not advised during this
timeframe. In addition, strong rip currents will accompany the
energetic wave train, particularly at WNW facing beaches. These
type of events claim lives each year along our coast so extreme
vigilance is advised if visiting the coast. Finally, moderate to
locally large breaking waves of 14 to 18 feet will be possible
later in the day on Thursday at WNW facing beaches as the swell
period decreases and swell heights increase, thus this product
will be in effect through the day Thursday. A beach hazard
statement is in effect from 10 AM today to 4 PM Thursday.

&&

.MARINE...as of 3:41 AM PST Wednesday...Surface high pressure
over the eastern Pacific and a stronger surface high over the
Great Basin will keep light northwest to north winds going across
the coastal waters and bays through Sunday. A long period
northwest swell arrives today to early Friday bringing potential
hazards in the surf zone.

&&

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

&&

$$

PUBLIC FORECAST: Dykema/Murdock
AVIATION: Canepa
MARINE: Canepa

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 Tuesday, December 1, 2020

High Temperature

88°F at Fort Stockton Pecos County Ap, TX

Low Temperature

-1°F at Gunnison County Ap, CO

High Precipatation

2.10in at Houlton Airport, ME

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