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.

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 Thursday, 13-Oct-2016 12:40 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.

689
FXUS66 KMTR 181207
AFDMTR

Area Forecast Discussion
National Weather Service San Francisco Bay Area
507 AM PDT Wed Oct 18 2017

.SYNOPSIS...Cooler temperatures are expected today and Thursday
as onshore flow strengthens. A weak early season weather system is
forecast to bring light rain to much of the region from Thursday
afternoon through Thursday night. Dry weather is expected to
return by Friday. A warming trend will begin over the weekend.
Warm and dry weather is expected regionwide early next week.

&&

.DISCUSSION...As of 3:35 AM PDT Wednesday...KMUX radar is still
showing some weak showers over extreme southern Monterey county.
Nothing is being reported at automated gauges, so this is all
likely aloft. Meanwhile satellite imagery shows some high clouds
currently moving over the area with coastal stratus making a
resurgence and starting to spread locally inland over San
Francisco as well as into the Monterey Bay and Salinas Valley.
Current temperature trends indicate cooler temperatures in most
locations with readings from the lower 40s to the mid 50s. Surface
pressure gradients are now stronger onshore with 1.3 mb from SFO
to SAC compared to light offshore (-0.2 mb) yesterday at this
time. There is still a very weak offshore gradient component from
WMC to SFO at 2.2 mb, but this is decreasing.

Today is expected to be cooler across the district but mainly near
the coast as onshore flow ramps up with highs ranging from the
60s at the coast to the 70s and 80s inland. Additional cooling
will occur on Thursday, especially inland, as a weak storm system
approaches the coast and increases cloudiness. Latest models bring
light rain to the Sonoma coast by Thursday afternoon, and then
spreads rain across most of the North Bay by early evening. The
weakening frontal boundary will then press south of the Golden
Gate by late Thursday and bring scattered amounts of light rain to
the rest of the Bay Area Thursday evening and as far south as
Monterey County by later Thursday night. The models continue to
trend drier with this system and a blend of recent model output
indicates most locations will pick up less than a tenth of an inch
on Thursday and Thursday night. Locally higher amounts of a
quarter to a third of an inch are possible across northwest Sonoma
County. Nearly all models now indicate rain will end by daybreak
Friday.

A warming trend is forecast to begin during the weekend as an
upper level ridge begins to build over the west. The ridge will
then strengthen early next week and light offshore flow will
develop. This will result in warm and dry conditions throughout
the district next Monday and Tuesday with widespread highs in the
80s, even near the coast. The ridge is progged to flatten after
midweek.

&&

.AVIATION...As of 5:07 AM PDT Wednesday...Profiler data shows the
marine layer is compressed down to 300 to 800 feet from Bodega Bay
to Point Sur, similarly the sodar at San Carlos is showing a marine
layer temperature inversion based near 800 feet. Coverage of LIFR/VLIFR
in fog has increased rapidly overnight across the coastal waters and
up to the immediate coastline and locally into the bays per satellite
imagery and metar obs. Elsewhere VFR persists. Sufficient near surface
moisture continues to converge ahead of an elevated cool front approx
350-400 miles west of the Bay Area, and the front is forecast to proceed
toward the coast reaching the forecast area tonight. Patchy drizzle
is possible from Sea Ranch south to the San Mateo Coast to the Monterey
Peninsula tonight/Thursday morning, additionally expect low cigs in
stratus and fog. The latest NAM shows fairly rapid lower level cooling
tonight which should be enough to erode the marine inversions from
north-south tonight into Thursday. Winds will be onshore during the
period. All of this is in advance of the recently advertised (and
distinctly separate) cold frontal passage expected to arrive from
the Gulf of Alaska later Thursday.

Vicinity of KSFO...Slightly better than moderate confidence VFR holds
this morning in the vicinity of the terminal. Westerly wind is near
10 knots, onshore winds increasing with gusts to 20 knots is forecast
this afternoon and evening. VFR in 12z taf for the period, however cig
forecast confidence steadily lowers late today and tonight. If stratus
and/or fog is able to reach KSFO greatly hinges on the marine layer
depth behavior later today/tonight.

SFO Bridge Approach...Similar to KSFO.

Monterey Bay Terminals...VLIFR/LIFR this morning with partial clearing
by late morning, though timing is near low confidence. IFR due to stratus
and fog are likely to return early this evening.

&&

.FIRE WEATHER...As of 3:35 AM PDT Wednesday...Relative humidity
values have been increasing in the valleys and along the lower
coastal slopes as light onshore flow begins to develop. However,
the airmass in the hills above 1000 feet remains relatively warm
and very dry. Poor humidity recoveries are occurring in the hills
this morning. Fortunately, winds will remain light. More
widespread cooling will take place today as onshore winds increase
in the afternoon. This will result in better humidity recoveries
tonight into Thursday morning and more significant cooling by
Thursday. A weak early season weather system is forecast to bring
light rain to the North Bay from Thursday afternoon through
Thursday evening and to much of the rest of the district on
Thursday night. The models have been trending drier with this
system. Latest forecast rainfall amounts for Thursday and Thursday
night range from a tenth to a quarter of an inch across northwest
Sonoma County and northern Marin County, and generally less than
a tenth of an inch in all other areas. Rainfall is expected to end
by Friday.

A warming trend will begin over the upcoming weekend as a high
pressure ridge begins to build over California. This ridge will
strengthen into early next week and result in warm and dry
conditions districtwide on Monday and Tuesday.

&&

.MARINE...as of 4:39 AM PDT Wednesday...Compressed marine
inversions and an influx of moisture across the coastal waters is
resulting in areas of fog that is also extending into the bays.
Onshore pressure gradients will increase today causing a general
increase in winds over the bays this afternoon into tonight. A
small craft advisory will continue over the southern inner coastal
waters today and tonight. A cold front is forecast to move across
the waters late Thursday. This system may bring light rain. A
moderate to long period mixed northwesterly and southerly swell
has arrived with buoys reporting periods of 18 seconds across the
coastal waters. Late this week a very large northwesterly swell
train is forecast to move across the area. This large swell will
create hazardous conditions.

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
     .Tday...SCA...Pt Pinos to Pt Piedras Blancas 0-10 nm from 2 PM
             SCA...SF Bay from 2 PM

&&

$$

PUBLIC FORECAST: Sims
AVIATION/MARINE: Canepa
FIRE WEATHER: Sims

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.05 - 31-Mar-2015 see history).

PHP for NWS CPC USA Extremes

This script was originated by Michael of Relayweather.com and has been rewritten to use the NWS Climate Prediction Center's One Day Old Daily Data Summary text file for the USA. 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 four variables:

$usahigh - contains the text of the high temperature station(s) (value and station name from the NWS)
$usalow - contains the text of the low temperature station(s) (value and station name from the NWS)
$usaprecip - contains the text of the high precipitation station(s) (value and station name from the NWS)
$reportDate - contains the text of the date for the report (default format is 'Dayname, Month day, Year')

You can run the script by using:

<?php
include_once("usaextremes.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 courtsey of <a href=\"";
print "http://www.cpc.noaa.gov/products/analysis_monitoring/cdus/prcp_temp_tables/";
print "\">NWS-CPC</a></small></p>\n";

?>

which produces this result (with live data):

USA Extremes for Tuesday, October 17, 2017

High Temperature

101°F at Palm Springs Rgnl, CA

Low Temperature

13°F at Mount Washington, NH

High Precipatation

2.33in at Cocoa Beach/Patrick Af, FL

Data courtsey 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.

// Site to Parse
$url2 = "http://www.cpc.noaa.gov/products/analysis_monitoring/cdus/prcp_temp_tables/dly_glob1.txt";
// Name of cache file  --  This file must be set to CHMOD-666
$cacheFileDir = './'; // directory to store cache file in.
$cacheFile2 = "usaextremesCache4.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
$rUOM = 'in';     // or ='' for no rain unit display
$ignoreStations = array('99NRB'); // Station numbers to ignore, Array of station numbers

NWS CPC One Day Extremes PHP script Download (4.03 - 13-Oct-2016 see history).

deformed-offering