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.
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
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
Friday, 12-Feb-2021 9:56 AM
UV Index forecast by latitude/longitude
I've received permission from KNMI/EMA to use their handy multi-day UV-Index forecast which is based on latitude and longitude of the location. There is a requirement that you credit them as copyright holders as shown in the example below. The $requiredNote string contains the required text. The program doesn't print anything (except HTML comments) when run and is designed to be included in your page (see below). The only required settings are:
<?php
// -------------Settings ---------------------------------
$cacheFileDir = './'; // default cache file directory
$myLat = '37.27153397'; //North=positive, South=negative decimal degrees
$myLong = '-122.02274323'; //East=positive, West=negative decimal degrees
$ourTZ = "America/Los Angeles"; //NOTE: this *MUST* be set correctly to
// translate UTC times to your LOCAL time for the displays.
// http://us.php.net/manual/en/timezones.php has the list of timezone names
// pick the one that is closest to your location and put in America/Los_Angeles like:
// America/Los_Angeles = "Europe/Paris";
// America/Los_Angeles = "Pacific/Auckland";
$commaDecimal = false; // =true to use comma as decimal point in UVfcstUVI
$dateOnlyFormat = 'd M Y'; // dd MON YYYY
// -------------End Settings -----------------------------
?>
The script returns values in two arrays:
$UVfcstDate[n] contains the date of forecast in dd Mon yyyy format
$UVfcstUVI[n] contains forecast UVI in dd.d format
$UVfcstDOW[n] is the forecast Day Of Week ('Sunday' ... 'Saturday') from date('l',time()); (New in V1.02)
$UVfcstISO[n] is the forecast date in YYYYMMDD format. (New in V1.02)
where n=0...8 .
The script wil return $UVfcstUVI[n] = 'n/a' if the forecast is not available.
New with Version 1.02 - the script will adjust the returned arrays so that the [0] entry is for today (based on the timezone setting).
To use in your page, this code will show the UV forecast for one day
<?php
include("get-UV-forecast-inc.php");
print "UV Forecast $UVfcstDate[0] is $UVfcstUVI[0] <br/><small>($requiredNote)</small>\n";
?>
UV Forecast 11-Sep-2024 is 7.0
(UV forecast courtesy of and Copyright © KNMI/ESA (http://www.temis.nl/). Used with permission.)
This code will show the available forecasts with with text description and the required copyright note appears as a tooltip when you mouse over the UV values.
<?php
//=========================================================================
// decode UV to word+color for display
function getUVword ( $inUV ) {
// figure out a text value and color for UV exposure text
// 0 to 2 Low
// 3 to 5 Moderate
// 6 to 7 High
// 8 to 10 Very High
// 11+ Extreme
$uv = preg_replace('|,|','.',$inUV); // in case decimal comma option is selected
switch (TRUE) {
case ($uv == 0):
$uv = 'None';
break;
case (($uv > 0) and ($uv < 3)):
$uv = '<span style="border: solid 1px; background-color: #A4CE6a;"> Low </span>';
break;
case (($uv >= 3) and ($uv < 6)):
$uv = '<span style="border: solid 1px;background-color: #FBEE09;"> Medium </span>';
break;
case (($uv >=6 ) and ($uv < 8)):
$uv = '<span style="border: solid 1px; background-color: #FD9125;"> High </span>';
break;
case (($uv >=8 ) and ($uv < 11)):
$uv = '<span style="border: solid 1px; color: #FFFFFF; background-color: #F63F37;"> Very High </span>';
break;
case (($uv >= 11) ):
$uv = '<span style="border: solid 1px; color: #FFFF00; background-color: #807780;"> Extreme </span>';
break;
} // end switch
return $uv;
} // end getUVword
//=========================================================================
for ($i=0;$i < count($UVfcstUVI); $i++) { ?>
UV forecast: <?php echo $UVfcstDate[$i] ?> is
<a href="<?php echo htmlspecialchars($UV_URL); ?>" title="<?php echo strip_tags($requiredNote); ?>">
<b><?php echo $UVfcstUVI[$i]; ?></b></a> <?php echo getUVword($UVfcstUVI[$i]); ?><br/><br/>
<?php } // end for loop ?>
UV forecast: 11-Sep-2024 is
7.0 High
UV forecast: 12-Sep-2024 is
6.7 High
UV forecast: 13-Sep-2024 is
6.7 High
UV forecast: 14-Sep-2024 is
6.5 High
UV forecast: 15-Sep-2024 is
6.5 High
UV forecast: 16-Sep-2024 is
5.5 Medium
Download: get-UV-forecast-inc.php (V1.09 - 12-Feb-2021) (see Version History)
(note: this script is included with the AJAX/PHP website templates)