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.

000
FXUS66 KMTR 280552
AFDMTR

Area Forecast Discussion
National Weather Service San Francisco CA
1052 PM PDT Wed Mar 27 2024

...New AVIATION...

.SYNOPSIS...
Issued at 900 PM PDT Wed Mar 27 2024

Showers will end overnight. Breezy and cool Thursday with only
some isolated showers forecast. Southerly winds increase Friday
morning ahead of the next storm that will bring rain and scattered
thunderstorms to the region Friday into Saturday. Drying trend
Sunday as high pressure builds and lasts through the middle of
next week with a return to dry and seasonably mild weather.

&&

.SHORT TERM...
(Tonight through Friday)
Issued at 900 PM PDT Wed Mar 27 2024

Cold front is currently across the North Bay and will make its way
southward overnight. Cooler air aloft is starting to filter over
the region with an uptick in rain rates for the North Bay. So far
the heaviest rain has been confined to the North Bay hills with
0.75 for Mt Tamalpais and 0.04 last hour in the City. We noted a
clear frontal passage last hour at Bodega Bay buoy where the winds
abruptly shifted from southerly to westerly in an almost text
book fashion. Expect the frontal boundary and associated light
rainfall to shift north to south during the overnight hours with
lingering showers confined to the Monterey hills by sunrise and
perhaps some lingering morning drizzle around SF Bay. Roads will
be wet for the early morning commute.

The main weather story for Thursday will be chilly daytime highs
in the mid and upper 50s for most locations with some lower 60s
where the sun pokes out during the afternoon. Enough lingering
moisture and instability for there to be a few showers around,
especially in the North Bay Thursday afternoon as a weak shortwave
pivots across Oregon and far Northern California.

Attention quickly turns to next weather system with chilly temps
on Thursday night moderated by incoming mid/high clouds ahead of
the next storm.

Southerly winds will ramp up noticeably Friday morning in
response to a developing area of low pressure approaching the
waters west of the Golden Gate. Surface pressure dropping down to
around 997 mb means winds wont be nearly as strong as what we saw
with some storms of similar trajectory earlier this winter. Will
need to look at guidance overnight and at least be considering
wind advisories with future forecast updates. 925 mb winds in the
35 kt range suggest gust potential in the wind channeled valleys
could reach the 45 mph range especially with a deepening low
offshore. Saturated soils could lead trees more easily toppling.

&&

.LONG TERM...
(Friday night through next Wednesday)
Issued at 900 PM PDT Wed Mar 27 2024

Numerous showers and thunderstorms Friday night into Saturday as
the core of the upper low will be over the region with steep lapse
rates. Small hail will be the biggest threat but will need to at
least monitor shear profiles given the strong March sun angle and
cold air aloft.

Drying trend for Sunday as the low drops southward. High pressure
builds Monday through Weds with a return to dry weather as temps
trend above normal, back into the lower and mid 70s.

&&

.AVIATION...
(06Z TAFS)
Issued at 1047 PM PDT Wed Mar 27 2024

A cold front is currently making its way through the heart of the
Bay Area with APC and STS already seeing clearing. The cold front
will continue to drop to the southeast, bringing MVFR ceilings
and rain to the rest of the terminals. Winds will be breezy out of
the west tomorrow afternoon.

Vicinity of SFO...Currently MVFR with breezy southerly flow as the
cold front moves over the terminal. Winds will become westerly and
rain shower activity will promptly cease behind the cold front.
Winds will be breezy out of the west tomorrow afternoon.

SFO Bridge Approach...Similar to SFO.

Monterey Bay Terminals...Currently VFR with southwesterly flow at
MRY and VFR with northerly flow at SNS. Rain showers are beginning
to close in on the terminals with the cold frontal passage expected
by 11Z. Winds will become breezy out of the northwest after the cold
front passes with breezy westerly flow prevailing by tomorrow
afternoon.

&&

.MARINE...
(Tonight through next Tuesday)
Issued at 518 PM PDT Wed Mar 27 2024

Winds have started to strengthen and turn SW ahead of a weak cold
front approaching the coastal zones. The approaching front has
slowed down with widespread light to moderate showers expected to
begin over the coastal waters this afternoon and evening. A
second, stronger low pressure system will reach the coastal waters
Friday, bringing moderate precipitation, gusty southerly winds,
and allow for wave heights to build. This second system will
create widespread conditions that are hazardous to small crafts.
Northwesterly swell continues with a new long period northwesterly
swell arriving early next week.

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
CA...None.
PZ...Small Craft Advisory until 3 AM PDT Thursday for Mry Bay.

     Small Craft Advisory from 3 AM Thursday to 9 AM PDT Friday for
     Pt Arena to Pt Reyes 0-10 nm-Pt Arena to Pt Reyes 10-60 NM.

     Small Craft Advisory from 3 PM Thursday to 9 AM PDT Friday for
     Pigeon Pt to Pt Pinos 0-10 nm-Pt Pinos to Pt Piedras
     Blancas 0-10 nm-Pt Reyes to Pigeon Pt 0-10 nm.

     Small Craft Advisory from 9 AM Thursday to 9 AM PDT Friday for
     Pigeon Pt to Pt Pinos 10-60 NM.

&&

$$

SHORT TERM...RW
LONG TERM....RW
AVIATION...Sarment
MARINE...AC

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 26, 2024

High Temperature

90°F at Plant City Municipal Ap, FL

Low Temperature

-11°F at Hettinger Municipal Ap, ND

High Precipatation

10.24in at Bay Bridge Airport, MD

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