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

Area Forecast Discussion
National Weather Service San Francisco Bay Area
240 PM PST Sun Dec 5 2021

.SYNOPSIS...

Breezy in the hills tonight into Monday. Light rain showers Monday
night into Tuesday with light accumulations at best. Quiet through
mid week with rain chances returning by Thursday. Cooler
temperatures for late week into the weekend.

&&

.DISCUSSION...as of 2:35 PM PST Sunday...

Today through Wednesday:

High pressure at the surface and aloft will center west of the area
today promoting drier north to northeast winds. After a cloudy
and foggy start expect continued erosion/thinning of cloud cover
through the afternoon. Temperatures should rebound nicely in the
interior valleys with highs in the mid to upper 60s. However given
slower clearing expect cooler temperatures for the coast and bays,
with readings in the upper 50s and lower 60s.

For tonight into Monday high pressure should shift away to our
southwest as a shortwave trough drops southeast across the
eastern Pacific and CA. Of the 05.12z deterministic guidance the
ECMWF is a bit more supportive of light precipitation by Monday
evening with the upper wave/vort max tracking a bit closer to the
Central Coast. In contrast, the GFS is more offshore with the
upper feature and corresponding large-scale forcing for ascent.
Regardless of track, ensembles suggest only light rain
accumulations generally on the order of .15" or less (ECWMF) to a
few hundredths (GFS), so this won`t be a washout by any stretch
of the imagination.

Winds should increase tonight into Monday in the hills as northerly
925 mb magnitudes peak around 30-40 kt. Gusty conditions are likely
around and above 2500 ft. Some of the high resolution guidance
members suggest limited downward momentum transfer into the
surface layer and resultant fog development late tonight into
Monday. Others suggest more of a BR/stratus mix. Given expected
winds/mixing am more supportive of the stratus scenario, but
couldn`t rule out some fog here or there.

Temperatures should be pretty close to seasonal averages with highs
generally in the 50s to lower/mid 60s (warmer in the southern
valleys) and lows mostly in the 40s.

Transient high pressure will bring quiet conditions and seasonally
warm temperatures for Tuesday followed by cooling by mid week.

Wednesday Night through Sunday:

A more progressive pattern should take shape as upper troughing
sharpens along the west coast on Wednesday into Thursday. Rain
chances should accompany this system Wednesday night into Thursday.
In general it appears that this system should remain progressive
with light rain amounts, but there`s time to fine tune this going
forward. With thicknesses and snow levels dropping it`s possible
that precipitation may end as light snow for peaks above 3000 ft.
That said, the latest model trend delays the cooling just enough
that precipitation may be over before the coldest air arrives.

&&

.AVIATION...as of 10:40 AM PST Sunday...For the 18z TAFs. Pockets
of fog and mist are lingering into the late morning, but should
dissipate for the afternoon. Surface winds will stay light to
moderate for the TAF period but stronger 925 mb winds will build
going into the night. This will result in widespread concerns for
LLWS with a 30 to 40 kt difference between surface winds and winds
at 2000 ft AGL. LLWS looks to last into Monday evening. Monday
morning may offer another batch of fog, but the drier flow should
limit the spread and prevent a repeat of this morning.

Vicinity of KSFO...VFR through the TAF period. Expect moderate winds
this afternoon that will ease into the evening. While surface winds
become weaker in the late night, winds aloft will increase leading
to concerns for LLWS starting around 10z. Expect winds around 40 kts
a 2000 ft AGL with surface winds staying light. The LLWS potential
looks to last well into Monday evening.

KSFO Bridge Approach...Similar to KSFO.

Monterey Bay...VFR until early Monday morning. Expect surface winds
to be light to moderate around the Monterey Bay through the day and
well into the night. Chances for fog and mist return for for early
Monday morning. Winds aloft look to strengthen for the early morning
as surface winds remain light leading to LLWS concerns, which look
to last well into Monday evening.

&&

.MARINE...as of 01:39 PM PST Sunday...Expect breezy to gusty
northwest winds to last through early work week. These winds will
generate steep hazardous wind waves which  can be hazardous to
smaller vessels. A low pressure system will  move southward across
the offshore waters bringing a chance of  rain to our coastal
waters Monday night and Tuesday morning. A  weakening northwest
swell will likely be dominated by wind  generated waves through
the coming days. These wind waves will  eventually build to
periods of 8 to 10 seconds through the work  week.

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
     .Tday...Coastal Flood Advisory...CAZ006-506-508
             SCA...Pt Arena to Pt Reyes 0-10 nm
             SCA...Pt Reyes to Pigeon Pt 0-10 nm
             SCA...Pigeon Pt to Pt Pinos 0-10 nm
             SCA...Pt Pinos to Pt Piedras Blancas 0-10 nm
             SCA...Pt Arena to Pigeon Pt 10-60 nm
             SCA...Pigeon Pt to Pt Piedras Blancas 10-60 nm

&&

$$

PUBLIC FORECAST: SPM
AVIATION: Murdock
MARINE: Murdock

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 Saturday, December 4, 2021

High Temperature

89°F at Christiansted Hamilton Field Ap, VI
89°F at Zapata County Airport, TX

Low Temperature

-5°F at Mount Washington, NH

High Precipatation

1.13in at Stampede Pass, WA

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