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

Area Forecast Discussion
National Weather Service San Francisco Bay Area
151 PM PDT Mon Oct 25 2021

.SYNOPSIS...Dry weather returns tonight into early Tuesday. A
weak system will bring light rain chances to the North Bay later
on Tuesday while other areas remain dry. High pressure should
bring seasonally dry and mild conditions through late week.

&&

.DISCUSSION...as of 01:30 PM PDT Monday...

This Afternoon into Tuesday:

Any lingering showers will depart portions of the South/East Bays
and Monterey/San Benito Counties later this afternoon. Additional
rain amounts should be very light. A little elevated instability
is present so can`t rule out an isolated lightning strike over the
next few hours. However this would be the exception rather than
the rule.

A low amplitude perturbation should pass to our north on Tuesday.
Enough moisture may exist to wring out a few showers over the North
Bay but it appears that most of the region should stay dry. Rain
amounts for the North Bay should generally be 0.1" or less.

Highs on Tuesday should range from the upper 50s to around 60 for
the North Bay, to the mid/upper 60s most other places. Some southern
valley locations could reach the 70 degree mark however with a bit
more sunshine.

Wednesday through Friday:

A meridional flow pattern should evolve aloft featuring amplified
mid-level ridging across the region. This should support surface
high pressure and warming/drying trend locally. Highs in the 70s are
likely for most areas.

Saturday and Sunday:

A shortwave trough/closed upper low may approach the region with
a chance for some light rain. However model differences lead to
low confidence in the ultimate forecast evolution this far out.
Temperatures may cool slightly depending upon the ultimate amount
of cloud/rain coverage we see.

&&

.AVIATION...as of 10:31 AM PDT Monday...For the 18z TAFs. The
bulk of the precipitation from the Atmospheric River is now south
of the region. Lingering post frontal showers remain mainly south
of the SF Bay Area around the Monterey sites. Slight chance of
scattered showers into this afternoon before dry conditions return
the rest of the day. Post frontal cumulus can be seen on
satellite with observations showing cigs at about 1,500 to 5,000
ft AGL. Expect SCT to BKN cigs VFR/MVFR cigs to persist through
much of the taf period. A weak boundary will approach northern
California tonight into Tuesday morning, this will bring some
light showers to the SF Bay Area and northward starting in the
morning. There may also be lowering cigs and patchy MVFR
conditions. Latest HRRR shows showers reaching the North Bay
around 15z-17z Tuesday morning and then reaching the SF Bay Area
around 20z-22z. Again, showers should be mainly light. Light winds
this morning aside from locally breezy W winds around the SF Bay
Area this afternoon at 15-20 kt.

Vicinity of KSFO...VFR with occasional MVFR cigs possible as post
frontal cumulus pops up in the area. Slight chance of showers in
the vicinity into this afternoon. Cigs should become more
scattered in the afternoon. Breezy W winds persist at about 15-20
kt with gusts to 25 kt this afternoon into the early evening.
Showers look to approach Tuesday afternoon.

KSFO Bridge Approach...Similar to KSFO.

Monterey Bay... KMUX radar shows some lingering showers around
KMRY and KSNS with MVFR cigs at about 1,500 to 3,000 ft AGL. MVFR
conditions the next hour or so before lifting. Post frontal
cumulus is forecast into the afternoon with cig heights 3,000 to
6,000 ft expected. Improving conditions into this evening, though
may see some patchy low clouds into early Tuesday morning. Breezy
westerly winds this afternoon 15-20 kt.

&&

.BEACHES...as of 3:00 AM PDT Monday...A strong, early season
storm system will continue to increase wave energy into early
Tuesday. This wave energy will transition through the coastal
peak today. Swell of 16 to 24 feet at 16 to 18 seconds is
forecast to arrive with the swell train as it peaks this afternoon
and results in a number of coastal hazards. These hazards include
large breaking waves of 20 to 30 feet (higher at favored break
points), increased risk of strong longshore and rip currents,
increased risk of coastal erosion and minor coastal flooding, and
enhanced coastal run up concerns due to the summer beach profiles
in place. Due to the early arrival of these large waves, many
beaches are still transitioning from their summer beach profiles
and lack the features and steepness to resist larger wave run up
on coasts. This means that more of this wave energy will have a
chance to move onto the beach and overtake individuals,
potentially injuring them, or pulling them into the cold ocean.
Each year, people die at the coast due to these or similar ocean
conditions. A high surf warning for the entire coast has been
issued for this threat and is in effect through 11AM Tuesday,
with the highest risks once again at west to northwest facing
beaches.

&&

.MARINE...as of 01:30 PM PDT Monday...Generally light west to
southwest winds will prevail across the waters today. Another
weaker frontal system will approach the waters into Tuesday
allowing southerly winds to return tomorrow before shifting back
out of the northwest midweek. The main concern over the waters in
the near term remains a large and dangerous west to northwest
swell with heights of 16 to 24 feet at 16 to 18 seconds. Swell
heights are expected to peak this afternoon and bring dangerous
conditions to the surf zone and near harbor entrances with
breaking waves of 20 to 30 feet. This will also result in
hazardous conditions over the waters.

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
     .Tday...High Surf Warning...CAZ006-505-509-529-530
             SCA...Pt Arena to Pt Reyes 0-10 nm
             SCA...Pt Reyes to Pigeon Pt 0-10 nm
             SCA...Pigeon Pt to Pt Pinos 0-10 nm
             SCA...Pt Pinos to Pt Piedras Blancas 0-10 nm
             SCA...Pt Arena to Pigeon Pt 10-60 nm
             SCA...Pigeon Pt to Pt Piedras Blancas 10-60 nm
             SCA...Mry Bay

&&

$$

PUBLIC FORECAST: SPM
AVIATION: AS
MARINE: AS
BEACHES: Diaz

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 Sunday, October 24, 2021

High Temperature

99°F at Zapata County Airport, TX

Low Temperature

14°F at Mount Washington, NH

High Precipatation

10.05in at Blue Canyon 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