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

Area Forecast Discussion
National Weather Service San Francisco CA
358 PM PST Sun Dec 10 2023

...New AVIATION, MARINE...

.SYNOPSIS...
Issued at 1140 PM PST Sat Dec 9 2023

Quiet weather this week with mild days and cool nights. A pattern
change takes hold for next weekend into early next week with a
likely return to wet and unsettled conditions.

&&

.SHORT TERM...
(This evening through Monday)
Issued at 125 PM PST Sun Dec 10 2023

Filtered sunshine across the Bay Area and Central Coast this
afternoon. A pleasant afternoon with temps in the upper 50s to
lows 70s.

After several nights of cold weather prompting Frost/Freeze
headlines temperatures tonight will be warmer thanks to the cloud
cover and approaching surface front from the NW. That being said,
interior locations will still be chilly and in the mid to upper
30s.

A weak cold front off the OR coast will continue to track
southward over the next 24 hour. This front will be weakening and
ultimately wash out over the Bay Area and coastal waters. As this
happens a few showers will be possible over the coastal waters
Monday with some patchy drizzle along the immediate coast. While
land areas look mostly dry, the front will bring some clouds and
cooler conditions on Monday.

&&

.LONG TERM...
(Monday night through next Saturday)
Issued at 133 PM PST Sun Dec 10 2023

For the upcoming work week - looks relatively quiet with mild and
dry conditions. An upper level shortwave trough deepens into an
upper low over NV and AZ Monday night through Tuesday. This low
will result in a period of offshore flow midweek. Winds will be
locally breezy over the North and East Bay Mts. The offshore flow
will keep mild and dry conditions in place. As the low moves
farther east midweek high pressure builds over CA. This building
ridge will keep the warming trend in place. In fact, by Thursday
and Friday well above normal temperatures will develop around the
region. ECMWF Extreme Forecast Index gives confidence in this
occurring and also highlights that it`s unusual for this time of
year. Highs will generally be in the 60s to mid 70s Thu/Fri. San
Jose will be near record values for Friday.

A notable pattern shift in the weather is still expected next
weekend. As noted before, both deterministic and ensemble
guidance continue to advertise a robust jet moving across the
Pacific. This upper level jet will bring a more active period to
the West Coast, including CA this time. Current forecast brings
rain back tot he region as early as Saturday. Additionally, latest
Atmospheric River guidance gives about a 40-60% chance for an AR
to reach CA late next weekend into the following. Exact details
like: timing, amounts, intensity, will be fine tuned over the
upcoming week.

&&

.AVIATION...
(00Z TAFS)
Issued at 357 PM PST Sun Dec 10 2023

Currently seeing VFR at all terminals. Most terminals will retain
this status throughout the TAF period; however, OAK and STS may not.
There is some hinting by hi-res models that OAK may obtain an MVFR
or even potentially an IFR ceiling towards the end of the TAF
period; however, confidence was not high enough to include such in
the TAF. There is more hinting for STS to see something similar to
what they saw last night in terms of low fog and low visibility;
however, the passage of high clouds from a shortwave may hinder that
opportunity, thus not giving high enough confidence to include in
the TAF.

Vicinity of SFO... Currently VFR with calm winds and high clouds.
VFR will persist throughout the TAF period. Winds will remain breezy
and onshore throughout the TAF period with northwesterly winds
giving way to westerly winds by 22Z tomorrow afternoon.

SFO Bridge Approach...Similar to SFO.

Monterey Bay Terminals...Currently VFR at both MRY and SNS, this
will be the case throughout the TAF period. Winds will turn offshore
and remain light overnight before returning to breezy onshore flow
tomorrow.

&&

.MARINE...
(Tonight through next Friday)
Issued at 357 PM PST Sun Dec 10 2023

The quiet weather over the waters continue to be under a high
pressure system. Gusty wind continue to build in the southern
waters as well as south of Point Sur creating hazardous conditions
for small craft vessels with winds diminishing near the mid-week.
Slight chance for a shower or two tonight into Tuesday in the
outer waters as a weak weather disturbance passes by.

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
CA...None.
PZ...Small Craft Advisory from 9 PM this evening to 3 AM PST Tuesday
     for Pt Pinos to Pt Piedras Blancas 0-10 nm.

&&

$$

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

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 Saturday, December 9, 2023

High Temperature

115°F at Houston Ellington Afb, TX

Low Temperature

-7°F at Clayton Lake, ME
-7°F at Stanley Ranger Station, ID

High Precipatation

1.69in at Hoquiam Bowerman Ap, WA

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