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

Area Forecast Discussion
National Weather Service San Francisco Bay Area
1113 PM PDT Sun Mar 26 2023

.SYNOPSIS...Temperatures decrease with the potential for frost
development and cold temperatures for Monday morning. A cold front
arrives late Monday into Tuesday morning proving strong winds and
moderate to heavy rain. Rain showers linger into midweek as the
storms central low slowly moves southward. Drier conditions return
on Thursday, yet a cool and unsettled weather pattern persists into
next weekend.

&&

...Wind and Rain Impacts Monday Night through Wednesday...

.DISCUSSION...as of 08:54 PM PDT Sunday...High clouds are gently
passing over the Bay Area and the Central Coast Sunday evening.
Temperatures are still in the low 50s tonight, same as they were
last night. The Frost Advisory was extended to cover Monday morning,
and it looks like the event is transpiring near similarly to
yesterday. And with the high clouds present, it is assumed that it
will trap some of the radiation release keeping the confidence in
similar conditions high. Monday morning will feature calm and dry
conditions with below normal afternoon high temperatures.

High clouds will increase through Monday as the next low pressure
system moves southward. No major changes to the forecast based on
most recent high resolution models. It keeps the low reaching its
lowest pressure off the coast, a band of moderate to heavy rain
passing through on Tuesday, and then continued rain chances through
Wednesday as the central low moves southeastward. While the entire
Bay Area and Central Coast will receive rain and stronger southerly
wind gusts, main impacts will be along the immediate coastline where
a Wind Advisory was issued, and higher precipitation totals will be
received at the highest terrain. For additional info on this system
and the extended forecast, see the discussion below.

&&

.PREV DISCUSSION...as of 02:57 PM PDT Sunday...Rest of today through
Monday: Mainly clear sky conditions prevail this afternoon with a
few cumulus clouds developing in the higher terrain. Temperatures
are generally in the 50s region-wide with 40s in the higher ridges
and peaks. Given the mostly sunny conditions, may see a few
locations peak at around 60 deg F when all said and done this
afternoon. Winds will gradually diminish through the night and
give way to yet another chilly/cold morning on Monday. A Frost
Advisory remains in effect for most interior/inland areas with
temperatures forecast to drop into the low-to-mid 30s given the
cold air mass aloft and light winds. Individuals in homes without
power as well as the unsheltered or marginally sheltered
populations will be at risk due to these cold temperatures.

Monday night through Wednesday: There is high confidence for yet
another storm system to impact the region early in the week as an
upper level system drops southward out of the Gulf of Alaska. This
system will travel southward down off of the British Columbia
coastline and strengthen as it traverses the Pacific Northwest. As
such, light rain will develop over the North Bay late Monday night
ahead of a cold front that will then sweep through the entire Bay
Area and Central Coast on Tuesday. Southerly winds will increase
ahead of and along the cold front late Monday night into Tuesday and
remain gusty until the boundary passes the region. Thus, expect wind
gusts of 40-50 mph across much of the region and potentially greater
than 60 mph in the favored coastal gaps, ridges and peaks. These
wind speeds, even for a short period of time, will increase the risk
for downed trees and tree limbs resulting in isolated power outages.
Therefore, a Wind Advisory has been issued for all coastal areas
including the City of San Francisco and the bay shoreline. Please
see SFONPWMTR for additional details on exact timing and location of
the advisory. Wind speeds are forecast to diminish in wake of the
frontal passage by late Tuesday afternoon and/or evening. However,
breezy northwest winds will prevail.

Moderate to at times heavy rainfall can be expected early Tuesday
morning as the cold front moves into the North Bay around or just
before sunrise and then across the remainder of the Bay Area through
mid-morning. Given the strong mid/upper level support associated
with the system, there is the potential for the development of a
narrow cold-frontal rainband (NCFR) as the boundary moves through
the Bay Area and then progresses southward across the Central Coast
into early afternoon. This will result in an increased risk for
urban and small stream flooding, ponding of water on roadways, and
shallow mudslides/rockslides. There is also a 10-20% probability of
thunderstorms on Tuesday as the air mass becomes more unstable just
along and in wake of the frontal passage. Scattered to numerous rain
showers will then persist into Wednesday as the core of the
mid/upper level low gradually shift southward off of the central
California coast. Rainfall amounts are forecast to range from 1.50-
2.50" in the North Bay with 2.00-4.00" in the coastal ranges of the
region. For the City of San Francisco and other coastal locations
through the Central Coast, expect 1.00-1.50" totals through midweek.
The coastal ranges from the Santa Cruz Mountains and the Santa Lucia
Range can expect 2.00-3.00" totals. The favored rain-shadowed
valleys such as the Santa Clara Valley and Salinas Valley can expect
0.25-0.75". It is these areas that may see little rain with the
initial frontal band while receiving much of their storm total
rainfall with the post frontal showers that follow. Meanwhile, snow
levels will range between 2,500-3,500 ft Monday night into Tuesday
morning before rising to above 3,500 ft during the bulk of the
precipitation. Thus, snow accumulations are likely in the highest
peaks of the Bay Area and Central Coast, yet should have minimal
impacts to the general public.

Wednesday Night through Thursday: Isolated to scattered rain showers
and high elevation snow showers will linger into Wednesday night.
Conditions will begin to dry out from north to south early Thursday
as the upper level system moves further away from the region. The
eventual track of this system will determine exactly when dry
conditions return.

Thursday night and beyond: Cool, unsettled conditions are expected
to persist heading into late week and even into the following week
with the pattern over the West Coast remaining troughy. However,
details remain difficult to nail down this far out. Stay tuned...

&&

.AVIATION...as of 11:12 PM Sunday....For the 06Z TAFs. VFR at all
area terminals as mostly clear skies prevail. No sign of any low
clouds on night satellite imagery and models only bring slight
chances of low clouds through the day Monday. Mid- and high- level
clouds fill in Monday afternoon ahead of the next storm system,
approaching from the north. Expect southerly winds to increase
Monday afternoon/evening with stronger winds arriving in the late
night hours. Rain arrives to coastal North Bay 03z-06z Tuesday,
the rest of the Bay Area 07z-12z, and Monterey Bay after 12z,
with increasing intensity Tuesday morning as a cold front passes
through the area. Conditions deteriorate to MVFR/IFR early to mid
morning.

Vicinity of SFO...VFR through Monday night before low clouds and
rain move in early Tuesday morning. Moderate westerly winds near
10 kt, easing overnight. Expect winds to turn more southerly
throughout Monday afternoon, becoming gusty during the evening,
and strong in the late night hours through Tuesday. Gusts may
reach 35-40 kt Tuesday morning. Light rain arriving near the end
of the TAF period, with heavier rain Tuesday.

SFO Bridge Approach...Similar to SFO.

Monterey Bay Terminals...VFR through the TAF period. Light SE
winds overnight into Monday morning, then turning onshore Monday
afternoon. Some high clouds begin to move in Monday afternoon
ahead of the storm system. Rain chances begin to increase after
12z Tuesday, along with stronger southerly winds.


&&

.MARINE...as of 8:38 PM PDT Sunday...Winds continue to diminish
overnight tonight across the waters. Northwest swell continues to
decay with wave heights in the outer waters gradually diminishing
overnight to 6-8 feet by Monday morning. A low pressure system
moves in and will bring rain and strong wind to the coastal waters
and bays late Monday into Tuesday, with gales returning.

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
     .Tngt...Frost Advisory...CAZ503-504-506-510-512>518-528-529
             SCA...Pt Pinos to Pt Piedras Blancas 0-10 nm until 3 AM

&&

$$

PUBLIC FORECAST: RGass/DK
AVIATION: Lorber
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 Saturday, March 25, 2023

High Temperature

120°F at Immokalee Fl, FL
120°F at George M Bryan Airport, MS

Low Temperature

-9°F at Berthoud Pass, CO
-9°F at Bryce Canyon Ap, UT

High Precipatation

2.26in at Auburn Opelika Ap, AL

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