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

Area Forecast Discussion
National Weather Service San Francisco Bay Area
1025 PM PST Wed Mar 3 2021

.SYNOPSIS...Dry weather conditions will prevail with temperatures
near seasonal averages into early Friday. A frontal boundary will
bring widespread, yet generally light rainfall to the Bay Area and
Central Coast Friday night into Saturday morning. Cool, mostly
dry and breezy conditions are likely for the upcoming weekend.
Continued cool and unsettled weather returns through the first
half of next week.

&&

.DISCUSSION...as of 9:43 PM PST Wednesday...Some low clouds
forming over the North Bay early this evening with some patchy
clouds over the Monterey Bay region while clear skies prevail
elsewhere. Low pressure that brought some rain to SoCal today will
continue to eject eastward overnight. That system kept clouds
over the Bay Area today with some brisk southwesterly onshore
winds. SST remain cold, in the low 50s and you could feel the
clammy marine air coming onshore this afternoon, as downtown SF
recorded a high of only 59 today while Concord was the warm spot
at 71.

Plenty of sunshine on Thursday as high pressure will nose over the
region. Daytime highs mainly in the 60s across the region but
it`ll feel nice under the early March sun.

All attention turns to incoming rain chances for Friday night.
Before that look for increasing clouds on Friday as southwesterly
winds increase ahead of the front. Frontal timing has slowed
slightly but still looks to be a nighttime rain event Friday night
into early Saturday morning with most showers ending as early as
15z Saturday. The speed of the system will be a limiting factor
for any significant rainfall and debris flow thresholds will
likely not be met on 2020 burn areas. Rain totals of around a half
inch for the coastal hills (locally 1 inch NW Sonoma and Mt Tam),
0.25 coastal valleys and a tenth or so for interior valleys.

It will be cool and blustery behind the front on Saturday but for
all intents and purposes the weekend looks dry for outdoor plans
during the daylight hours of Saturday into Sunday.

Confidence increasing for more significant rainfall later Monday
and through Weds/Thurs of next week as multiple cold systems take
aim at NorCal and the Bay Area.

&&

.PREV DISCUSSION...as of 1:40 PM PST Wednesday...By Friday a
shift in the pattern as an upper low trough swings into NorCal.
The trough will also have a cold front associated with it. This
front will slowly move into the North Bay late Friday morning and
then slowly progress through the Bay Area through early Saturday.
The front will bring a return of some rainfall to the region.
Onset of rain will begin in the North Bay late morning and making
to SF Bay by afternoon and finally the Central Coast Friday
evening. The front initially has a decent moisture tap as it moves
into the North Bay, but the continuous moisture tap fades as the
front moves southward. Rainfall amounts are generally 0.5"-0.75"
for the coastal ranges/hills, 0.25"-0.50" for immediate Bay Area
and North Bay and 0.25" or less elsewhere. Interior portions of
Monterey/San Benito will generally be less than 0.10". Enough
colder air will fill in behind the fropa that any lingering
showers through early Saturday may be snow over the higher peaks.
Drier weather returns Saturday afternoon with some sunshine, but
temperatures will be cool. Dry conditions again on Sunday, but
only a warm up of a few degrees on Sunday.

Does the storm door finally open back up next week or at least
open a crack? Longer range models, both deterministic and
ensembles, show a colder and unsettled pattern for next week. The
first in a series of disturbances passes through the region on
Monday. Guidance suggests rain returns on Monday. Precip will
likely continue Tuesday and Wednesday as a another upper low
drifts into NorCal. Atmospheric River guidance also shows that
moisture taps will be limited Monday through Wednesday. One
difference is that much colder air will accompany these systems so
snow falling over the higher peaks will be possible.

CPC keeps much of the region with higher chances for precip
through the middle of the month.

&&

.AVIATION...as of 10:25 PM PST Wednesday...For the 06Z TAFs. Mix
of VFR/MVFR across terminals. Stratus has pushed through the
Golden Gate and is flowing into North Bay Valleys. A patch of
stratus has also formed in the Salinas Valley. Overnight,
expecting more stratus development, as a continued push of moist
marine air advects onshore. This will result in IFR/MVFR cigs
overnight through early to mid-morning. Winds have settled down
and will remain light overnight into the morning. Skies clear to
VFR Thursday morning with breezy southwesterly winds in the
afternoon.


Vicinity of KSFO...VFR with few014 reported. Stratus observed on
night satellite is being funneled through the Golden Gate into
the North Bay Valleys, but is expected to reach around the Bay
overnight bringing MVFR and possible IFR cigs after 09z. Light
onshore winds will continue to diminish overnight. Clearing to VFR
expected by mid- morning. Breezy southwest winds in the afternoon.

SFO Bridge Approach...Similar to KSFO.

Monterey Bay Terminals...VFR/MVFR with stratus in the Salinas
Valley, advancing towards the bay. MVFR/IFR cigs expected across
terminals by around 09z. Light winds overnight but breezier SE
winds in the Salinas Valley. Clearing to VFR by mid- morning with
breezy southwest to westerly winds in the afternoon.

&&

.BEACHES...as of 08:47 PM PST Wednesday...Thursday morning has a
new long period northwest swell arriving that will bring an
increased risk of sneaker waves, rip currents, long shore
currents, and there could be hard breaking surf on steep beaches.
There is the potential that these conditions will transition into
high surf on Friday. The hazard is for west and northwest facing
beaches where caution is advised. Never turn your back to the
ocean.

&&

.MARINE...as of 08:44 PM PST Wednesday...A front approaches from
the northwest on Thursday, featuring increasing winds that will
shift to the south-southwest and the addition of a new, longer
period swell arriving. Winds will be moderately breezy with models
depicting strong gusts over the northern waters. A longer period
swell arrives Thursday morning. Swell heights will increase
Thursday evening into Friday morning as the period slowly
subsides. The stronger wind gusts and the growing swell are
expected to make for hazardous seas for smaller vessels,
particularly in regions of the outer waters. Chances of rain
remains as the front arrives Friday leading into Saturday, as the
swell diminishes.

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
     .Tngt...NONE.

&&

$$

PUBLIC FORECAST: RWW
AVIATION: Lorber
MARINE: DK

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 Tuesday, March 2, 2021

High Temperature

97°F at Kyle Oakley Field Airport, KY

Low Temperature

-28°F at Mount Washington, NH

High Precipatation

2.67in at Bainbridge Decatur Co Industrial Air Park Airport, GA

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