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

Area Forecast Discussion
National Weather Service San Francisco Bay Area
208 PM PDT Tue Sep 22 2020

.SYNOPSIS..A seasonable weather pattern on Wednesday with ridging
aloft. A weak front moves into Northern California on Thursday but
no rain for the Bay Area with just some increasing onshore winds
and slight cooling of temps. Slight warming trend starts Friday
then much warmer over the weekend with Sunday the hottest day.
Offshore winds over the weekend with increased fire weather
concerns and a Fire Weather Watch already posted for the North and
East Bay hills this weekend. No sign of the ridge breaking down
with above normal temperatures continuing at least through the
middle of next week.

&&

.DISCUSSION...as of 2:08 PM PDT Tuesday...Skies are mostly sunny
this afternoon across the Bay Area and most of the smoke from
nearby fires has mercifully stayed out of the Bay Area. The marine
layer is around 1200 feet with some patchy clouds from Ocean
Beach down to Davenport. Farther south low clouds are lingering
from Monterey Bay and down along the Big Sur coast. The SFO to Sac
gradient is 2 mb onshore with a steady 20 mph wind at the Golden
Gate keeping temps in the 60s for the City and along the coast.

Looking ahead to Weds expect to see some shortwave ridging from
SoCal that will build heights to around 590 dm. However,
persistent onshore winds will keep temperatures running near
normal with 70s around the Bay and 80s inland with 90s for the
hottest interior valleys of the Central Coast.

On Thursday a weak front moves into far Northern California. It
may bring some light rain to fires up near the Oregon border.
Locally it will help to deepen the marine layer with perhaps some
drizzle for the coastal slopes and places like the Wallbridge and
Woodward burn scars.

On Friday behind that front the flow across Oregon turns zonal as
the main jet shifts north and high pressure quickly builds over
the Bay Area as a 591 dm closed height field develops while the
remnants of Tropical Storm Lowell drift well to our south and
west. As this ridge builds temps will begin to rebound slightly
by Friday afternoon which will augur the beginning of a
significant warming trend this weekend.

Strong high pressure builds over the entire West Coast Saturday
and Sunday. 850 mb temps around 24 celsius by Saturday afternoon
warm to 27 celsius by Sunday afternoon as 500 mb heights climb to
595 dm. This all happens while an offshore surface pressure
gradient develops. The strongest gradient will be over the Sierra
with upper support only minimal as cold air is shunted well to our
east. The upper pattern wont support strong winds. However a
period of moderate offshore winds with gusts to 50 mph is
currently progged for Saturday night into Sunday morning, most
focused over the North Bay hills.

A Fire Weather Watch has been posted from 11 am Saturday through 8
am Monday morning for the North and East Bay hills as well as the
East Bay interior valleys. This is a longer lead time than normal
but confidence is high that event will unfold though it could
trend slightly stronger or weaker in terms of wind strength. The
National Preparedness level is still at its highest level of 5
with numerous large fires continuing across the West that has kept
fire fighting resources stretched thin. In addition to the
typical offshore winds confidence is high for above average
temperatures this weekend with widespread 90s to lower 100s.
Sunday looks to be the hottest day. So by Saturday morning temps
will be quickly warming as offshore winds start to develop in the
hills then peak overnight Saturday into Sunday morning. There will
essentially be no humidity recovery with values in the 10-20%
range while fuels are of course critically dry as observed over
the last month of burning. Current model projections show 925 mb
winds to around 45 mph so gusts in the 50-55 mph range look likely
at this time around Mt Saint Helena and Mt Diablo as well as Mt
Tamalpais.

A second burst of winds could occur Sunday night into early
Monday but that looks weaker at this time though there will
continue to be no marine layer or humidity recovery.

Though offshore winds may ease early next week all indications for
several more days of hot afternoons. Will have to look closer at
heat advisory potential by Sunday or Monday but the dry airmass
should allow for decent night time cooling of temps that will help
with overall cumulative effect of heat impacts.

&&

.AVIATION...As of 10:50 AM PDT Tuesday...Weak ridging has
compressed the marine layer while a drier air mass has scoured it
out. Late morning satellite imagery shows mostly clear conditions
inland with some remnant marine layer along and through the
Golden Gate Gap, eastward into Martinez and southward through
San Mateo coast, as well as along the lip of the Monterey Bay.
Expecting generally VFR conditions from 18Z onward throughout the
TAF period as drier air mass remains in place. Marine layer is
expected to return Wednesday night into Thursday morning. Locally
breezy to gusty onshore winds through coastal gaps today with
lighter onshore winds elsewhere. A few passing high clouds this
evening to tonight. Remnant marine layer may be able to manifest a
few to sct at a few hundred feet overnight at sheltered
locations.

Vicinity of KSFO...VFR through the period. Breezy (15-20kt) to
occasionally gusty onshore winds (25kt) from roughly 21-04Z today
and tomorrow. Some passing high clouds 04-10Z WED.

SFO Bridge Approach...Possible lowered slant-range vis from haze,
otherwise similar to KSFO.

Monterey Bay Terminals...Lingering marine layer VLIFR-LIFR clouds
will mix out shortly. VFR today with light to occasionally breezy
onshore winds (up to 10kt). Some patchy very low clouds possible
tonight but should mainly manifest as FEW-SCT 100-200 feet.

&&

.BEACHES...as of 04:38 AM PDT Tuesday...A deep low in the Gulf of
Alaska will produce a large long-period swell train that will
arrive late Thursday evening and into Friday morning. Swells by
then could be up to 9 to 11 ft with a 16 to 18 second period. The
main impacts will be increased wave heights breaking near the
shoreline and an increased risk of rip currents developing along
coastal beaches. With the increase in temperatures inland expected
this weekend, beachgoers should be mindful of the increased wave
activity and rip currents. The wave activity is forecast to
gradually decrease through the weekend, but caution is advised
through at least Sunday morning.

&&

.MARINE...as of 10:40 AM PDT Tuesday...Light to locally moderate
northwest winds, strongest along the inner coastal waters today.
The first larger height, longer  period northwest swell of the
season will arrive Thursday and  Friday.

&&

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

&&

$$

PUBLIC FORECAST: RWW
AVIATION: DRP
MARINE: DRP

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, September 21, 2020

High Temperature

106°F at El Centro Naf, CA
106°F at Imperial County Ap, CA
106°F at Palm Springs Asos, CA

Low Temperature

21°F at Presque Isle Awos, ME
21°F at Whitefield Mt Washington Regional Ap, NH
21°F at Saranac Lake Adirondack Regional Ap, NY

High Precipatation

5.70in at Houston Clover Field, TX

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