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.

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, 27-Feb-2018 1:47 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 230532
AFDMTR

Area Forecast Discussion
National Weather Service San Francisco Bay Area
1032 PM PDT Sun Jul 22 2018

.SYNOPSIS...A gradual warming trend is forecast through midweek
with very warm to hot temperatures expected across the interior.
Meanwhile, onshore flow and marine air will hold temperatures down
near the coast. Inland areas are expected to cool slightly during
the second half of the week.

&&

.DISCUSSION...As of 8:50 PM PDT Sunday...Low clouds this evening
are much less extensive compared to last evening, even through
synoptic pattern and marine layer depth have changed very little.
One possible explanation is that gravity waves propagating away
from widespread thunderstorms over the Sierra may have produced
enough turbulent mixing to temporarily disrupt the marine layer.
In any case, expect low clouds to gradually become more widespread
overnight.

A strong upper ridge continues to dominate the southwestern U.S.
and currently extends from Texas west to California. The ridge is
currently centered over New Mexico, but is forecast to slowly
retrograde and be centered over southern California by midweek.
This will result in a gradual warming trend through the first
half of the work week, but primarily across inland areas. The
marine layer will likely compress slightly from its current depth
of 1500 feet, but onshore flow is forecast to persist and thus
coastal temperatures will remain mild. The warmest days for inland
areas this week are expected to be Tuesday and Wednesday. On
those days, highs will mostly be in the 90s across inland portions
of the SF Bay Area, with a few of the hottest spots reaching
triple digits. Farther to the south, across interior Monterey
County and San Benito County, widespread highs of 100 to 108 are
projected for Tuesday and Wednesday. In addition, areas in the
hills above 1000 feet will remain warm at night with overnight
lows forecast in the 70s. The combination of hot temperatures
during the day and warmth in the overnight hours will raise Heat
Risks into the high category across much of San Benito County and
interior Monterey County on both Tuesday and Wednesday. Thus, a
Heat Advisory is in effect for these areas from Noon Tuesday until
9 pm Wednesday. One other isolated area that may also see high
Heat Risk in the Tue/Wed time frame is the eastern portion of Napa
County around Lake Berryessa.

The upper ridge is forecast to gradually weaken during the second
half of the week which will result in a modest cooling trend from
Thursday through Saturday. However, longer range models maintain
an upper ridge across the southwestern U.S. through at least the
middle of next week and the latest 8-14 day outlook from the
Climate Prediction Center indicates above normal temperatures
across all areas west of the Rockies.

&&

.AVIATION...As of 10:30 PM PDT Sunday...Moisture in the mid
levels has weakened and disrupted the marine inversion and may be
causing less stratus this evening. Models forecast drier air aloft
during the night and the stratus is expected to return to the SFO
and MRY Bay Area later tonight. Marine layer currently around
1500 feet is expected to compress a bit as upper level high moves
over the state. Typical onshore flow so typical burnoff time of
the stratus of around 17Z.

Vicinity of KSFO...IFR cigs after 11Z clearing after 17Z.

SFO Bridge Approach...Similar to SFO.

Monterey Bay Terminals...Stratus over southern MRY Bay cleared
before sundown and is presently confined near WVI. Still expecting
cigs to come in after 08Z clearing after 17Z.

&&

.MARINE...as of 10:24 PM PDT Sunday...Generally light
northwesterly winds will continue across the  coastal waters
through Tuesday except for locally stronger winds near coastal
jets. A mixed northwest swell and long-period south swell will
continue through midweek.

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
     .Tngt...SCA...Pt Pinos to Pt Piedras Blancas 0-10 nm

&&

$$

PUBLIC FORECAST: Dykema
AVIATION: W Pi
MARINE: W Pi

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 Saturday, July 21, 2018

High Temperature

112°F at Ardmore Municipal, OK
112°F at Lawton/Muni, OK

Low Temperature

32°F at Meacham Amos, OR

High Precipatation

5.02in at Washington/Dulles, VA

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 = "http://www.cpc.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.03 - 13-Oct-2016 see history).

deformed-offering