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.
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.
This page was updated
Friday, 18-Feb-2011 10:10 PM
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<br/>
// -------------Settings ---------------------------------<br/>
$myLat = '37.27153397'; //North=positive, South=negative decimal degrees<br/>
$myLong = '-122.02274323'; //East=positive, West=negative decimal degrees<br/>
$ourTZ = "America/Los Angeles"; //NOTE: this *MUST* be set correctly to<br/>
// translate UTC times to your LOCAL time for the displays.<br/>
// http://saratoga-weather.org/timezone.txt has the list of timezone names<br/>
// pick the one that is closest to your location and put in PST8PDT<br/>
// also available is the list of country codes (helpful to pick your zone<br/>
// from the timezone.txt table<br/>
// http://saratoga-weather.org/country-codes.txt : list of country codes<br/>
$commaDecimal = false; // =true to use comma as decimal point in UVfcstUVI<br/>
// -------------End Settings -----------------------------<br/>
?>
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
<br/>
<?php<br/>
include("get-UV-forecast-inc.php");<br/>
print "UV Forecast $UVfcstDate[0] is $UVfcstUVI[0] <br/><small>($requiredNote)</small>\n";<br/>
?><br/>
UV Forecast 20 May 2013 is 8.9
(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: 20 May 2013 is
8.9 Very High
UV forecast: 21 May 2013 is
8.7 Very High
UV forecast: 22 May 2013 is
7.8 High
UV forecast: 23 May 2013 is
6.9 High
UV forecast: 24 May 2013 is
7.4 High
UV forecast: 25 May 2013 is
7.8 High
UV forecast: 26 May 2013 is
8.0 Very High
Download: get-UV-forecast-inc.php (V1.06 - 18-Feb-2011) (see Version History)
(note: this script is included with the AJAX/PHP website templates)