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.

056
FXUS66 KMTR 120003
AFDMTR

Area Forecast Discussion
National Weather Service San Francisco Bay Area
403 PM PST Mon Nov 11 2019

.SYNOPSIS...Light offshore flow through Tuesday is expected to
reduce night and morning fog and low clouds, and result in warmer
temperatures, especially near the coast. High pressure over
California will weaken by the second half of the week, resulting
in cooler temperatures and more cloud cover. Precipitation is not
expected over the next 7 to 10 days.

&&

.DISCUSSION...as of 01:25 PM PST Monday...Offshore flow and less
cloud cover this morning led to a rather pleasant day around the
Bay Area. Afternoon satellite shows much of the low cloud cover
has diminished or pushed away from the coast. The exception is
south of Half Moon Bay and the Big Sur Coast with lingering clouds.
Latest 24 hour trend also shows a noticeable uptick in
temperatures today. Many locations around the region are running
10-15 degrees warmer than yesterday afternoon. Did a quick update
earlier in the afternoon to nudge a few places upward. Highs
today will likely top out in the mid 60s/lower 70s coast and 70s
to lower 80s inland.

Offshore flow is on track to weaken further this evening and
overnight, but still remain offshore. Therefore, dry low levels
will remain. Similar to this morning a few pockets of low cigs/fog
will be possible once again, especially along the coast and
Monterey Bay tonight. Very little change in temperatures are
expected on Tuesday with lingering offshore flow.

Slight change in the sensible weather on Wednesday as the ridge
slides eastward, onshore flow returns and a trough deepens over
the EPac. Temperatures will cool a few degrees on Wednesday with
the return of onshore flow. Further cooling is expected on
Thursday with temperatures returning closer to seasonable levels.
Models do develop some precip with the trough midweek, but keep
it north of the Bay Area. If anything, the Bay Area will see an
increase in cloud cover the second half of the work week.

An upper ridge is still on track to re-build next weekend with dry
weather remaining. The EC/Canadian/GFS all show a breakdown of the
ridge the following week with a chance of rain possibly returning
to the region. The EC actually shows a nice low bringing rain to
the Bay Area around Nov 19, but the other long range forecasts are
less bullish. At this point it is a wait and see since extended
forecasts have been all over the place lately.

&&

.AVIATION...as of 4:03 PM PST Monday...for 00z TAFs. The stratus
deck remains out to sea currently. Winds remain fairly light and
offshore, with the exception of a few coastal terminals having
locally NW flow. Most models show just high clouds surrounding the
Bay Area, with the exception of low clouds late this evening near
the KMRY Bay Terminals. The offshore flow should keep the low
clouds away from the SF Bay Area; however, the winds will be
monitored throughout the night in case it becomes too still and
the low clouds try to push in. For now it will remain out of the
TAF.

Vicinity of KSFO...Winds are currently light and out of the NW
with high clouds in the surrounding area. High clouds remain
throughout the TAF period. Winds switch back to offshore tonight
and remain light throughout the night. The offshore winds should
keep the stratus out to sea, but will be monitored through the
night.

SFO Bridge Approach...Similar to KSFO.

Monterey Bay Terminals...VFR conditions with a few passing high
clouds around the area. Winds remain light with breezier
conditions near the Salinas Valley. Models continue to support
the chance for low clouds drifting through the Bay this evening
before mixing out overnight into Tuesday morning.

&&

.MARINE...as of 03:43 PM PST Monday...Predominately light
northwest winds, with locally breezy conditions in the outer
waters north of Point Reyes. A pair of light, moderate period
northwest swells will move through the waters through mid week,
with a long period northwest swell arriving late in the week.
Northwest wind waves at 6 to 7 seconds  will further weaken
through the remainder of the day.

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
     .Tngt...None.

$$

PUBLIC FORECAST: MM/Dykema
AVIATION: DK
MARINE: DRP

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 Sunday, November 10, 2019

High Temperature

105°F at Daggett/Barstow, CA

Low Temperature

-14°F at Havre/City Co, MT

High Precipatation

0.45in at Sheridan/Co, WY

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