deformed-offering

Weather station scripts - ATOM/CAP advisories

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 Wednesday, 19-Jan-2022 10:03 PM

NOAA ATOM/CAP Advisory PHP scripts

This PHP script accesses and formats the Zone advisory ATOM/CAP XML feeds from www.weather.gov/alerts-beta/ to allow easy inclusion into your website. The ATOM/CAP feeds from NOAA include Advisory, Statement, Watch, and Warning type messages, but do not seem to include "Outlook" type statements (so no "Hazardous Weather Outlook" is available via the RSS feeds from weather.gov). The script has three optional arguments for the URL:

zone=ssZnnn
This allows override of the default Zone for the RSS feed to use.
inc=Y
If present, the script will not output surrounding HTML for the page returned. You should specify this if you invoke the script from within your webpage i.e.
<?php include("http://your.website/atom-advisory.php?inc=Y"); ?>
summary=Y
If present, the script will output only the titles and links for the alerts found. The links will open the page specified in the script to display the details.

There are two ways of including the script in your pages depending on whether your hoster has allow_url_include option set to on or off. The URL method only works if allow_url_include is on in your PHP settings. The File method works with allow_url_fopen in either on or off mode.

URL method (old.. not recommended for PHP5+):
Page with summary info:
<?php
include("http://your.website/atom-advisory.php?&inc=Y&summary=Y;detailpage=advdetail.php");
?>
Detail display page (advdetail.php in this example) :
<?php
include("http://your.website/atom-advisory.php?&inc=Y");
?>
File method (recommended for PHP4 or PHP5+):
Page with summary info:
<?php
$includeOnly = true;
$DefaultZone = 'WAZ021';
$doSummary = true;
$hurlURL = "advdetail.php";
include_once("atom-advisory.php");
?>
Detail display page (advdetail.php in this example) :
<?php
$includeOnly = true;
$DefaultZone = 'WAZ021';
$doSummary = false;
include_once("atom-advisory.php");
?>

You can try a test of this with your Zone (located from www.weather.gov/alerts/ RSS County/Zone feed) using this website http://saratoga-weather.org/index.php?zone=ssZnnn where ssZnnn is your Zone. The script contains the documentation for setting up operation.

The original RSS script has been greatly improved by Mike Challis and we've reissued the script as 'atom-advisory.php' .
New features include:

  • Cache file name of 'atom-advisory-ssZnnn.txt' use to prevent possible interference with existing 'rss-advisory-ssZnnn.txt' files used by the older RSS scripts.
  • Modified to use the Experimental XML/CAP 1.1 Feeds (these alerts are available now and are going to be the standard rss alerts beginning in Dec. 2009. The old alerts are to be phased put.)
  • Displays new information called "CAP codes". The CAP codes provide: Last updated time, Effective time, Expires time, Urgency, Severity, Certainty, Status, Message type, Alert Category, and Areas affected. When there is an Urgency: "Immediate" alert, the word "Immediate" will be in red highlights to stand out better.
  • Added a link "...view the complete message" on each alert so you can read the complete message on the NWS web site.
  • When there is an alert, it automatically displays a header title at the top of the advisories page that includes the zone name and zone code. ie: "Current Watches, Warnings and Advisories for Midland (TXZ062) Texas Issued by the National Weather Service". This new feature compliments the feature that lets you change the zone code by adding a query on the URL ie: atom-advisory.php?zone=TXZ062
  • When there is an active alert, it automatically displays a "source" url link at the bottom of the advisories page that links directly to the rss page where the script got the alerts. ie: "Source: NWS Watches, Warnings or Advisories for zone TXZ062". This new feature compliments the feature that lets you change the zone code by adding a query on the URL ie: atom-advisory.php?zone=TXZ062
  • New setting: $fullMessagesMode = true; // fetches the complete message for each alert.
  • New setting: $doLongTitles = true; // adds the zone name to the Alert Title for each alert.
  • Better usage of $doLowerCase setting. It will now lowercase all, then attempt to uppercase first word of every sentence.
  • Cache file improvements - cache files are now only written to the server when there is a valid zone selected
  • Fixes for handling invalid zones - now checks both input and default zone configuration for both syntax and actual existence of the NOAA zone. If a bogus zone is offered, it does not write any cache files and then displays "Advisory Information Unavailable, invalid advisory zone selected."
  • Better error handling for when the NOAA servers are having problems. View the HTML source for debugging comments.
  • Misc. fixes and improvements
  • Addition of small alert icons to display Alert Icons

Known Issues: (all fixed)
  • NWS provides this new feed with a shortened "summary", this can cause the displayed message to be shorter than the complete message that is available, click the link "view the complete message" on the alert to read the complete message on the NWS web site. (This issue has been reported to NWS, but their intent is for you to click to read the complete message for more information and instructions. So this is actually working the way they designed it.)
    Fixed to workaround this problem, set $fullMessagesMode = true;
  • The alert message may be missing the "instructions" section. Because the NWS only provides this new feed with a shortened "summary", you have to click the link "view the complete message" on the alert to read the complete message on the NWS web site. (This is the way the NWS designed the new alerts. This is to save resources by not showing the full details for some of the messages you may not be interested in viewing in detail.) Fixed to workaround this problem, set $fullMessagesMode = true;
  • The short summary message text sometimes has run-together words (This issue has been reported to NWS, hopefully they will fix it before the beta stage ends in December 2009.)
    Fixed to workaround this problem, set $fullMessagesMode = true;
  • On 14-Jun-2016, the alerts.weather.gov website switched to HTTPS access only. The script now forces https:// for access.

Note: This version requires PHP5.
Your NOAA RSS Advisory PHP script will require an upgrade to this version by December of 2009 (you can start using it now if you want).

See comments in the code for more examples and descriptions.

Download the alert-images set of files needed to show the alert icons .. unpack and upload as the alert-images/ directory on your website.

NOAA ATOM/CAP Advisory PHP script (V2.13 - 19-Jan-2022): demo and download [ see version history ]


NOAA ATOM/CAP Top Advisory Warning PHP script

This PHP script reads the same XML feed (and uses the same cache file) as the NOAA ATOM/CAP Advisory PHP described above. The main difference is it displays nothing if there are no advisories/watches/warnings for the zone specified. If there are one or more advisories/watches/warnings available, it picks the most severe one to display and uses a CSS stylable box/color to help separate the intensity of the warnings. This script is based on Jim McMurry's warnscroll.php and Tom of Carterlake's advisory.php. The order of decreasing severity is:

  • Tornado Warning
  • Other Warning
  • Watch
  • Advisory
  • Special Weather Statement
  • Short Term Forecast

This script works with the atom-advisory.php script to provide the details of the alert and can be easily incorporated on your page by using:

<?php include("atom-top-warning.php"); ?>

See the testpage and the source of the script for additional options to allow the Zone to be dynamically specified.

My thanks to Jim McMurry of jcweather.us for the coding of his warnscroll.php on which this script is based and his urging to add it to the script collection here. Thanks Jim!.

Also many thanks to Mike Challis of 642weather.com for his enhancements to the original rss-top-warning.php script and it's revision as atom-top-warning.php to use the NOAA ATOM/CAP XML feeds. His improvements include:

  • Cache file name of 'atom-advisory-ssZnnn.txt' used to prevent possible interference with existing 'rss-advisory-ssZnnn.txt' files used by the older RSS scripts.
  • Modified to use the Experimental XML/CAP 1.1 Feeds (these alerts are available now and are going to be the standard rss alerts beginning in Dec. 2009. The old alerts are to be phased put.)
  • If you install this, one new thing you might notice is that when there is no active warning, it will tell you.
    "There are no active watches, warnings or advisories for zone WAZ021."
  • Three new alerts added in the sorting of the top warning: "Hazardous Weather Outlook(possible future use)", "Evacuation Immediate" and "Extreme Fire Danger".
  • New setting: $doLongTitles = true; // adds the zone name to the Alert Title for each alert.
  • New setting: $doSilentNoActive = false; // change to true to suppress "There are no active watches, warnings or advisories ...".
  • Cache file improvements - cache files are now only written to the server when there is a valid zone selected
  • Fixes for handling invalid zones - now checks both input and default zone configuration for both syntax and actual existence of the NOAA zone. If a bogus zone is offered, it does not write any cache files and then displays "Top Warning Information Unavailable, invalid advisory zone selected."
  • Better error handling for when the NOAA servers are having problems. View the HTML source for debugging comments.
  • Misc. fixes and improvements
  • On 14-Jun-2016, the alerts.weather.gov website switched to HTTPS access only. The script now forces https:// for access.


Note: This version requires PHP5.
Your NOAA RSS Advisory PHP and RSS Top Warning scripts will require an upgrade by December of 2009 (you can start using it now if you want).

Download the alert-images set of files needed to show the alert icons .. unpack and upload as the alert-images/ directory on your website.

NOAA ATOM Top Warning PHP script (V2.11 - 19-Jan-2022) : demo and download [ see version history ]


Alternative multi-zone NOAA ATOM/CAP XML feed processor script is available

Curly of Michana Weather has developed an "all-in-one" program is available to display top warnings and full details from the ATOM feed provided by the National Weather Service from http://www.nws.noaa.gov/alerts-beta/

It is designed to handle several NOAA zones at a time and can be used with or without the Carter Lake template set.
Two sets of usable web pages are included along with a demo page, detailed instruction and a set of 72 icons.
Main features include top warnings, top warning icons, alert box and an XML page. Each alert type is color coded to its severity and has a small icon so it can be easily distinguished when there are several alerts for each zone. All alerts from NOAA's NWS ATOM/XML are accepted when available.

The script uses code borrowed (with permission) from Mike Challis to fetch the data and Michael (mth) of Relay Weather contributed some code, features and did extensive beta testing.
Because of the amount of zones that the script can handle, a cron job must be used to call the script. If your web host doesn't offer the ability to do crons, information in the readme file will guide you on how this can be done in a proven and reliable method. A "pseudo-cron" does not work and is not supported. PHP 5 is required.

Curly has kindly allowed the scripts to be included with the Base-USA template set. You can also get copies from his site. Support will be provided by Curly and by mutual assistance from the script users on WXforum.net..

More information and discussion is available on this Weather-Watch.com forum thread.


deformed-offering