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

Area Forecast Discussion
National Weather Service San Francisco Bay Area
714 PM PST Tue Dec 10 2019

.SYNOPSIS...A weak weather system will produce light rain from
late today into early Wednesday, mainly in the San Francisco Bay
Area and North Bay. A moist zonal flow will keep a chance of
light rain in the forecast for much of the week, with the best
chances across the North Bay. A system will bring another chance
of rain and cooler temperatures on Saturday with dry weather
returning Sunday and Monday.

&&

.DISCUSSION...as of 01:55 PM PST Tuesday...A weak storm system is
approaching the California coast this afternoon and will bring
light rain to the area tonight mainly north of Monterey Bay.
Temperatures this afternoon across the southern portion of the
forecast area have been mild in the upper 50s to middle 60s, where
skies have been sunny since early this morning. Low stratus and
now high clouds have kept temperatures cooler around SF Bay and
the North Bay with temperatures in the middle to upper 50s. Clouds
will continue to increase this afternoon ahead of the system.

KMUX radar has begun to detect a band of rainfall over the
coastal waters. Light rain will move into the North Bay this
afternoon and spread south to the Golden Gate and greater Bay Area
this evening. The trough associated with the rain is weakening
and will move through quickly. A brief period of steady light rain
will become more showery overnight tonight and taper off by
Wednesday morning. Rainfall totals will be light, with 0.25 to 0.5
inches across the North Bay (locally higher in the mountains),
0.1 to 0.25 across the Bay Area, and only a few hundredths of an
inch south of the Santa Cruz mountains.

A moist zonal flow will develop Wednesday through the end of the
week. A subtle disturbance in the flow and warm advection will
bring a chance of rain mainly north of the Golden Gate on
Wednesday night and Thursday. Moist onshore flow will continue
into Friday with the best chance of light rain continuing across
the North Bay. Rainfall through the end of the week will be light
with minimal impacts. A slightly warmer airmass will also arrive
with highs on Thursday in the lower to middle 60s. The moist flow
will also provide for mild overnight lows, mainly in the upper 40s
to lower 50s. The moist zonal flow will bring mostly cloudy skies
through the week.

A shortwave trough will then move through northern California on
Saturday. Currently, most of the precipitation with this system is
forecast to remain to our north. The trough will bring a cooler
airmass to the region on Saturday with highs dropping back into
the 50s. A cool, drier northwesterly flow will develop on Sunday
followed by upper level ridging early next week. A progressive
pattern still looks to persist into next week, but the Euro
ensemble has trended towards less amplified troughing.

&&

.AVIATION...as of 7:00 PM PST Tuesday...Approaching frontal
system will bring low level moisture into the area tonight along
with some light rain. MVFR cigs have appeared at STS and is
working its way into SFO Bay Area. Winds will be light and
generally out of the southeast. Models show low level moisture
lingering through the day on Wednesday so it may remain MVFR.

Vicinity of KSFO...As precip band approaches...cigs are expected
to drop gradually lower into MVFR with bases 4000-5000 ft lowering
to 2000-3000 ft after 06Z. Periods of light rain through 12Z.
MVFR cigs persisting through the day Wednesday. Light easterly
winds becoming more southeast tonight.

SFO Bridge Approach...Similar to KSFO.

Monterey Bay Terminals...Low clouds off the coast of Carmel
could spread into MRY after 04Z and SNS after 06Z. Low confidence
on timing as it could come in later. Southeast winds around 5-10
kt with except brief west winds possible this afternoon and early
evening.


&&

.MARINE...as of 07:09 PM PST Tuesday...Rain showers will impact
the waters overnight, mainly north of  Pigeon Point. Light to
moderate southerly winds will then continue through much of the
week before shifting back out of the  northwest towards the
weekend. A moderate northwest swell will  persist before a longer
period northwest swell arrives on  Thursday. Wave heights will
gradually build heading into the  coming weekend creating
hazardous seas conditions, particularly  for smaller vessels.

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
     .Tngt...SCA...Pt Arena to Pigeon Pt 10-60 nm until 3 AM
             SCA...Pt Arena to Pt Reyes 0-10 nm from 9 PM until 3 AM

&&

$$

PUBLIC FORECAST: ST
AVIATION: W Pi
MARINE: Rowe

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, December 9, 2019

High Temperature

91°F at Albany Municipal, GA

Low Temperature

-19°F at Grand Forks/Intl, ND

High Precipatation

2.81in at Hatteras (asos), 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 = "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