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 Thursday, 13-Oct-2016 12:40 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 252021
AFDMTR

Area Forecast Discussion
National Weather Service San Francisco Bay Area
121 PM PDT Tue Apr 25 2017

.SYNOPSIS...Seasonably cool temperatures will persist into
Wednesday as a weak system passes inland to the north. This will
result in a slight chance of light precipitation, mainly from the
Santa Cruz Mountains northward into Wednesday. A warming and
drying trend will then get underway beginning Thursday and likely
continuing into the upcoming weekend as high pressure builds over
the eastern Pacific. Breezy northerly winds are also possible from
Thursday into Friday, especially in the hills.

&&

.DISCUSSION...as of 01:20 PM PDT Tuesday...Deep moisture aloft
continues to advect inland across the region this afternoon and
has resulted in widespread mid/high level cloudiness. All of this
is in advance of a weak mid/upper level trough that will push
inland into the Pacific Northwest late tonight into Wednesday.
This system may bring some very light precipitation to the
northern portion of our region, mainly from the Santa Cruz
Mountains northward early Wednesday morning. Cannot rule out some
lingering showers into the early afternoon from the East Bay Hills
down into the Santa Lucia Mountains, yet chances for widespread
measurable rainfall remain minimal as this system lacks needed
mid/upper level support as it pushes inland to our north. With
this passing system, temperatures will be seasonably cool and
temperatures will range from the lower 06s coast to middle 60s
inland through Wednesday. Some of the warmer, interior locations
of the Central Coast may warm into the lower 70s.

A warming trend will then get underway by Thursday as dry conditions
return along with mostly sunny skies. As a stronger mid/upper level
low drops southward out of Canada into the Rockies and high pressure
develops offshore late in the week, temperatures will warm into the
70s inland. In addition, breezy to locally gusty winds will develop
due to the tightening pressure gradient from Thursday into Friday.
Further warming of the air mass aloft will result in lower 80s
during the afternoon hours this weekend while onshore winds near the
coast keep temperatures in the 60s to 70s.

Temperatures moderate slightly by early next week as the mid/upper
level ridge weakens as a system pushes inland into the Pacific
Northwest. With that said, the main storm track will remain well
north of the region and dry weather conditions are likely into the
beginning of May.

&&

.AVIATION...as of 10:19 AM PDT Tuesday...Mid and high level clouds
continue to stream in from the north ahead of the next system.
Expecting VFR today with breezy conditions. Cigs will gradually
lower overnight with -ra poss at KSTS early Wed, but will only do
VCSH for KOAK and KSFO.

Vicinity of KSFO...Little change from previous forecast. VFR
through today. MVFR cigs develop tonight/early Wednesday. A
passing shower poss early Wednesday.

SFO Bridge Approach...Similar to KSFO.

Monterey Bay Terminals...VFR. Afternoon sea breeze. Lower cigs
return tonight with MVFR category.

&&

.MARINE...as of 10:17 AM PDT Tuesday...Moderate to locally strong
northerly winds will prevail as high pressure remains anchored off
the coast. The strongest winds will likely occur monterey bay
southward along the immediate coast. Winds and seas will increase
over all coastal waters on Wednesday as high pressure
strengthens.

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
     .Tngt...SCA...Mry Bay until 9 PM
             SCA...Pigeon Pt to Pt Pinos 0-10 nm until 9 PM
             SCA...Pt Pinos to Pt Piedras Blancas 0-10 nm

&&

$$

PUBLIC FORECAST: RGass
AVIATION: MM
MARINE: MM


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.05 - 31-Mar-2015 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, April 24, 2017

High Temperature

98°F at Wink/Winkler Co, TX

Low Temperature

23°F at Yellowstone (ramos), WY

High Precipatation

4.80in at Raleigh-durham, NC

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