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

Area Forecast Discussion
National Weather Service San Francisco Bay Area
834 AM PDT Fri Sep 17 2021

.SYNOPSIS...Mostly cloudy this morning turning sunny by midday.
Increasing clouds Saturday with a slight chance of North Bay
showers. Frontal system passes over the Bay Area Saturday night
into Sunday morning with some light rain showers North Bay down
into the Santa Cruz mountains. Dry but continued warm Sunday
afternoon. Offshore winds develop late Sunday night followed by
rapid warming and drying Monday through much of next week.

&&

.DISCUSSION...as of 08:45 AM PDT Friday...Morning satellite
imagery shows a blanket of 2400 foot marine stratus banked along
the coast and inundating most urban locations this morning. The
marine layer deepened over 2000 feet early yesterday morning in
response to a passing weak shortwave trough and has since
stabilized at its current level. 24 hour trends also indicate
a rising pressure tendency (up 2.5-3.0 mb versus yesterday
morning) and a slightly warmer, drier air mass in the subcloud
level from 1000 feet and below to the surface. The morning
synoptic pattern features a disorganized cutoff low lingering off
the Central Coast this morning, with higher pressure towards the
Four Corners and a much deeper low over the Gulf of Alaska. Today
will be similar, if not slightly warmer across the interior versus
yesterday and act as an intermediary day between yesterdays
weaker, drier trough and tomorrows deeper, wetter trough. Expect a
tangible shift in the weather pattern towards more fall like
concerns including a chance of rain Saturday night into early
Sunday and offshore wind concerns in the wake of the trough Sunday
night into Tuesday.

The overnight discussion below covers the current forecast
package in great detail, so please review it for more detail on
both the weekend rain & SW wind and early next week offshore wind
forecast.


.PREVIOUS DISCUSSION...as of 3:30 AM PDT Friday...A fair amount
of weather info to unpack this morning. In the short term the
marine layer is 2500 feet deep with widespread low clouds covering
much of the Bay Area, leaving only the higher peaks of the
Central Coast cloud free. Low clouds will slowly mix out by midday
leaving a sunny and pleasant Friday afternoon for the region. All
eyes to our north where satellite shows impressive plume of
moisture taking aim at the Pacific northwest. The origins of which
were tropical activity off the coast of Asia that got entrained
in the westerlies across the Pacific over the last week or so. TPW
values in excess of 1.5 inches for Washington and Oregon which
translates to values in excess of 200% of normal for mid Sept.
Will be watching this boundary slip southward on Saturday in
association with a well defined upper trough, jet dynamics and
cold advection that will stay focused well to our north. However
the moisture plume will slowly drift into Northern California,
though most focused north of Cape Mendocino. Our pre-existing
marine boundary layer may be influenced by the synoptic lift with
some morning drizzle or even stray showers, especially near the
coast Saturday morning. This is depicted in the model output and
our forecast package this morning.

Clouds will increase across the North Bay by Saturday afternoon
with some light rain showers possible lasting overnight. GFS
shows the moisture plume narrowing and focusing as TPW values
increase to around 1.80 inches over Cape Mendocino and then to
around 1.50 inches over the Bay Area by Saturday evening. This
simply means there will be plenty of moisture in the atmosphere
but forcing will be the question. One thing nearly everyone will
notice is much more humid or muggy conditions by Saturday
afternoon as dewpoints will rise into the upper 50s and even
lower 60s across the North Bay due to closer proximity to the
moisture plume. Model cross sections suggest the moisture will be
shallow and thus forcing will be most efficient against the
topography of the North Bay coastal mountains of Sonoma county and
perhaps around Mt Tamalpais. Some of our usual wet spots around
Venado and Cazadero could overproduce in terms of rainfall
forecast under this type of setup by Sunday morning. Official
forecasts will keep values around 0.20-0.30 for northwest Sonoma
county but local amounts of up to 0.50 inches would not be out of
the question for these locations given the available moisture,
long residence time and good orographics. That being said much of
the Bay Area proper will see little or no rain from this event.
Much drier for say Napa county with just some light rain showers
forecast and a few showers for SF down the coastline towards Santa
Cruz. Little or no precip for the East/South Bay and Central
Coast with perhaps a hundredth around the Monterey peninsula
Sunday morning as the boundary washes out.

The front will quickly wash out into a warm frontal boundary with
a rapid rebound in temperatures by Sunday afternoon as high
pressure quickly builds.

The question for Sunday night will turn to fire weather concerns
as our first offshore wind pattern of the season looks to set up.
(see fire weather section below for more specifics) Latest model
trends suggest this wont be an archetype strong Diablo wind event
but still have 72 hours to fine tune details. Current model
simulations suggest moderate northeast winds will indeed develop
Sunday night into Monday morning. Given the juicy airmass that
will be in place it will take awhile to dry things out and
humidity values look moist much of Sunday night with the strongest
winds likely staying above 2500 feet.

By Monday we should see rapid warming and drying as north winds
work down the Sacramento valley. Temperatures should jump well
into the 80s to mid 90s with rapidly lowering humidity during the
day Monday. Light offshore flow should continue Monday night into
Tuesday with little or no humidity recovery but offshore winds
look to remain pretty light at this time. Will continue to monitor
closely for fire weather concerns as we balance rainfall
potential over the weekend, a current jump in 10 hour fuel
moisture and the misalignment of strongest offshore winds with
lowest humidity values.

Long range ensembles and cluster analysis as well as strongly
negative PNA give above average confidence for unseasonably warm
and dry weather for much of next week.

&&

.AVIATION...as of 04:29 AM PDT Friday...For the 12z TAFs. A 2,000
plus ft marine layer remains in place per profiler data.
Satellite imagery shows stratus has settled around the Bay Area
and into the inland valleys. MVFR/IFR conditions to prevail
through mid to late morning. VFR conditions returning late this
morning to early this afternoon with the later clearing times
expected around the Monterey Bay. Low clouds forecast to return
again this evening. Light winds this morning with the typical sea
breeze in the afternoon.

Vicinity of KSFO...MVFR through mid to late morning (~17z-19z) as
low clouds have filled in over the bay and moved into the
terminal. VFR conditions to return by the early afternoon before
stratus is forecast to re-develop overnight tonight. Increasing
onshore winds this afternoon to around 15 kt.

KSFO Bridge Approach...Similar to KSFO.

Monterey Bay...IFR/MVFR conditions persisting through late this
morning and potentially into the early afternoon (~18z-21z).
Brief VFR conditions forecast for this afternoon before low
clouds quickly return by the early evening.

&&

.MARINE...as of 3:31 AM PDT Friday...Northwest winds will
continue to diminish overnight with locally breezy conditions
persisting into mid morning over the northern outer waters. Winds
will shift out of the south to southwest on Saturday as a cold
front moves through the waters before shifting back out of the
northwest behind the front. As an upper trough moves inland late
this weekend, expect north to northwest winds to increase over the
waters into early next week. Seas remain mixed with a short
period northwest swell and a longer period weak southerly swell.

&&

.FIRE WEATHER...as of 3:53 AM PDT Friday...Deep marine layer has
brought high RH values overnight into Friday morning. Looking at
10 hour fuel sticks values are quite moist, so the marine layer
over the last couple of days has mitigated some of the fine fuels
though long term drought conditions continue to impact all fuel
classes. For the weekend we`ll first be watching precip chances
and rainfall totals. Most likely location for wetting rains will
be coastal Sonoma county and perhaps around Mt Tamalpais. Less
than a tenth for Napa, San Mateo and Santa Cruz counties with
little or no rain East/South Bay and Central Coast. As noted above
the airmass will be very moist so RH values to remain very moist
Sunday afternoon into Sunday night.

First shot of northeast winds to arrive just before midnight
Sunday night across the Napa hills. At this time humidity values
look too moist to support critical fire weather conditions as
there will be a fairly long lag time to dry out the airmass. In
addition the strongest winds will be at or above ridgetop level
with of course stronger winds for Mt Saint Helena and Diablo.

Shortly after sunrise Monday winds could peak and humidity values
start to plummet as the dry air comes down the Sac Valley. However
we often will see widespread RH values in the teens and right now
it looks more likely to be around ~30%. Do expect rapid warming
during the day Monday with northeast offshore winds bringing
widespread upper 80s and 90s to the valleys of the North and East
Bay.

The rule of thumb is the first night (in this case Sunday night)is
when winds are strongest and the second night (in this case Monday
night) is when humidity values show no recovery but winds are
lighter. This looks to be the case with RH values staying very
dry, say below 30 percent in the hills Monday night into Tuesday
morning. Initial indications suggest the northeast winds on Monday
night will stay fairly light generally in the 15-20 mph for the
hills. All this to say is for the moment we are not expecting the
fuels, humidity and wind profiles to line up for critical offshore
wind event at this time. However, we are still several days out
and the large scale pattern suggests the potential is there. Will
also need to monitor precip totals over the weekend. Right now
the East Bay hills may be the most likely to receive no precip but
still get breezy and dry weather Monday into Tuesday.

Longer range trends show above average confidence for unseasonably
warm and dry weather for much of next week keeping fire weather
concerns elevated through the extended forecast as we get deeper
into peak fire season for the Bay Area.

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
     .Tday...SCA...Pt Arena to Pigeon Pt 10-60 nm until 9 AM

&&

$$

PUBLIC FORECAST: DRP/RWW
AVIATION: AS
MARINE: AS
FIRE WEATHER: RWW

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 Thursday, September 16, 2021

High Temperature

107°F at Blythe Asos, CA

Low Temperature

26°F at Angel Fire Airport, NM

High Precipatation

2.85in at Jacksonville Intl Ap, FL

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