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 Tuesday, 28-Jul-2020 2:45 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 261749
AFDMTR

Area Forecast Discussion
National Weather Service San Francisco Bay Area
949 AM PST Sat Nov 26 2022

.SYNOPSIS...Cool this weekend with quiet weather. Turning colder
next week with a few chances for light rainfall. Frost and
freezing temperatures become more likely for inland areas towards
mid week.

&&

.DISCUSSION...as of 12:05 AM PST Saturday...

Today through Sunday:

Nighttime microphysics satellite imagery revealed a shield of mid to
high level clouds progressing into NorCal early this morning. Light
to moderate radar returns were noted across south central Oregon and
far northern California in association with a surface cold front.
Closer to home, mostly clear skies were present across much of the
area, except for some low stratus hugging the North Bay coastline. A
consensus of forecast model solutions suggest the shortwave trough
responsible for the upstream clouds and precipitation will gradually
lose amplitude as it advances towards the Great Basin with waning
moisture. Thus the surface front is expected to pass through the
area dry today, ushering in a cooler airmass. Highs today will
remain fairly seasonal, with temperatures in the lower 60s along the
coast and bays, with mid 60s to lower 70s expected for the inland
valleys. Lows tonight should drop off into the 35-45 degree range,
with the warmest readings along the coast.

For Sunday skies should clear following the frontal passage with
additional cooling. Highs will generally range from around 60 near
the coast to the upper 60s in the warmest inland valleys. With good
radiational cooling expect lows mainly in the mid 30s to lower 40s,
although some of the cooler inland spots could dip to the 32 degree
mark or even a touch cooler

Monday through Wednesday:

Upper troughing will extend from southwest Canada through the
Intermountain West early in the period with a deeper trough
approaching the Pacific Northwest by Wednesday. Deterministic models
and their ensembles have trended weaker and more inland with the
leading trough suggesting only limited precipitation chances for the
North Bay on Monday. Rain amounts, if realized, are on the order of
a few hundredths of an inch and are mainly confined to northern
Sonoma and coastal Marin Counties. Dry conditions are anticipated
for Tuesday and Wednesday following a cold frontal passage with high
pressure and colder air arriving. Expect highs in the mid 50s to
around 60, with overnight lows generally in the 30s to lower 40s.
The coldest period should be Tuesday night into Wednesday morning
where lows should mostly be in the 30s, except for some lower 40s
around the immediate San Francisco Bay. The typically colder North
Bay Valleys have a medium to high potential (50-80 percent) of
experiencing freezing temperatures, with similar potential noted
over San Benito and southern Monterey Counties. It`s also worth
noting a low potential exists (30-35 percent) for reaching freezing
within portions of the Santa Clara valley surrounding San Jose.
Temperature trends will be monitored in the days going forward but
this is a good reminder to both protect sensitive vegetation and to
check in on those without adequate access to heating during this
period of colder weather.

Thursday and Friday:

A meridional flow pattern will evolve as an upper level trough
reaches the west coast. An occluding low pressure system will locate
along the WA/OR coast with a surface cold front extending towards
our area. Deterministic model solutions appear on the wet side this
go around (26.00Z) with a decent shot for rainfall across much of
the area. However WPC Cluster Analysis ensemble members show some
variability in the strength and placement of the upper trough during
this time. This uncertainty is reflected in GFS/ECMWF ensemble
members as well which show large variability in precipitation timing
and amounts. So for now the envelope of potential solutions appears
too great to delve into any specifics. Stay tuned. Otherwise of
greater confidence is the continuance of below average temperatures
given the arrival of a colder air mass behind this system.

&&

.AVIATION...as of 09:45 AM PST Saturday...For the 18Z TAFs. A
weak, dry cold front is currently passing through the Central
Coast, which has brought clear skies. Generally light north-
northwest winds will prevail today in the post-frontal
environment. Breeziest winds around 8 to 12 knots will occur near
coastal terminals this afternoon. Winds will diminish overnight
with light drainage (SE) winds in the valleys. Low chance for cigs
tonight, as light northerly flow in the North Bay and drainage
winds for KSJC, KMRY, KSNS will help keep terminals VFR.

Vicinity of KSFO...VFR with increasing onshore winds this
afternoon. Winds diminish overnight. Some patchy stratus will
flow into the Bay overnight via the Golden Gate, but will not be
impactful to terminals overnight into tomorrow morning.

KSFO Bridge Approach...Similar to SFO.

Monterey Bay...VFR through the TAF period. Winds will be
W/NW for KMRY until tonight, where it shifts to an S/SE direction.
KSNS will have a S/SE direction initially, and will shortly
transition to W/NW, then back to the S/SE direction. With the
shift to S/SE, slight chances for lower cigs for both terminals
tonight into the morning but low confidence that it will be
MVFR/IFR ceilings.

&&

.MARINE...as of 08:30 AM PST Saturday...Wave heights have
diminished slightly, but a dry cold front is currently passing
through the northern waters which will bring breezy north-
northwest winds this afternoon, creating steep wind waves that
will be hazardous for small craft vessels. 7 to 8 foot northwest
swell at 13 to 14 seconds persists in the background and will
continue into early next week. A new, long period northwest swell
arrives on Monday.

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
     .Tday...SCA...Pt Arena to Pt Reyes 0-10 nm
             SCA...Pt Pinos to Pt Piedras Blancas 0-10 nm
             SCA...Pt Arena to Pigeon Pt 10-60 nm

&&

$$

PUBLIC FORECAST: SPM
AVIATION: McCorkle/SO
MARINE: McCorkle

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

This script was originated by Michael of Relayweather.com and has been rewritten to use the NWS Climate Prediction Center's CSV file for world observations. 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 variables:

$omittedCountry (text list of countries excluded from $world high/low/precip scans)
Note: the setting $ignoreCountrys is the array of country names to to exclude
$worldhigh
$worldlow
$worldprecip

$selectedCountry (setting: country name for selected country high/low/precip)
Note: run http://your.site.com/worldextremes.php?list to see the list of country names to use
$countryhigh
$countrylow
$countryprecip

$usahigh (Note: for lower-48 USA states)
$usalow (Note: for lower-48 USA states)
$usaprecip (Note: for lower-48 USA states)

$selectedState (setting: USA state 2-character name abbreviation in settings area)
$selectState (a copy of $selectedState for compatibility with old stateextremes.php)
$statehigh
$statelow
$stateprecip

$reportDate (nicely formatted date of the report)
$stateReportDate (a copy of $reportDate for compatibility with old stateextremes.php)

You can run the script by using:

<?php
include_once("worldextremes.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 courtesy of <a href=\"";
print "https://www.cpc.ncep.noaa.gov/products/cadb/";
print "\">NWS-CPC</a></small></p>\n";

?>

which produces this result (with live data):

USA Extremes for Friday, November 25, 2022

High Temperature

97°F at Miramar Nas, CA

Low Temperature

-6°F at Afton Muni, WY
-6°F at Dixon Airport, WY

High Precipatation

1.88in at San Angelo Mathis Field Ap, TX

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

$cacheFileDir = './'; // directory to store cache file in.
$cacheFile2 = "worldextremesCache.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 (display in C is default)
$rUOM = 'in';     // or ='' for no rain unit display (display in mm is default)
#
$ignoreCountrys = array('Antarctica','Greenland');     // for world extremes - exclude these country(s)
$ignoreStations = array('99KLRJ');     // list of stn_id (field 0) to ignore for bogus data
$tempDiffAllowed = 40; // max difference Tmax-Tmin (C) for valid data
$selectedCountry = 'Canada'; // for country max/min/precip in $country* variables
// note: the $usa* variables will have the min/max/precip for the lower-48 states
$selectedState   = 'CA';  // for USA state max/min/precip in $state* variables

Note that $cacheFileDir, $tUOM, $rUOM will use the Saratoga template Settings.php values if used in a Saratoga template.

NWS CPC One Day Extremes PHP script Download (5.04 - 28-Jul-2020 see history).

deformed-offering