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 Sunday, 10-Feb-2019 7:10 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 231738
AFDMTR

Area Forecast Discussion
National Weather Service San Francisco Bay Area
1038 AM PDT Tue Jul 23 2019

.SYNOPSIS...Inland temperatures will warm to above seasonal
averages through the remainder of the week and into the upcoming
weekend as high pressure dominates the weather pattern. The
influence of a shallow marine layer and persistent onshore flow
will keep conditions seasonably mild near the coast.

&&

.DISCUSSION...as of 08:47 AM PDT Tuesday...Satellite imagery
currently shows stratus over the waters and along the coast as the
marine layer remains at around 1000 ft AGL. Expect low clouds to
dissipate over land by late morning leaving mostly clear skies
across the region aside from some passing high clouds. A mid/upper
high continues to build over the Desert Southwest while an upper
low sits just offshore of western Canada with an associated trough
extending southward along the west coast down to Northern
California. The mid/upper high is circulating mid/upper level
moisture across southern and eastern California that will generate
some high clouds over our area today. Mid/upper level instability
will also continue, but at least for today will be confined to
our south and east. The aforementioned upper trough will act to
stall this weeks warming trend for today. Some areas may even be a
few degrees cooler than yesterday afternoon. Highs this afternoon
along the coast will be mainly in the upper 60s to mid 70s with
inland areas seeing widespread 80s and 90s. Isolated interior
locations may reach triple digits. Warming will pick up again
tomorrow and continue into the upcoming weekend while onshore flow
and a shallow marine layer keep coastal areas relatively mild.

&&

.PREV DISCUSSION...as of 02:51 AM PDT Tuesday...A shallow marine
layer at about 800 feet in depth has resulted in low clouds over
much of the Monterey Bay southward into the Salinas Valley. In
addition, patchy stratus can be see on GOES-W satellite imagery
along the San Francisco Peninsula as well as offshore. These
clouds may fill in a bit through sunrise, yet will be less
widespread compared to previous mornings. In addition, mid- level
moisture rotating around the building mid/upper level high
pressure over the Desert Southwest appears to have produced an
isolated high-based shower over far eastern portion of San Benito
County, now moving across western Fresno and Merced Counties.
Overall, expecting only a few sprinkles from this if any
precipitation is reaching the surface at all. Regardless, look for
mid/high level clouds to continue to move over the interior
portion of the Central Coast through the morning.

The aforementioned mid/upper level high pressure to our east will
continue to be the dominate weather feature across the southwestern
portion of the country through the remainder of the week. However,
the ridge is forecast to be suppressed slightly over northern
California today as an upper level trough just off of the British
Columbia coast pushes into the Pacific Northwest. This will stall
the warming trend a bit today with some inland locations potentially
cooling by a few degrees. Regardless, look for widespread 80s and
90s across the interior while upper 60s to middle 70s will be common
near the coast.

The warming trend will continue on Wednesday as the ridge
strengthens over the region. Daytime temperatures will likely warm
to around 10 degrees above seasonal averages over the interior.
Meanwhile, a shallow marine layer and continued onshore flow will
maintain cooler conditions near the coast with periods of
night/morning low clouds and patchy fog. Temperatures cool slightly
across inland areas Thursday and Friday, but will remain very warm.
Look for an increase in mid/upper level clouds late in the week as
monsoon moisture advects across the region around the ridge over the
Desert Southwest. With this, will need to monitor for any potential
of high-based showers and/or thunderstorms, mainly for Thursday
night.

Longer range guidance from both the ECMWF and GFS, as well as the
ensembles, indicate the ridge of high pressure will shift westward
and over southern California during the upcoming weekend. This will
likely result in additional warming with daytime temperatures
rebounding to above seasonal averages for much of the region. Thus,
will need to monitor for increased heat risks across the interior by
the weekend.

&&

.AVIATION...as of 10:38 AM PDT Tuesday...For 18z tafs. The marine
layer remains at around 1000-1200 ft AGL per the Fort Ord
Profiler while satellite imagery shows low clouds clinging to the
coastline and slowly dissipating over the Monterey region. VFR
conditions to prevail through the period for most sites. Expect
patchy stratus coverage again inland tonight and tomorrow morning.
Generally light onshore winds today with locally breezy afternoon
winds around the Bay Area taf sites.

Vicinity of KSFO...VFR prevailing through the period. Onshore
winds to increase in the afternoon (~21z) with gusts 20-25 kt.

SFO Bridge Approach...Similar to KSFO.

Monterey Bay Terminals...LIFR/IFR conditions currently at KMRY as
low clouds and fog are slow to dissipate. Anticipating clearing
within the next hour. VFR conditions to prevail into the early
evening before VLIFR-IFR cigs return. Generally light winds
through the period.

&&

.MARINE...as of 08:51 AM PDT Tuesday...Breezy northwest winds
will persist today across the coastal waters. Winds will increase
becoming gusty tonight and Wednesday as high pressure builds into
the Pacific Northwest and northern California. Light southerly
swell coupled with short period wind waves will continue through
the week.

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
     .Tday...SCA...Pigeon Pt to Pt Pinos 0-10 nm
             SCA...Pt Arena to Pt Reyes 0-10 nm
             SCA...Pt Arena to Pigeon Pt 10-60 nm
             SCA...Pigeon Pt to Pt Piedras Blancas 10-60 nm
             SCA...Pt Pinos to Pt Piedras Blancas 0-10 nm
             SCA...Pt Reyes to Pigeon Pt 0-10 nm
             SCA...Mry Bay
             SCA...SF Bay from 3 PM

&&

$$

PUBLIC FORECAST: AS/RGass
AVIATION: AS
MARINE: CW

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 USA Extremes

This script was originated by Michael of Relayweather.com and has been rewritten to use the NWS Climate Prediction Center's One Day Old Daily Data Summary text file for the USA. 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 four variables:

$usahigh - contains the text of the high temperature station(s) (value and station name from the NWS)
$usalow - contains the text of the low temperature station(s) (value and station name from the NWS)
$usaprecip - contains the text of the high precipitation station(s) (value and station name from the NWS)
$reportDate - contains the text of the date for the report (default format is 'Dayname, Month day, Year')

You can run the script by using:

<?php
include_once("usaextremes.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 courtsey of <a href=\"";
print "http://www.cpc.noaa.gov/products/analysis_monitoring/cdus/prcp_temp_tables/";
print "\">NWS-CPC</a></small></p>\n";

?>

which produces this result (with live data):

USA Extremes for Monday, July 22, 2019

High Temperature

109°F at Las Vegas/Mccarran Int, NV
109°F at Needles Airport, CA

Low Temperature

39°F at West Yellowstone, MT

High Precipatation

3.34in at Knoxville/Mcghee Tyson, TN

Data courtsey 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.

// Site to Parse
$url2 = "https://www.cpc.ncep.noaa.gov/products/analysis_monitoring/cdus/prcp_temp_tables/dly_glob1.txt";
// Name of cache file  --  This file must be set to CHMOD-666
$cacheFileDir = './'; // directory to store cache file in.
$cacheFile2 = "usaextremesCache4.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
$rUOM = 'in';     // or ='' for no rain unit display
$ignoreStations = array('99NRB'); // Station numbers to ignore, Array of station numbers

NWS CPC One Day Extremes PHP script Download (4.03e - 09-Feb-2019 see history).

deformed-offering