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

Area Forecast Discussion
National Weather Service San Francisco Bay Area
1255 PM PDT Tue May 17 2022

.SYNOPSIS...A warming trend will continue into Wednesday as high
pressure builds. Temperatures cool a few degrees Thursday as a dry
cold front moves into the Great Basin. This will bring dry
offshore winds to the region Thursday into Friday with increasing
fire weather concerns. Seasonably warm and dry weather this
weekend into early next week.

&&

.DISCUSSION...as of 12:55 PM PDT Tuesday...Skies are sunny this
afternoon region wide except for a few wisps of stratus for
coastal Monterey county. 24 hour trends show most areas about 3-6
degrees warmer this afternoon compared to Mondays cool
temperatures. Expect to see some coastal low clouds reform
overnight as the ridge of high pressure builds and compresses the
marine inversion layer.

For Weds the main forecast theme is for continued warming trend,
especially inland areas as upper 80s and lower 90s return to the
forecast as high pressure over the East Pac builds towards our
coastline.

On Thursday an inside slider moves into the Great Basin. Enough
cool advection for temps to cool a few degrees but the main
impacts will be lowering humidity and increasing dry northerly
winds. Though the strongest winds should stay confined to the
hills above 1500 feet and the far East Bay interior valleys.

On Thursday evening the strongest pulse of offshore winds will
arrive with gusts in the 40-50 mph range for the Napa hills and
Mt Diablo. Right now the best alignment for critical fire weather
concerns looks to stay over the Central Valley. That being said
fire weather concerns will be on the increase over the Bay Area.
At the very least fuels will begin to rapidly dry over the next
few days with breezy conditions always a concern as humidities
lower under dry northerly flow.

North winds ease on Friday as the strongest winds ease followed by
very low humidity values for the interior areas, down in the
teens. Will continue to consider if any wind advisories or fire
weather products are needed but for now will use generic headlines
in the Fire Wx forecasts. Anecdotally the synoptic setup is
similar to the May 2008 Summit fire in the Santa Cruz mountains so
do your part and be one less spark.

A nice Bay Area weekend in store with seasonably warm temperatures
inland and mild at the coast. Latest deterministic ECMWF suggests
general warming and drying next week with periods of offshore
winds possible. Cluster analysis still showing about a 30 percent
chance of trough solution towards the end of next week but either
way no rain in the forecast.

&&

.AVIATION...as of 11:10 AM PDT Tuesday...For the 18Z TAFs. VFR
through the TAF period for all but the Monterey Bay, which will see
MVFR CIGs linger into the afternoon and return late tonight. Winds
will become breezy to gusty through the evening, but will begin to
reduce into the night. Most areas offer light to moderate wind
overnight. Lower clouds will move inland around the Monterey Bay in
the late night with low clouds lingering into mid Wednesday morning.
Wednesday looks to be another breezy day region-wide with gustier
conditions around SFO.

Vicinity of KSFO...VFR through the TAF period. Westerly winds will
become strong and gusty this afternoon and last through the evening.
Late night winds will stay breezy but will reduce into the early
morning. Gusty conditions return around the midday Wednesday and
look to last through the evening again.

KSFO Bridge Approach...Similar to SFO.

Monterey Bay...Becoming VFR with moderate to breezy winds this
afternoon. Winds will reduce and become lighter overnight as stratus
begins to build in the Monterey Bay. Expect MVFR at MRY in the late
night through the mid morning before VFR returns.

&&

.MARINE...as of 12:35 PM PDT Tuesday...Expect northwesterly gale
force wind gusts across the coastal  waters through much of the
week. Strong and gusty onshore winds  will move across the bays
each afternoon and evening through  midweek. Strong winds will
persist through the week generating  steep and hazardous seas at
periods of 7 to 9 seconds.

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
     .Tngt...GLW...Pt Arena to Pt Reyes 0-10 nm
             GLW...Pt Reyes to Pigeon Pt 0-10 nm
             GLW...Pigeon Pt to Pt Pinos 0-10 nm
             GLW...Pt Pinos to Pt Piedras Blancas 0-10 nm
             GLW...Pt Arena to Pigeon Pt 10-60 nm
             GLW...Pigeon Pt to Pt Piedras Blancas 10-60 nm
             SCA...Mry Bay
             SCA...SF Bay until 9 PM

&&

$$

PUBLIC FORECAST: RW
AVIATION: Murdock
MARINE: Murdock

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 16, 2022

High Temperature

106°F at El Centro Naf, CA

Low Temperature

27°F at Leadville, CO

High Precipatation

1.92in at Beaufort Michael J Smith Field, NC

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