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

Area Forecast Discussion
National Weather Service San Francisco Bay Area
1127 PM PDT Mon Aug 15 2022

...Significant Heat Far Inland Areas for Tomorrow...

.SYNOPSIS...Gradual warming and drying continues as high pressure
builds into the area from the east. Excessive heat concerns for the
more interior locations expected Tuesday. Cooler conditions
expected into next weekend.

&&

.DISCUSSION...as of 09:17 PM PDT Monday...The day continued the
warming trend and it was followed by a hazy evening with a red
sunset due to smoke moving in from the Six Rivers Lightning
Complex fires. The forecast remains on track for another mild
night tonight with some pockets of fog along the coast. The main
forecasting focus will be with Tuesday high temperatures with some
monsoonal influence.

The day shift updated Tuesday`s Excessive Heat Watch into a Heat
Advisory and added portions of interior Monterey Co to the areas
affected. There is strong confidence in the forecasted highs, and
the evening shift did not see fit to make any adjustments to the
afternoon forecast package. In spite of these dangerously warm
temperatures, no daily high temperature records are expected to be
broken at any of the local climate sites.

The monsoonal moisture will be something the forecasting team
continues to track, but most of its energy looks to remain over the
sea. You can read more in the very well-written discussion from the
day shift below.

&&

.PREV DISCUSSION...as of 02:30 PM PDT Monday...Temperatures across
the area are currently in the 60s near the water with a
compressed marine layer holding tight near the coast. Temperatures
increase quickly further inland, with temps in the upper 80s and
then 90s further inland. Temperatures will continue to rise
through the afternoon with highs today reaching mid 90s for
interior valleys and upper 90s further inland. Our usual hot spots
in the interior East Bay could see temps reach low triple digits
this afternoon. Hazy conditions and small concentrations of smoke
from the Six Rivers Lightning Complex fire to advect southward
into the Bay Area possible, as indicated per the High Resolution
Rapid Refresh smoke model. Small concentrations of near surface
smoke could create hazy conditions and impact air quality. This
risk will be more concentrated towards the North Bay.

Temperatures are still on track to be the warmest tomorrow
afternoon. As such, the Heat Advisory is in effect from 11 AM to
8 PM Tuesday. An update from the previous discussion is that the
southern portion of the Salinas Valley and interior Monterey
County (including the Santa Lucia Mountains) were included in the
Heat Advisory. Temperatures in the interior will likely reach
triple digits with some areas in the farther interior near the Sac
Valley reaching or exceeding 105 degF. The area most likely to
see temps reach 105 are the interior portions of Contra Costa and
Alameda counties as well as southern Monterey and San Benito
counties.

This results in a moderate HeatRisk for much of our area, with a
high HeatRisk for locations bordering the Central Valley, including
eastern portions of Contra Costa, Alameda, Santa Clara, and San
Benito Counties. Higher elevations in the Santa Lucia mountain
range are also highlighted as a high HeatRisk. This means there
is a risk for heat- related illnesses to those who are sensitive
to heat (in the moderate risk area), with this risk extending to
most of the population in the high risk area. This concern is
greatest for those without effective cooling and/or adequate
hydration so be sure to check on your friends, neighbors, and
outside workers during this heat event. Please use caution as
temperatures will be dangerously hot in areas that are under High
HeatRisk (such as interior East Bay). If planning to partake in
outdoor activities, hydrate and take breaks often. If possible,
seek AC and cooler conditions if further inland. For more specific
information regarding where you are in terms of HeatRisk, check
out wrh.noaa.gov/wrh/heatrisk/ or weather.gov/heat.

Looking beyond Tuesday, temperatures will continue to be toasty
but start to gradually decrease. Subsequently, the HeatRisk on
Wednesday has less aerial coverage in the "High" HeatRisk
category, but a majority of our cwa remains under the "Moderate"
risk. For now, the Heat Advisory is only in effect during the day
and evening tomorrow, but stay tuned for upcoming forecasts to
see if the Heat Advisory will be extended. However at this time,
the Heat Advisory is only in effect for Tuesday. In addition,
conditions will be hazy in the Bay Area and North Bay as small
concentrations of smoke meander southward.

A surge of monsoonal moisture in the midlevels of the atmosphere is
expected to arrive tonight as well. There is some slight
instability associated with this surge of moisture (100 to 200
J/kg of MUCAPE) but at this time stays confined to over the
waters and near the coast. A slight chance for rain (15% PoPs)
was added to the forecast over the waters Wednesday overnight.
Confidence remains low on thunder chances Wednesday night, so not
included in the forecast. We will continue to monitor for this
chance.

Into the longer term, heat concerns begin to diminish by
Thursday and temperatures cool off to more seasonable
temperatures by the weekend.

&&

.AVIATION...As of 11:27 PM Monday... For the 06Z TAFs. VFR
conditions for most of the SF Bay area, and LIFR with
stratus/BR/FG around Monterey Bay. Highly compressed marine layer
depicted on the Bodega Bay profiler and a bit deeper (~1000 ft) at
the Fort Ord profiler. Satellite imagery reveals stratus covering
Monterey Bay, including coastal areas and progressing down the
Salinas Valley. Almost no stratus is observed north of Santa Cruz
County. A strong northerly ACV-SFO pressure gradient has allowed
full erosion of stratus and fog over the coastal waters, except
for the Central Coast. HREF output shows a slow recovery in
coastal stratus and fog tonight and Tuesday morning. Since the
ACV- SFO pressure gradient and wind outweighs the onshore (2.3 mb)
SFO- SAC pressure gradient and the marine layer is forecast to
stay compressed, expect very little, if any, stratus and fog
intrusion into the Bay Area tonight and Tuesday morning. More
stratus buildup likely over the coastal waters Tuesday night, as
the northerly gradient eases. The marine layer will still be very
compressed due to building high pressure, limiting inland
intrusion.

Wildfire smoke from the Six Rivers Lightning Complex over far
northern California continues to arrive in our cwa on northwest
winds. The HRRR vertically integrated smoke forecasts continue to
show smoke arriving through most of Tuesday, then by late Tuesday
and Wednesday winds shift to a southerly direction which should
help disperse smoke layers.

Vicinity of KSFO...VFR, with WNW winds near 10 kt. Clear skies
reported at the terminal which is supported by satellite imagery.
Could see FEW/SCT develop along the coast and over the bay in the
early morning hours, but cigs not expected. Breezy onshore winds
return Tuesday afternoon and evening, up to 15-20 kt. VFR
conditions forecast through the TAF period.

KSFO Bridge Approach...Similar to SFO.

Monterey Bay...Stratus and fog /VLIFR-IFR/ tonight through
Tuesday morning. Conditions lifting to VFR by late Tuesday morning
and afternoon. Winds increasing to 10 to 15 knots Tuesday
afternoon and evening. Stratus and fog returns Tuesday
evening/night with LIFR-IFR conditions likely.

&&

.MARINE...as of 8:51 PM PDT Monday...Strong northwesterly winds
continuing across the coastal waters, with near-gale-force gusts
possible in the northern outer waters through tonight. Steep,
hazardous short period seas building as a result. Winds
diminishing Tuesday morning through mid week then strengthening
again by Friday. Light southwest swell from 14 to 16 seconds
continues through the week.

&&

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

&&

$$

PUBLIC FORECAST: McCorkle/Murdock
AVIATION: Lorber
MARINE: Canepa

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 Sunday, August 14, 2022

High Temperature

108°F at Palm Springs Asos, CA

Low Temperature

3°F at Fritzsche Aaf, CA

High Precipatation

10.00in at Hampton Roads Executive Airport, VA

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