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

Buy Me A Coffee 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.

Note: Twitter widget has been disabled 3-Jul-2023 since it no longer displays the recent update Tweets.

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.

788
FXUS66 KMTR 202332
AFDMTR

Area Forecast Discussion
National Weather Service San Francisco CA
332 PM PST Mon Jan 20 2025

...New AVIATION, MARINE...

.SYNOPSIS...
Issued at 144 PM PST Mon Jan 20 2025

Strong, gusty winds continue over the North Bay and East Bay Hills
where Wind Advisories will be in effect through 1 AM Tuesday. Cold
mornings continue through late week with Frost and Freeze products
likely to be reissued throughout the week. Daytime temperatures
will see a slight warming trend Tuesday through Thursday before
another pattern change takes place late week.

&&

.SHORT TERM...
(This evening through Tuesday)
Issued at 144 PM PST Mon Jan 20 2025

Gusty winds have been observed across the Bay Area with peak gusts
ranging from 66 mph to 72 mph. These winds have largely been
concentrated over the interior North Bay Mountains where a Wind
Advisory went into effect at 4 AM and will expire at 1 AM Tuesday.
Gusty winds have additionally been observed in the East Bay Hills
where a few stations are hovering right around Wind Advisory
criteria. A few sites (PG914 and PG696) in the vicinity of Mt.
Diablo State Park have been gusting to between 45 to 50 mph. With
this in mind, a Wind Advisory has been issued beginning now through
1 AM Tuesday for the East Bay Hills with gusts between 35 to 50 mph
possible. Diving deeper into our winds, the SFO-WMC pressure
gradient was -12.40 hPa as of noon. This has weakened (slightly)
from earlier in the morning when the gradient was -12.70 hPa at 10
AM PST. WRF guidance shows the pressure gradient begins will begin
to weaken more significantly during the late evening hours which
should coincide with winds starting to weaken. There is some
uncertainty on when the gradient will switch from negative
(offshore) to positive (onshore). The WRF shows the switch happening
early to mid morning on Tuesday whereas the HRRR and GFS models both
show it happening later Tuesday morning. Regardless, as the pressure
gradient weakens winds will gradually ease over the Bay Area and
drop below Wind Advisory criteria by very early Tuesday morning.

Conditions are expected to remain clear overnight which brings us to
our second hazard, a combination of Freeze Warnings and Frost
Advisories. Frost Advisories have been issued for the interior Bay
Area and Central Coast except for the southern Salinas Valley where
a Freeze Warning has been issued instead. For the Frost Advisory,
overnight temperatures are expected to drop as low as 33 degrees
with particular emphasis on the Valleys and highest ridgelines.
Given the clear skies anticipated overnight, additional radiational
cooling is expected to occur overnight which will push more
locations across the CWA into Frost Advisory territory. A Freeze
Warning will be in effect overnight for the southern Salinas Valley
where temperatures will drop as low as 26 degrees. Portions of the
Fort Hunter Liggett area and far southeastern Monterey County may
see locally colder temperatures dropping as low as 29 degrees. These
areas are bordering the Southern Salinas Valley and Arroyo Seco
zone. Cold mornings will continue through the week ahead with high
confidence in the additional issuance of Frost Advisories and medium
confidence in the additional issuances of Freeze Warnings over the
upcoming week.

&&

.LONG TERM...
(Tuesday night through next Sunday)
Issued at 144 PM PST Mon Jan 20 2025

For those of you who would prefer slightly warmer daytime weather
and less breezy conditions, the next week is for you! The positively
tilted upper level trough that has been digging into the West Coast
(bringing our early week wind) continues to look fairly progressive
and is expected to move eastward, away from the West Coast, on
Tuesday. In its place a ridge of high pressure will build over the
West Coast and bring with it clear skies and a gradual warming trend
through the week ahead. Daytime temperatures will generally be in
the 60s while the warmest portions of southern Monterey county may
reach the low 70s. On the flip side, clear skies overnight will lead
to additional radiational cooling and will continue to necessitate
the issuance of Frost/Freeze products across the Bay Area and
Central Coast. The most likely locations will be in the North Bay
Valleys and the interior Central Coast.

The pattern will again change late week as an upper level low slides
into the western United States and deepens over CA, with the ECMWF
showing the upper level low becoming cut-off over the Bay Area
before moving southwards. While this system continues to trend
fairly dry, it does look as though it will produce strong, gusty
winds both over the marine environment and over the interior North
Bay Mountains and East Bay Hills. High end small craft warnings are
likely over the southern coastal waters while Gale Warnings are
likely over the northern coastal waters. The NBM continues to show
PoPs in the range of 30-40% along the Central Coast and lower PoP
values across the Bay Area. If any rain does develop with this
system, it is likely to be only drizzle directly along the coastline
with particular emphasis on coastal Monterey County. Any rainfall
that does accumulate on the Central Coast is likely to be less than
a tenth of an inch, not meeting wetting rain criteria. CPC guidance
highlights the weeks 3-4 outlook (February 1 - 14th) as when the
return of above average precipitation is likely.

&&

.AVIATION...
(00Z TAFS)
Issued at 331 PM PST Mon Jan 20 2025

Clear skies across the terminals. With the offshore pattern and dry
conditions, expect VFR through the TAF period for all terminals.
Gusty and breezy offshore winds will start to diminish after 02-03Z
to light winds and will remain light through the TAF period.

Vicinity of SFO...VFR through the TAF period. Moderate NE winds will
diminish to light this evening and expected to turn to NW by Tuesday
afternoon.

SFO Bridge Approach...Similar to SFO.

Monterey Bay Terminals...VFR through the TAF period. SE drainage
expected this evening with moderate speeds. Winds turn NW by Tuesday
afternoon.

&&

.MARINE...
(Tonight through next Saturday)
Issued at 331 PM PST Mon Jan 20 2025

Offshore breezes prevail across the waters through Tuesday, with
moderate to strong breezes within the San Pablo and San Francisco
Bays through early Tuesday morning. Winds calm after Tuesday
through Thursday. Moderate seas will persist through Thursday
with significant wave heights becoming rough by Friday. Gale force
winds are expected Friday and into the weekend.

&&

.BEACHES...
Issued at 334 AM PST Mon Jan 20 2025

A Beach Hazards Statement is in effect for all Pacific Coast beaches
through 7 PM as a long period westerly swell is resulting in a
moderate to high risk of sneaker waves and an increased risk of rip
currents. For beachgoers to remain safe it is vital to keep off of
jetties and rocks, keep pets on a leash, observe the ocean for 20
minutes before recreating on the beach or in the ocean, and never
turn your back on the ocean.

Sarment

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
CA...Beach Hazards Statement until 7 PM PST this evening for CAZ006-
     505-509-529-530.

     Wind Advisory until 1 AM PST Tuesday for CAZ504-515.

     Frost Advisory from 1 AM to 9 AM PST Tuesday for CAZ504-506-510-
     513>515-517-518-528.

     Freeze Warning from 1 AM to 9 AM PST Tuesday for CAZ516.

PZ...None.
&&

$$

SHORT TERM...Kennedy
LONG TERM....Kennedy
AVIATION...SO
MARINE...SO

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 Sunday, January 19, 2025

High Temperature

88°F at Vero Beach Intl Ap, FL
88°F at Henry E. Rohlsen Airport, VI
88°F at Christmas/Cassid, UM

Low Temperature

-35°F at Ely Municipal Ap, MN

High Precipatation

3.68in at Jacksonville Craig Municipal Ap, FL

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