After using both the circular Zambretti Forecaster and the Zambretti Weathercard Forecaster, I noticed they were not always accurate as neither uses cloud cover or current weather conditions to make a forecast. I found that The Sager Weathercaster does use cloud cover and current weather conditions making it more accurate. I made BT's Global Sager Weathercaster PHP Scripts For CumulusMX earlier this year and have kept testing and improving them to what they are now. I originally used JavaScript but have since changed them to PHP as of 2013-12-31.
I have added the ability to use The Sager Weathercaster anywhere on Earth as it is originally meant for use in the Northern Temperate Zone.
Prerequisites
Your web server host must have both PHP 5.x and cURL support enabled on your account.
CumulusMX
There are some settings that need to be made to and checked in CumulusMX.
Click on SETTINGS > STATION SETTINGS:
- Under LOCATION, make sure your latitude and longitude are set correctly.
- Under OPTIONS, make sure the boxes in front of "Use bearing zero when calm" and "Cumulus pressure trend names" are checked. Also make sure you have correctly entered your GPS coordinates.
- Click SAVE at the bottom.
- Close CumulusMX.
bt-metar.php
bt-sager.js
bt-sager.php
bt-sager-cu.js
bt-sager-cu.php
bt-sager-var.php
When you open the BT's Global Sager Weathercaster PHP Scripts For CumulusMX.zip attachment at the bottom of this long post, you will see 3 PHP files:
bt-sager.php
bt-sager-cu.php
bt-sager-wc.php
Here is what they do:
bt-sager.php
This file reads data obtained from bt-sager-cu.php and bt-sager-wc.php and displays it in a useful way. You can access this file by clicking on the forecast on your weather webpage.
bt-sager-cu.php
This file is what CumulusMX updates during a web update with the correct variables to determine a forecast.
bt-sager-wc.php
This file takes the variables CumulusMX updates during a web update in bt-sager-cu.php to determine the correct forecast for your location.
Extract these 3 files to your CumulusMX web folder. Now open the CumulusMX web folder and locate bt-sager-cu.php. You will need to open it with a text editor. I HIGHLY RECOMMEND Notepad++ which is free. This is the program I am going to assume you will be using to do all which follows.
You will need to know what your closest airport's ICAO code is in order to get a METAR report. You can find this easily by going to Wunderground. You more than likely upload your CumulusMX data there already so go to the forecast for your location. Near your station name you should see a button called STATION SELECT. Click on that and you should see nearby airport codes using 4 letters. Write down the ID of the one closest to your location. You can learn more about METAR here:
http://www.wunderground.com/metarFAQ.asp
https://en.wikipedia.org/wiki/METAR
http://www.aviationweather.gov/static/a ... ations.txt
Now with bt-sager-cu.php open in Notepad++, go to Line 15 and change XXXX between the quote marks to the METAR station ID you want to use. Be sure to leave the quote marks. Make sure to enter the ICAO code in CAPITAL LETTERS. Save your changes then close Notepad++.
Next you will need to upload all 3 files once to your web server in the same directory CumulusMX uploads to during web updates.
You can now re-open CumulusMX. Once it finishes reading data, click on SETTINGS > EXTRA WEB FILES. You will see a series of boxes. The ones on the left are LOCAL files. The ones on the right are REMOTE files. You will need a blank LOCAL one with a blank REMOTE one to the right of it. Click the empty box under LOCAL. You need to browse to your CumulusMX web folder and select bt-sager-cu.php. This file along with the folder location it is in should now be in the LOCAL box. Now in the REMOTE box, you will need to type in /bt-sager-cu.php or if you are uploading to a folder use the folder name so type in /FOLDER NAME/bt-sager-cu.php. Now to the right of the REMOTE box are some check boxes. You need to check PROCESS? and FTP? so bt-sager-cu.php is updated when CumulusMX performs a web update. Click OK.
Now you need to update either the CumulusMX indexT.htm file if you are using the default templates from CumulusMX on your weather webpage or you will need to update the template files for the template you are using. Usually most folks use the default CumulusMX templates, but others use the Saratoga or the Weather by You PHP templates. All of these changes are explained below. You only need to change the ones you are using obviously.
indexT.htm
Open this with Notepad++.
CHANGE:
Code: Select all
<head>
<meta charset="UTF-8">
<meta name="description" content="<#location> weather data" />
<meta name="keywords" content="Cumulus, <#location> weather data, weather, data, weather station" />
<title><#location> weather</title>
<link href="weatherstyle.css" rel="stylesheet" type="text/css" />
</head>
Code: Select all
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="299">
<meta name="description" content="<#location> weather data" />
<meta name="keywords" content="Cumulus, <#location> weather data, weather, data, weather station" />
<title><#location> weather</title>
<link href="weatherstyle.css" rel="stylesheet" type="text/css" />
</head>
Code: Select all
<p><b>Forecast:</b> <#forecast></p>
Code: Select all
<p align= "center"><b>12-24 Hour Forecast:</b><br>
<a href = "bt-sager.php" style = "text-decoration:none;" target = "_blank"><b><font color = "#FF0000" face = "Tahoma" size = "4"><script src = "bt-sager-wc.php"></script></font></b></a></p>
Code: Select all
<p><b>12-24 Hour Forecast:</b> <a href = "bt-sager.php" style = "text-decoration:none;" target = "_blank"><b><font color = "#FF0000"><script src = "bt-sager-wc.php"></script></font></b></a></p>
That's it! Now when CumulusMX updates your website, you will see The Sager Weathercaster forecast on your main weather webpage. If you use Saratoga or Weather by You PHP templates on your website, keep reading.
The following is older info as I no longer use these templates, but they should help you still if you do. Just be aware the line numbers mentioned may have changed as these templates have been updated.
Saratoga Templates
Open bt-sager-wc.php with Notepad++. Scroll down to the very bottom of the file. Add // to the front of Line 6145 so it looks like this:
Code: Select all
// echo "document.write ('$sf');";// This allows displaying the forecast on a HTML webpage. Add // to the front of this line if using a PHP webpage.
ajax-dashboard.php
top.php
Using the 30 Dec 2013 04:31pm PST (31 Dec 2013 00:31 GMT) version of "Base-USA.zip":
For ajax-dashboard.php on Line 971, CHANGE:
Code: Select all
<td class="data1" style="width: 80px;font-size: 8pt;border: none;text-align: center" valign="middle" align="center"><strong><?php echo $forecasticons[0] . "</strong><br />" . $forecasttemp[0]; ?></td>
Code: Select all
<p align = "center" style = "line-height : 1.3"><b><font face = "Tahoma" size = "2">12-24 Hour Forecast:</font></b><br>
<a href = "bt-sager.php" style = "text-decoration:none;" target = "_blank"><b><font color = "#FF0000" face = "Tahoma" size = "4"><?php include "bt-sager-wc.php"; echo "$sf"; ?></font></b></a></p>
<td class="data1" style="width: 80px;font-size: 8pt;border: none;text-align: center" valign="middle" align="center"><strong><?php echo $forecasticons[0] . "</strong><br />" . $forecasttemp[0]; ?></td>
Code: Select all
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
Code: Select all
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<meta http-equiv="refresh" content="299">
Open bt-sager-wc.php with Notepad++. Scroll down to the very bottom of the file. Add // to the front of Line 6145 so it looks like this:
Code: Select all
// echo "document.write ('$sf');";// This allows displaying the forecast on a HTML webpage. Add // to the front of this line if using a PHP webpage.
Using the "Weather Blues V2 2a" template as an example:
CHANGE Lines 34-47 FROM:
Code: Select all
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title><?php echo $location.' | '.$TT_now; ?></title>
<meta name="keywords" content="Current, actually, last minute" />
<meta name="description" content="Current weather observations" />
<link href="styles.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="nivo-slider.css" type="text/css" media="screen" />
<script type="text/javascript" src="lib/clock/clockt.js"></script>
<script type="text/javascript" src="lib/clock/clockp.js"></script>
<script type="text/javascript" src="lib/dropmenu/dropdowntabs.js"></script>
<script type="text/javascript">
var dayname = new Array('<?php echo $Tr_sun."', '".$Tr_mon."', '".$Tr_tue."', '".$Tr_wed."', '".$Tr_thu."', '".$Tr_fri."', '".$Tr_sat."', '".$Tr_sun; ?>');
</script>
</head>
Code: Select all
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="refresh" content="299">
<title><?php echo $location.' | '.$TT_now; ?></title>
<meta name="keywords" content="Current, actually, last minute" />
<meta name="description" content="Current weather observations" />
<link href="styles.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="nivo-slider.css" type="text/css" media="screen" />
<script type="text/javascript" src="lib/clock/clockt.js"></script>
<script type="text/javascript" src="lib/clock/clockp.js"></script>
<script type="text/javascript" src="lib/dropmenu/dropdowntabs.js"></script>
<script type="text/javascript">
var dayname = new Array('<?php echo $Tr_sun."', '".$Tr_mon."', '".$Tr_tue."', '".$Tr_wed."', '".$Tr_thu."', '".$Tr_fri."', '".$Tr_sat."', '".$Tr_sun; ?>');
</script>
</head>
Code: Select all
<h1><?php echo $Tr_forecast; ?> : <span style="color: #000"><?php echo $forecast; ?></span></h1><br />
Code: Select all
<p align = "center" style = "line-height : 1.3"><b><font face = "Tahoma" size = "2">12-24 Hour Forecast:</font></b><br>
<a href = "bt-sager.php" style = "text-decoration:none;" target = "_blank"><b><font color = "#FF0000" face = "Tahoma" size = "4"><?php include "bt-sager-wc.php"; echo "$sf"; ?></font></b></a></p><br>
If you use a language other than English, you can customize bt-sager-wc.php after you extract it to the CumulusMX web folder to work properly for your location. Open bt-sager-wc.php with Notepad++ and look at Lines 154-176 and 181-294. These are the lines to be changed to your local language, however, not all of them need to be changed.
As you can see, the arrays are EXPECTED, VELOCITIES, and DIRECTION. You would need to change the Rain/Snow predictions under C, all of the EXPECTED, the VELOCITIES for the wind unit you use, and the DIRECTION for the Zone you are at.
Only change what is between the quote marks and be sure to leave the $fp1 or $fp2, the extra line spaces, periods, parentheses () marks, and semicolon ; marks! For example, let's change Line 194 from English to Spanish. It should look like this when you are done:
Code: Select all
expected[12] = "$fp1 y calentador; ";
Code: Select all
expected[12] = "$fp1 暖かい; ";
The bt-sager-wc.php file also uses English wind directions for N, NE, E, SE, S, SW, W, NW, and Calm. If you have CumulusMX set to use wind directions other than these, you need to change these.
The EASY WAY would be to click on SEARCH>REPLACE in Notepad++. Let's say you need to change NE to NO.
In FIND WHAT, enter with quotes "NE" and in REPLACE WITH, enter with quotes "NO" then click REPLACE ALL. Repeat for the other wind directions you need to change.
Save bt-sager-wc.php and re-upload it to your website.
CHANGE LOG:
2020-12-12
Minor corrections.
NOAA changed the link to the .TXT METAR reports. The .PHP files have been updated for this change.
2016-08-04
NOAA changed the link to the .TXT METAR reports. The .PHP files have been updated for this change.
2014-02-05
The Sager Weathercaster uses older names for Beaufort wind speeds. I updated all of these to their modern wording.
Some other minor improvements have been made.
The barometric pressure offset on Line 17 in bt-sager-cu.php is currently the best way to adjust for wind speeds being forecasted too high consistently. I have tried several other methods to counteract that, but have found none better than the current method of pressure offset.
2014-01-31
The METAR fix in yesterday's version needed an adjustment.
2014-01-30
For those of you who had METAR stations which had a Precipitation Code in the station ID, that has now been fixed so when you update you will not need to delete any Precipitation Codes.
Instead of using and having code for in-between wind directions NNE, ENE, ESE, SSE, SSW, WSW, WNW, and NNW which The Sager Weathercaster doesn't exactly use (they get combined into other directions), I did what The Sager Weathercaster does and just made all wind directions in 45° sections so all wind bearings are accounted for and the directions used are:
N = 338-360 and 1-22
NE = 23-67
E = 68-112
SE = 113-157
S = 158-202
SW = 203-247
W = 248-292
NW = 293-337
Calm = 0
Several other small improvements have been made to all of the PHP files.
2014-01-14
A few people were having issues with their web server hosts blocking PHP's file_get_contents which was needed by the PHP Scripts to get METAR data. I have changed this to cURL which seems to be turned on usually (at least more so than file_get_contents). If your web server host doesn't have cURL, you can ask for it to be turned on for your account or I can give you the code to change cURL back over to file_get_contents if the previous version of these PHP Scripts worked for you.
I decided to take BCJKiwi's advice and have defaults set for $m2 and $m3. The PHP Scripts should now not report any errors in XAMPP after the METAR station ID is entered in and Cumulus updates bt-sager-cu.php.
I fixed an issue with changing commas to decimal points.
A few other tweaks to the PHP Scripts have been made.
2014-01-11
The original bt-sager.php file has been renamed to bt-sager-wc.php.
The original bt-metar.php file is no longer used. Its contents have been added into bt-sager-wc.php.
The original bt-sager-var.php file has been renamed to bt-sager.php.
The Sager Weathercaster forecasts for Rain can now change to Rain or Snow (possibly mixed) or just Rain or Snow depending on the temperature.
You now add your METAR station to Line 14 of bt-sager-cu.php.
The forecast coding shown on your main weather page has also been updated and needs to be changed to what is detailed in the directions above.
METAR Precipitation Codes and optional Descriptors are now translated for those who do not know what they are when viewing bt-sager.php if precipitation is being reported in the METAR.
A Prediction Offset has been added in case the forecasted wind speed is too high or too low. It will be rare that this will need to be used. It is detailed on Line 16 of bt-sager-cu.php.
The <#altimeterpressure> webtag has been changed back to <#press> in bt-sager-cu.php.
2014-01-05
Some METAR reports in Europe and Australia use codes and characters not used here in the USA so I added these and made other modifications to "bt-metar.php" so it should now be highly accurate.
Made some minor improvements to the other .PHP files.
2014-01-03
A few corrections made. Removed the Code Number from in front of the forecast both in "bt-sager.php" and the directions so it doesn't display in front of the forecast on your main weather page or wherever you set it to display.
I made "bt-sager-var.php" prettier.
2013-12-31
The new version of BT's Global Sager Weathercaster For Cumulus now uses PHP instead of JavaScipt making it much faster!
There is no longer any need to use Cumulus' Current Condition box to type out sky conditions thanks to METAR integration!
All directions above have been updated.
Barometric trend now assumes this:
Rising Rapidly = 1.4 hPa change or more per hour.
Rising Slowly = 0.7 to less than 1.4 hPa change per hour.
Normal (Steady) = Between 0.7 and -0.7 hPa change per hour.
Falling Slowly = -0.7 up to -1.4 hPa change per hour.
Falling Rapidly = -1.4 hPa change or more per hour.
Wind bearings more precise.
2013-06-21
Instead of using barometric pressure trend names, barometric trend values determined over three hours average are used converted to hPa:
Falling Rapidly means the pressure is falling at a rate of -1.20 hPa or faster.
Falling Slowly means the pressure is falling at a rate of -0.40 to -1.19 hPa.
Steady means the pressure is falling or rising no faster than a rate of less than -0.40/0.40 hPa.
Rising Slowly means the pressure is rising at a rate of 0.40 to 1.19 hPa.
Rising Rapidly means the pressure is rising at a rate of 1.20 hPa or faster.
The above should improve forecast performance.
The rain override is now set to 30 minutes instead of 15 minutes in case if the rainfall rate is slow.
2013-06-13
JavaScripts date and time represented in international standard date and time notation.
Foggy added as a Mostly Overcast current condition.
JavaScripts var bp has been changed from using the <#RCpress> webtag to using the <#altimeterpressure> webtag in order to bypass Davis Vantage Pro/Pro2 calculations of relative barometric pressure which use other factors in addition to altitude which can make the reading too low and result in an erroneous forecast. The <#altimeterpressure> webtag does the exact same thing as the <#press> webtag for non-Davis weather stations. It is represented as:
Code: Select all
var bp = parseFloat("<#altimeterpressure>".replace(",","."));
2013-06-07
Fixed the diurnal variation of the barometer by moving the barometer trends of Rising Slowly and Falling Slowly to be seen as Steady/Normal. This should keep the forecast from switching so much. I had thought matching Rising Slowly and Falling Slowly between The Sager Weathercaster and Cumulus was the same but it is not.
Sager uses Rising Rapidly, Rising Slowly, Normal, Falling Slowly, and Falling Rapidly.
Cumulus uses Rising Very Rapidly, Rising Quickly, Rising, Rising Slowly, Steady, Falling Slowly, Falling, Falling Quickly, and Falling Very Rapidly.
The Sager has 5 dial positions for barometer trends. To make all of these match properly between Sager and Cumulus:
1) Rising Rapidly, Rising Very Rapidly, and Rising Quickly.
2) Rising.
3) Rising Slowly, Normal, Falling Slowly, and Steady.
4) Falling.
5) Falling Rapidly, Falling Quickly, and Falling Very Rapidly.
More info at viewtopic.php?p=82953#p82953
2013-06-05
The JavaScripts now assume it is Partly Cloudy if nothing is entered into the Current Condition Box.
Added km/h, kts (knot), and m/s wind speed readings to the forecast. These are determined by the wind unit selected in Cumulus.
Shortened the "bt-sager.js" file by using variables to determine certain arrays.
Localization directions added to this post.
2013-05-30
Thanks to steve, support for the new Cumulus webtag <#MinutesSinceLastRainTip> has been added. Now if you are away from your weather station, it will override the current condition forecast as a rain forecast if the rain sensor has been activated within the last 15 minutes.
Also added the longitude to the bt-sager-cu.js file to make finding a location easier.
2013-05-10
Thanks to steve, support for the new Cumulus GPS webtags which convert commas into periods has been added.
Added directions for other weather templates.
2013-05-07
Thanks to mcrossley, I added his suggestion of making some variables change automatically in the JavaScripts to lowercase letters to lessen the problem of having data being entered using proper capitalization.
I changed the Calm wind condition in bt-sager.js so that if it was Calm 3 hours ago and now the wind is blowing, the wind is seen as being Steady.
2013-05-05
Original release.