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

Area Forecast Discussion
National Weather Service San Francisco Bay Area
305 AM PST Thu Dec 1 2022

.SYNOPSIS...Breezy to gusty winds and widespread rain will
impact the Bay Area and Central Coast on Thursday with drying
conditions by tonight. Mainly dry and cold on Friday before rain
returns for the upcoming weekend. Cold and dry weather returns early
next week.

&&

.DISCUSSION...as of 03:00 AM PST Thursday...The much anticipated
cold front is knocking on the "doorstep" of the North Bay early
this morning with light rain developing in the coastal ranges
within the moist southwest flow. As the front progresses
southward, rain will increase in coverage and intensity across the
North Bay through 5 AM before pushing into the heart of the San
Francisco Bay Area between 5 AM and 9 AM. With hits of a NCFR or
at least heavier band of precipitation developing along the
boundary, expect a brief period of moderate to heavy rain through
the morning rush hour. As such, water ponding on area roadways
will make for hazardous travel conditions this morning across much
of the Bay Area. The boundary will then shift southward late in
the morning through early afternoon with similar impacts to the
Central Coast. Breezy southerly winds will also develop just ahead
of the cold front producing wind gusts of 30 to 40 mph with
isolated gusts greater than 50 mph near the coast and along the
coastal ridges. While we cannot rule out enough instability for an
isolated thunderstorm or two, confidence of occurrence remains
generally below 15%. While a few lingering rain showers will be
possible in wake of the frontal passage, precipitation will
rapidly diminish over the North Bay by late morning/early
afternoon and then over the remainder of the region this
afternoon/early evening. Winds will also shift out of the
northwest and remain breezy at times along the coast into the
afternoon before diminishing overnight.

A much colder air mass will quickly advect southward across the
region in wake of the frontal passage late in the day and into
tonight. While snow levels also rapidly lower, there will be a
disconnect from the precipitation which will prevent much in the way
of snow accumulations in the higher terrain. That said, can`t rule
out some light frozen precipitation across the highest peaks and
ridges in the Santa Lucia range. Speaking of cold, temperatures will
plummet tonight into Friday morning as the colder air mass settled
into the region and winds become light. The highest confidence for
sub-freezing temperatures will be across the interior North Bay,
interior Monterey and San Benito counties and into the Eastern Santa
Clara Hills (southern Diablo Range). Therefore, these areas will be
under a freeze warning with lows forecast to drop as low as the
mid/upper 20s. It is worth noting that freezing conditions are
possible elsewhere across the region, especially away from the
immediate coastline/bay shore and in the colder wind sheltered
valleys. Thus, folks should prepare for cold temperatures tonight
through Friday morning.

Call to action - Remember the Four P`s with the arrival of colder
weather.

*People: wear layers, limit time outdoors, & check heaters in
 advance.
*Plants: cover or bring sensitive plants indoors.
*Pets: bring pets indoors at night and provide them with plenty of
 warmth.
*Pipes: wrap/cover exposed outdoor pipes to prevent freezing.

Mostly dry and tranquil conditions are forecast through the day on
Friday with temperatures struggling to warm into the mid 50s. Rain
returns to the forecast by Friday night into Saturday morning. This
will occur as another mid/upper level trough begins to develop off
of the British Columbia and Pacific Northwest coast. This feature
will tap into deeper moisture advection over southern California
which happens to be the remnants of the system passing through
today. As such, widespread rain will again impact the region through
the upcoming weekend. Confidence in the details remain low-to-
moderate at this time with regards to timing and exactly how much
rain will fall over the region. Additionally, cold temperatures look
to persist into early next week as precipitation begins to tapper
off. Stay tuned to the latest as we fine tune the forecast in the
coming days.

&&

.AVIATION...as of 03:00 AM PST Thursday...For the 12Z TAFs.
Current radar showing rain showers moving into North Bay
terminals, which will continue to move southward across the area
this morning. Gusty S/SE winds can be expected ahead of the cold
front, which is set to move through the North Bay before sunrise,
the SF Bay Area shortly after sunrise, and the Monterey Bay area
by late morning. Rain showers, heavy at times, will accompany the
cold front, along with a rapid wind shift. Gusty NW winds behind
the front will diminish later in the afternoon. Conditions improve
to VFR Thursday afternoon into the evening from north to south.

Vicinity of SFO...S/SE winds to increase through the morning ahead
of an approaching cold front and associated rain showers. The rain,
heavy at times, is expected to make its way through the terminal
vicinity shortly after sunrise through late morning. Winds to shift
rapidly behind the front becoming NW with continued breezy
conditions before diminishing into the afternoon. Rain is expected
to mostly end by the early afternoon for much of the Bay Area with
some lingering showers through the afternoon. Conditions improve
to VFR through the rest of the day.

KSFO Bridge Approach...Similar to SFO.

Monterey Bay Terminals...SE winds increasing this morning ahead
of an approaching cold front. Rain shower activity will begin to
increase by mid-morning, becoming more widespread by late morning
to midday. Winds becoming NW behind the cold front by midday. Rain
will begin to exit the area by late afternoon to early evening
with a chance for lingering scattered showers through the evening.
Conditions generally improving to VFR by later tonight.

&&

.CLIMATE...

Daily Record Low Temperatures for December 2nd.

              12/02 Record Low          Record Year

Santa Rosa coop        25                1906
Kentfield              28                1906
Napa State Hospital    28                1932, 1928
Richmond               38                2006, 1973, 1967
Livermore coop         26                1906
San Francisco downtown 40                2009, 1906
SFO Airport            37                1967
Redwood City           30                1936
Half Moon Bay          32                2004
Oakland Museum         38                1973
San Jose               26                1906
Gilroy                 26                1990
Salinas Airport        30                2004, 1990, 1936, 1934
King City              24                1957, 1933

&&

.MARINE...as of 03:00 AM PST Thursday...Expect a very unsettled,
winter-like weather pattern through late week and weekend. A cold
front with heavy rain and gusty winds will move southeastward
across the coastal waters and bays through this morning. Below
early December normal temperatures will return with northwest
winds this evening and Friday. A low pressure system over the
eastern Pacific will then potentially deepen and bring another
round of rain and increasing winds as it approaches the Bay Area
Saturday and Sunday.

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
     .Tday...SCA...SF Bay until 9 AM
             SCA...Pt Reyes to Pigeon Pt 0-10 nm until 9 AM
             SCA...Pigeon Pt to Pt Pinos 0-10 nm until 9 AM
             SCA...Mry Bay until 3 PM
             SCA...Pt Arena to Pt Reyes 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

&&

$$

PUBLIC FORECAST: RGass
AVIATION: Behringer
MARINE: Behringer

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, November 29, 2022

High Temperature

93°F at Key West Nas, FL

Low Temperature

-15°F at Yellowstone Lake, WY

High Precipatation

4.67in at Columbus Afb, MS

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