Weather station scripts

They're free, but use at your own risk

The scripts in PHP and Perl 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 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 small 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.

Latest postings about Saratoga-weather.org Weather PHP scripts on Twitter

follow Saratoga-Weather.org PHP script updates on Twitter

This page was updated Tuesday, 01-Sep-2009 2:15 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 080302
AFDMTR

AREA FORECAST DISCUSSION
NATIONAL WEATHER SERVICE SAN FRANCISCO BAY AREA
800 PM PDT TUE SEP 7 2010

.DISCUSSION...AS OF 8 PM PDT TUESDAY...COOL AND BREEZY WEATHER TO
CONTINUE ACROSS THE BAY AREA THROUGH THURSDAY.

MUCH COLDER AIR FILTERED OVER THE BAY AREA TODAY DUE TO INCREASED
ONSHORE FLOW...COOLING OF THE AIR MASS ALOFT AND A DEEPENING MARINE
LAYER. SOME OF THE BIGGEST 24 HOUR DROPS IN TEMPERATURE WERE RECORDED
AT PACIFICA 29 DEGS COOLER...SAN MARTIN 27 DEGS COOLER...OAKLAND 23
DEGS COOLER AND NAPA 23 DEGS COOLER. ALSO NOTEWORTHY FROM A FIRE
WEATHER STAND POINT...HUMIDITIES WERE AS MUCH AS 50-70 PERCENT WETTER
TODAY COMPARED TO YESTERDAY. IN ADDITION TO COOLER AND WETTER...THE
INCREASED ONSHORE FLOW HELPED TO PRODUCE SOME GUSTY CONDITIONS...
ESPECIALLY ALONG THE COAST AND EAST WEST PASSES. DURING THE EVENING
HOURS IT WAS NOT UNCOMMON TO FIND GUSTS IN THE 35 TO 45 MPH RANGE IN
THE WINDIER LOCATIONS.

FOR TONIGHT...THE LAST FEW IMAGES OF THE VIS SATELLITE DO INDICATE
THAT STRATUS IS LIKELY TO FILL BACK IN TONIGHT. IN FACT...PROFILERS
HAVE RAMPED UP TO ABOUT 2500 FEET FOR THE MARINE INVERSION.  CURRENT
FORECAST LOOKS ON TRACK WITH CLOUDS...PATCHY FOG AND COASTAL DRIZZLE.
 WINDS ARE FORECAST TO REMAIN GUSTY THE REST OF THE NIGHT AS WELL.
THEREFORE NO UPDATE IS NEEDED.

WEDNESDAY...THE SFC BOUNDARY AND UPPER LEVEL TROUGH CURRENTLY MOVING
INTO NORCAL WILL CONTINUE TO MOVE SOUTHWARD AND INTO THE CWA.
MUCH BELOW NORMAL TEMPS ARE EXPECTED ON WEDNESDAY WITH SOME COASTAL
LOCATIONS STRUGGLING TO HIT EVEN 60 DEGREES AND MANY INLAND
LOCATIONS REMAINING IN THE 60S. THE CURRENT FORECAST HAS NO MENTION
OF PRECIP ASIDE FROM DRIZZLE FOR WEDNESDAY AND KEEPS THE APPROACHING
SFC BOUNDARY DRY. SEE NO REASON TO CHANGE THIS ATTM...BUT IT SHOULD
BE NOTED THAT SOME OF THE MESOSCALE AND NUMERICAL MODELS DEVELOP
LIGHT SHOWERS OVER THE NORTHERN SACRAMENTO VALLEY AND JUST NORTH OF
THE N BAY WEDNESDAY AFTERNOON AND EVENING. ONE THING THE SFC
BOUNDARY AND UPPER LEVEL TROUGH ARE LIKELY TO DO IS MIX OUT THE
STRATUS DECK FOR WEDNESDAY. HOWEVER...ENOUGH LOWER LEVEL MOISTURE
WILL REMAIN TO ALLOW FOR A SCATTERED DECK OF CLOUDS DURING THE DAY.

THE COOLER WEATHER WILL LINGER INTO THURSDAY BUT THERE IS HOPE FOR
FRIDAY HEADING INTO THE WEEKEND.  THE TROUGH IS FORECAST TO LIFT
NORTHEAST THURSDAY NIGHT WITH RISING H5 AND WARMING 850 MB TEMPS.
THE DEPARTING TROUGH WILL LEAD TO A GRADUAL WARMING TREND INTO THE
WEEKEND WITH A RETURN OF NIGHT AND MORNING STRATUS.

&&

.AVIATION...AS OF 5:10 PM PDT TUESDAY...A MOSTLY DRY BUT UNSEASONABLY
STRONG UPPER LEVEL TROUGH OF LOW PRESSURE IS MOVING SOUTHEASTWARD
TOWARDS NORTHERN CALIFORNIA. THIS IS RESULTING IN RAPID DEEPENING OF
THE MARINE LAYER AND EARLY RETURN OF THE COASTAL STRATUS TO THE
CENTRAL SAN FRANCISCO AND MONTEREY BAY REGION TERMINALS...ALONG WITH
LOCALLY GUSTY ONSHORE EARLY EVENING WINDS. MVFR CIGS ARE EXPECTED AT
ALL TERMINALS BY LATER THIS EVENING...WITH CIGS BECOMING LIFR AT THE
MONTEREY BAY AREA TERMINALS OVERNIGHT ALONG WITH SOME COASTAL
DRIZZLE. ON WEDNESDAY...MVFR CIGS ARE EXPECTED TO PERSIST INTO THE
AFTERNOON HOURS AT ALL TERMINALS EXCEPT KSTS AND KSJC.

.VICINITY OF KSFO...MVFR CEILING JUST REDEVELOPED AND IS NOW EXPECTED
TO PERSIST THROUGH THE EVENING AND OVERNIGHT...WITH CLEARING ON
WEDNESDAY UNLIKELY BEFORE THE AFTERNOON. ONSHORE WINDS 20 KT GUSTING
TO 25 TO 30 KT THE NEXT COUPLE OF HOURS...THEN GRADUALLY DIMINISHING
OVERNIGHT.

.KSFO BRIDGE APPROACH...SIMILAR TO KSFO...CEILING JUST REDEVELOPED
AND IS NOW EXPECTED TO PERSIST THROUGH THE EVENING AND OVERNIGHT.

.MRY BAY AREA TERMINALS...MVFR CEILINGS ALREADY PRESENT AT BOTH KMRY
AND KSNS...WITH CEILINGS EXPECTED TO LOWER INTO THE LIFR RANGE
OVERNIGHT...ALONG WITH SOME COASTAL DRIZZLE VICINITY OF KMRY.
GENERALLY LIGHT ONSHORE WINDS WILL DIMINISH THROUGH THE EVENING.

&&

.MTR WATCHES/WARNINGS/ADVISORIES...
     .TNGT....SCA...PT ARENA TO PIGEON PT 10 TO 60 NM
              SCA...PT ARENA TO PIGEON PT TO 10 NM
              SCA...SF BAY SAN PABLO SUISUN BAY AND THE WEST DELTA

&&

$$

PUBLIC FORECAST: MM
AVIATION/MARINE: BLIER/LARRY

NWS MTR Office Area Forecast Discussion

To use, include the output of the script on your webpage by either using

<?php include("http://your.website.com/forecast-discussion.php?inc=Y"); ?>

or 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 // 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 (Version 1.02 - 30-Dec-2007 see history).