# IRLP Weather Script General Information

## Introduction

The following irlp scripts provide weather reports, alerts, and forecasts to the irlp user by downloading text from the National Weather Service (NWS) and converting them into speech which can be output can be played on the irlp system. The following is a brief description of the files being installed and their function.
File Information

Name | Description
nsd_ccc.txt | Used by the metar2text script
alert_list.txt | Used by getWxAlert to parse the alerts.
metar2text | Perl script that takes the metar weather information and converts to readable text (requires perl module Manip.pm).
getWxAlert [<ZONE>] | Checks to see if a weather alert has been issued, this script is called by cron (see below). It requires an argument; see below. Files are downloaded to the following directory and uses this directory as a working directory: /home/irlp/audio/custom/wx/alert/<ZONE>/wx_new.txt
ZONE argument is optional. If not included, the wx_scripts.conf file variable ZONE will be used.
getWxFor [<ZONE>] | Gets the weather forecast for the local area (can be changed). This also converts from text to audio file by calling text to audio script. This script also modifies/formats the forecast text file to allow festival to be easily understood. This script is normally called by cron. Files are are downloaded to the following directory and creates the ul audio file:
/home/irlp/audio/custom/wx/forecast/<ZONE>/wx_forecast.txt
/home/irlp/audio/custom/wx/forecast/<ZONE>/forecast.ul
ZONE argument is optional. If not included, the wx_scripts.conf file variable ZONE will be used.
getWxRpt [<ICAO_STN>] | Gets the current condition (based upon the noaa zone selected). The metar text file is downloaded and converted to text by metar2text perl script and then converted to an audio file. This script is normally called by cron. Files are located at:
/home/irlp/audio/custom/wx/report/<ICAO>.txt
/home/irlp/audio/custom/wx/report/<ICAO>.ul
The ICAO_STN is optional. If not included, the wx_scripts.conf file variable ICAO_STN will be used.
getWxRpt_ug [<WX_UNDERGRND_STN>] | Gets the current condition (based upon xml data) from Weather Underground stations. This data can be an alternative or additional to noaa metar weather reports. The xml data is downloaded from the Weather Underground station and converted to local variables. The script then uses these values to create a weather report. Since this data is more verbose, it allows greater detail including pressure trends, precipitation data, as well as other information. file. This script is normally called by cron. Files are located at:
/home/irlp/audio/custom/wx/report_ug/<WX_UNDERGRND_STN>/
The WX_UNDERGRND_STN is optional. If not included, the wx_scripts.conf file variable WX_UNDERGRND_STN will be used.
WxAlerts [<ZONE>] | Clears and removes playWxAlertBg lockfiles. This script should be used when debugging or during a force clear of weather alerts. The main function is to remove all lock files and alert messages. This will not prevent new alerts being generated.
clearWxAlerts [<ZONE>] | Clears and removes playWxAlertBg lockfiles. This script should be used when debugging or during a force clear of weather alerts. The main function is to remove all lock files and alert messages. This will not prevent new alerts being generated.
playWxAlert [<ZONE>] | Plays the FULL Wx Alert if present. This can be very lengthy with lots of "gibberish" due to the NWS formatting of their message alerts. ZONE argument is optional. If not included, the wx_scripts.conf file variable ZONE will be used.
playWxAlertBg [<ZONE>] | This program is placed in background when an alert is issued from the NWS. The script will play the alert message as follows: initial, 15m, 15m, 15m, 30m, 30m, then every 60m If this message broadcast is not desired, then you can modify the wx_scripts.conf file and change:
WXALERT_BEACON="N"
If this this is set to "N", then the playWxAlertBg will not be executed and placed in background.
ZONE argument is optional. If not included, the wx_scripts.conf file variable ZONE will be used.
playWxFor [<ZONE>] | Plays the Wx Forecast. This is normally called by the custom_decode file. ZONE argument is optional. If not included, the wx_scripts.conf file variable ZONE will be used.
playWxRpt [<ICAO_STN>] | Plays the current Wx conditions using METAR data. The ICAO_STN is optional. If not included, the wx_scripts.conf file variable ICAO_STN will be used.
playWxRpt_ug [WX_UNDERGRND_STN>] | Plays the current Wx conditions using Weather Underground XML data from local and home weather sites. The WX_UNDERGRND_STN is optional. If not included, the wx_scripts.conf file variable WX_UNDERGRND_STN will be used.
WxRpt_ug (directory) | This is a working directory used by the getWxRpt_ug and playWxRpt_ug scripts. They contain the pressure trend variables and the trend script.
I also added, in the wx_scripts.conf file, a volume setting/control forceptral speech. If you find that the voice output too loud or weak, you can change the SWIFT_VOL setting: SWIFT_VOL=100 # Volume control for swift voice # volume in percentage
WxRpt_ug/trend [<WX_UNDERGRND_STN>]
The trend script is called by cron every six hours to determine the pressure trends; steady, rising, falling. Make sure that the WX_UNDERGRND_STN variable is defined in the wx_scripts.conf file. This script uses the getWxRpt_ug script to get the pressure.var and must be run regularly. Typical cron entry would look like:
#--Download from Underground Weather
*/10 * * * * (/home/irlp/custom/getWxRpt_ug &> /dev/null 2>&1)
# cron for pressure trends, every 6 hour for 6 hour trends.
0 */6 * * * (/home/irlp/custom/WxRpt_ug/trend &> /dev/null 2>&1)
The WX_UNDERGRND_STN is optional. If not included, the wx_scripts.conf file variable WX_UNDERGRND_STN will be used.
wxtext_conv.sed | General Conversion sed file. For example: "MPH" to "Miles per Hour", etc. This sed conversion file converts the various text text files into a more pleasing sounding text to speech conversion. Many times you will need to change a pronunciation, like "wind" to "wend" to make the audio clearer or speech.
wx_scripts.conf | Configuration File. This must be edited after installation to setup the METAR (ICA0_STN variable), NWS weather zone (ZONE variable), and CALL_SPACED variable.
WxScripts.txt | This file in ascii text format.

## Installation

RPM dependencies:
You will need to install the following on a newly installed irlp node:
FC3:
wget - wget-1.10.2-0.fc3.i386.rpm
festival - festival-1.4.2-25.i386.rpm
xml - xmlstarlet-1.0.1-1.i586.rpm
manip.pm - perl-DateManip-5.42a-3.noarch.rpm
FC5:
wget - wget-1.10.2-3.2.1.i386.rpm
festival - festival- 1.95-5.2.i386.rpm
xml - xmlstarlet-1.0.1-3.fc5.i386.rpm
manip.pm - perl-DateManip-5.44-1.2.noarch.rpm
CentOS:
wget - wget-1.10.2-0.40E.i386.rpm
festival - festival-1.4.2-25.i386.rpm
xml - xmlstarlet-1.0.1-1.i386.rpm
manip.pm - perl-DateManip-5.42a-3.noarch.rpm
Normally, using Google and searching for the above will give you the pointer to the RPM. You can also try using "yum" if it's configured correctly. If you still have problems obtaining the RPMS, let me know.
"yum" example:
yum install wget
yum install festival
yum install xmlstarlet
yum install perl-DateManip

## RPM Package Installation

To install the WxScripts RPM, move the RPM file to the irlp system. As root, change directories to the location of where the WxScript RPM is located. Then execute the following command:
# rpm -i WxScripts-<version>.noarch.rpm
If you get errors regarding missing dependencies, and you have installed
the required packages, then try:
# rpm -i --nodeps WxScripts-<version>.noarch.rpm
If you are upgrading from a previous version, use the following command:
# rpm -U WxScripts-<version>.noarch.rpm

## Local Forecast/Alert/Report Customization

Before using these scripts, you need to customize them for your location. You will need to determine the noaa METAR station call for your location (for alerts and current conditions). As well as the noaa weather zone for the desired forecast location. Below are some URL pointers that should help you determine your metar/zone information.

### METAR INFO:

http://www.weather.gov/tg/siteloc.shtmlo
Go to "Display all stations" in /pulldown_menu/ and select the desired state. Then click on "Display all stations".
Select the desired identifier and write it down.

### NWS ZONE INFO:

http://www.weather.gov/alerts/<state>.php
where <state> is the 2 letter abbreviation, for example:
http://www.weather.gov/alerts/mn.php
Pick from the various cities/areas displayed.
Select the desired identifier; this will be used for the ZONE variable. Write it down.
For Example:
Metar information for Minneapolis is KMSP which is used by "getWxRpt".
Zone information for Minneapolis is MNZ059 which is used by "getWxAlert".

### WEATHER UNDERGROUND INFO:

http://www.wunderground.com/weatherstation/index.asp
Select the desired state, then press "View by US State" button (you can also choose country). Once selected, a list of stations will be displayed. Select the desired station and review the captured information to make sure that this has all of the values you want to capture. For example, some stations do not include precipitation. I prefer the "rapid fire" stations since the almost continuously update. You will use the "Station ID" for the configuration file.
Once you have the Metar (ICAO_STN), Weather Underground Station ID (WX_UNDERGRND_ID), and NWS Zone (ZONE) values from above, you use these values to edit the configuration file.

### Editing the Weather Scripts configuration file:

Add your call sign (sorry, never got around to creating a converting script):
# node call with spaced letters, for speech programs
CALL_SPACED="W 0 A N M"
The weather scripts configuration file, /home/irlp/custom/wx_scripts.conf, now contains all the user variables which can be modified. To get started, only three are required to be changed:
# Zone information for Weather Alerts
# See WxScripts.txt documentation
ZONE=MNZ059
ICAO_STN=KCFE
# for Weather Underground Stations
WX_UNDERGRND_STN=KMNSTMIC3
Verify the correct paths to the speech executable:
# location of swift binary, can also be in opt
SWIFTBIN=/usr/local/swift/bin/swift
# location of festival binary
TEXT2WAVEBIN=/usr/bin/text2wave
In addition, there are two additional variables that you may likely want to
modify:
WXALERT_BEACON="Y" # Play weather alert message
# "Y" = yes, "N" = no
ACTIVE_PLAY="TRUE" # if "TRUE", allows playing of weather
# messages when connected to other
# nodes. If not desired, change to
# "FALSE"

### Speech Setup:

Also, you need to choose which text to speech software you will be using. You must uncomment the desired speech program and comment the other one as follows:
# Choose the speech to text software desired. If cepstral is chosen, you must
# install the new software and configure the voice.
# Uncomment one only.
# TEXT2SPEECH=festival # Festival Text to speech sw
TEXT2SPEECH=cepstral # Cepstral Text to speech sw
I also added, in the wx_scripts.conf file, a volume setting/control forceptral speech. If you find that the voice output too loud or weak, you can change the SWIFT_VOL setting:
SWIFT_VOL=100 # Volume control for swift voice
# volume in percentage
Once the configuration file is edited, you are ready to test.

## Testing

After the installation script passes all of the dependency checks, you know the zones and metar information, and the "getWxFor" is modified, it's time to test the scripts.
Note

The "<ZONE>" label in the command lines refer to the ZONE value selected and placed in the wx_scripts.conf file. For example, the '<ZONE>' is replaced by 'MNZ059': ./alert/<ZONE>/wx_new.txt ^....... MNZ059 -or- ./alert/MNZ059/wx_new.txt

1. For weather Alerts, first get the data manually using the following command sequence:
su - repeater
cd custom
./getWxAlert
2. Check report:
cat /home/irlp/audio/custom/wx/alert/<ZONE>/wx_new.txt
You should see something like:
There are no active watches, warnings or advisories
(unless there is an alert active).
If the file is not present or no data, check the zone information again.
The script failed to get the alert information from the noaa website.
Unless there is an alert active, there will NOT be an audio in the
following directory:
/home/irlp/audio/custom/wx/alert/<ZONE>/COMPLETE_ALERT.ul
3. Get the forecast:
/home/irlp/custom/getWxFor
Now check the forecast information downloaded forecast:
cat /home/irlp/audio/custom/wx/forecast/<ZONE>/wx_forecast.txt
You should see something like:
KANDIYOHI-MEEKER-WRIGHT-MCLEOD-
INCLUDING THE CITIES OF. . . WILLMAR. . . LITCHFIELD. . . MONTICELLO. . .
HUTCHINSON
350 AM CDT SUN AUG 6 2006
. TODAY. . . SUNNY. HIGHS 80 TO 85. NORTHWEST WINDS 5 TO 15 miles per hour.
. TONIGHT. . . CLEAR. LOWS AROUND 55. NORTHWEST WINDS 5 TO 15 miles per hour
DECREASING TO 5 miles per hour AFTER MIDNIGHT.
. MONDAY. . . SUNNY. HIGHS AROUND 85. EAST WINDS 10 miles per hour.
. MONDAY NIGHT. . . MOSTLY CLEAR. LOWS 55 TO 60. SOUTHEAST WINDS
10 miles per hour.
. TUESDAY. . . PARTLY CLOUDY. HIGHS AROUND 85. SOUTHEAST WINDS 5 TO
15 miles per hour.
. TUESDAY NIGHT. . . PARTLY CLOUDY WITH A 20 PERCENT CHANCE OF
SHOWERS AND THUNDERSTORMS. LOWS 60 TO 65.
. end of message .
There should also be an audio file in this directory:
ls -l /home/irlp/audio/custom/wx/forecast/<ZONE>/*.ul
-rw-rw-r-- 1 repeater repeater 511121 Aug 6 09:53 /home/irlp/audio/custom/wx/forecast/MNZ059/forecast.ul
If there is no audio file, the "festival" text2wave conversion failed or the "cepstral" swift conversion failed. You will need to check the speech software.
4. Get the current metar weather report by executing the following:
/home/irlp/custom/getWxRpt
you should see the following files (names will be different for your area):
ls -l /home/irlp/audio/custom/wx
KMSP.txt
KMSP.ul
If you don't see the txt file, then getWxRpt failed getting the METAR information. If you don't see the audio file (.ul), then festival failed to generate the audio file.
If you don't see the text file, or it has blank data, check the Metar station id, or try a different location. You can specify a location without modifying the configuration file. For example:
/home/irlp/custom/getWxRpt KBDR

## Modification of the custom.crons and custom_decode script

### Without Multiple Zone Support:

- You will need to modify/add to the custom.crons file to include:

#--Check for Weather Alerts
*/15 * * * * (/home/irlp/custom/getWxAlert &> /dev/null 2>&1)
#--Download current/forecast
53 * * * * (/home/irlp/custom/getWxFor &> /dev/null 2>&1)
#--Download Metar Weather files
*/30 * * * * (/home/irlp/custom/getWxRpt &> /dev/null 2>&1)
This will become active once "update" is performed on your node.

- Modification to the custom_decode script

For the custom_decode script, here is what I did:
# Say Weather Info
if [ "$1" = "S2" ] ; then "$CUSTOM"/playWxRpt ; exit 1 ; fi
if [ "$1" = "S3" ] ; then "$CUSTOM"/playWxAlert ; exit 1 ; fi
if [ "$1" = "S4" ] ; then "$CUSTOM"/playWxFor ; exit 1 ; fi

### With Multiple Zone/location Support:

- You will need to modify/add to the "custom.crons" file to include:

#--Check for Weather Alerts
*/15 * * * * (/home/irlp/custom/getWxAlert <ZONE> &> /dev/null 2>&1)
#--Download current/forecast
53 * * * * (/home/irlp/custom/getWxFor <ZONE> &> /dev/null 2>&1)
#--Download Metar Weather files
*/30 * * * * (/home/irlp/custom/getWxRpt <ICAO_STN> &> /dev/null 2>&1)
#--Download from Underground Weather
*/10 * * * * (/home/irlp/custom/getWxRpt_ug <WX_UNDERGRND_STN> &> /dev/null 2>&1)
This will become active once "update" is performed on your node.

- Modification to the custom_decode script

For the custom_decode script, here is what I did:
# Say Weather Info
if [ "$1" = "S2" ] ; then "$CUSTOM"/playWxRpt MNZ059; exit 1 ; fi
if [ "$1" = "S3" ] ; then "$CUSTOM"/playWxAlert MNZ059; exit 1 ; fi
if [ "$1" = "S4" ] ; then "$CUSTOM"/playWxFor MNZ059; exit 1 ; fi

- Special Note for Weather Alerts

If you do not want to hear the weather alert messages continue with the alert messages, you can disable them by the following entry in the custom.decode script:
# Wx Alert message disable/enable
# disable
if [ "$1" = "P9" ] ; then $CUSTOM/disable_wx_alertmsg ; exit 1 ; fi
# Enable
if [ "$1" = "S9" ] ; then $CUSTOM/enable_wx_alertmsg ; exit 1 ; fi
Of course, you will need to modify the DTMF codes to suit your needs.

## Using the scripts

Once the cron files kick off and start getting the weather reports, you will be able to play the reports either via DTMF codes or manually.
To manually the play scripts, as "repeater" execute the following commands:
su - repeater
cd custom
./playWxRpt (or ./playWxFor, or ./playWxAlert, or ./playWxRpt_ug)
If you use the, "playWxAlert", I am sure that it will not send anything due to your weather is free of alerts ;) .

## Additional Notes

These scripts should not effect your node operation.
One final note, you can use "cepstral" text to speech. Take a look at:
http://www.cepstral.com
if you choose to use this instead of "festival", you will get to edit the wx_scripts.conf file:
Change the following variable in the scripts:
From:
# TEXT2SPEECH=cepstral
TEXT2SPEECH=festival
To:
TEXT2SPEECH=cepstral
# TEXT2SPEECH=festival
Of course, you will need to install the cepstral program. This is an easy process which is explain on their site. I would recommend at least trying the Cepstral program. It does require a license for the VOICES, but the are more natural sounding. The cost of the license is very reasonable.