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

Area Forecast Discussion
National Weather Service San Francisco CA
1025 AM PDT Sun May 28 2023

...New AVIATION...

.SYNOPSIS...
Issued at 300 AM PDT Sun May 28 2023

Weather conditions largely remain unchanged with unseasonably
cool temperatures to persist into the upcoming week. Widespread
night and morning low clouds will give way to inland clearing each
afternoon. The longer range outlook shows this pattern will
likely persist into early June.

&&

.SHORT TERM...
(Today and tonight)
Issued at 300 AM PDT Sun May 28 2023

A mid/upper level cut-off low pressure system currently off of
the northern California coast will continue to drop southward
during the next 24 hours. As such, mid-to-high level clouds can be
seen on satellite this morning above the widespread stratus which
has penetrated well inland. This feature aloft has allowed for
the marine layer to compress slightly resulting in more widespread
drizzle this morning, especially near the coast and in the
favored moist upslope regions of the North Bay and East Bay.
Clouds will be slower to clear this afternoon given the mid/upper
level feature aloft. This system will also support a low
probability (10-20%) for isolated showers and/or thunderstorms
over far northern Sonoma and Napa counties, however limited
daytime heating in response to cloud cover will hinder
development. For tonight, more of the same with the return of low
clouds and patchy drizzle.

&&

.LONG TERM...
(Monday through Saturday)
Issued at 300 AM PDT Sun May 28 2023

The aforementioned upper level low will linger off of the central
and southern California coast into early next week. As a result,
expecting more of the same under the influence of troughing. Thus,
temperatures will largely remain below seasonal averages with
widespread night and morning low clouds. Patchy drizzle is also
expected to persist in this pattern as it has for the past week or
so. There are some hints of slight warming late in the upcoming
week as the closed low shifts inland. However, a general troughing
pattern will persist off of the West Coast into early June.

&&

.AVIATION...
(18Z TAFS)
Issued at 1024 AM PDT Sun May 28 2023

High clouds streaming across the area this morning as a weak cold
front aloft associated with a low pressure over north-central CA
pushes through, evident via the 12Z sounding. Radar showing very
light isolated showers, though any impacts to terminals should be
limited to brief DZ if any. High clouds contributing to some
uncertainty regarding the clearing of low clouds. Low confidence
(~20%) in clearing to VFR for Bay Area terminals. Ultimately will
need to see how the stratus deck starts to respond once high
clouds move away. Otherwise breezy onshore flow this afternoon.
There is also a low probability (10-20%) of some CB north of
KSTS/KAPC this afternoon during peak heating, though any deep
convective development will very likely be limited by the marine
layer.

Vicinity of SFO...Low confidence (~20%) in clearing to VFR during
the 21-00Z timeframe. Otherwise expecting MVFR cigs through the day
today and into Monday morning. As previously mentioned, will need to
see how low clouds respond to mid/high clouds moving out late this
morning before increasing any confidence in clearing. Breezy to
gusty onshore winds 15-20 kts this afternoon.

SFO Bridge Approach...Similar to SFO.

Monterey Bay...Moderate confidence (50-60%) in MVFR/IFR cigs through
the TAF period.  Cigs lowering to widespread IFR by the early
morning hours Monday due to marine layer compressing slightly in the
subsidence regime behind the upper low. Otherwise breezy onshore
this afternoon.

&&

.MARINE...
(Today through Friday)
Issued at 300 AM PDT Sun May 28 2023

Moderate northwest winds continue through Memorial Day with the
strongest winds over the northern outer waters. Breezy to gusty
westerly winds are also expected across the San Francisco Bay,
San Pablo Bay, Suisun Bay, and the Delta each afternoon. Longer
period background southerly swell continues through late next
week.

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
CA...None.
PZ...Small Craft Advisory until 3 PM PDT this afternoon for PZZ540.

     Small Craft Advisory until 9 PM PDT this evening for PZZ570.

&&

$$

SHORT TERM...RGass
LONG TERM....RGass
AVIATION...Behringer
MARINE...RGass

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, May 27, 2023

High Temperature

129°F at Immokalee Fl, FL

Low Temperature

25°F at Mineral Point Iowa County Ap, WI

High Precipatation

2.52in at Hinesville Ft Stewart, 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