Local Radar - KMUX - GRLevel3

Saratoga-Weather.org

Weather station scripts

They're free, but use at your own risk

The scripts in PHP and Perl 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 station website.
RSS feed for Scripts Updates A RSS Feed is available to help keep you informed on updates to the scripts.

If you find one or more of the scripts useful to you, please consider making a small 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 , Weather-Watch, Ambient and Weather-Matrix forums as they become available.

This page was updated Monday, 03-Mar-2008 9:39 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 ---------------------------------
  
$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://saratoga-weather.org/timezone.txt  has the list of timezone names
//  pick the one that is closest to your location and put in America/Los Angeles
// also available is the list of country codes (helpful to pick your zone
//  from the timezone.txt table
//  http://saratoga-weather.org/country-codes.txt : list of country codes
// -------------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 5 Jul 2008 is 10.7
(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 $uv ) {
// 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
   
switch (TRUE) {
     case (
$uv == 0):
       
$uv 'None';
     break;
     case ((
$uv 0) and ($uv 3)):
       
$uv '<span style="border: solid 1px; background-color: #A4CE6a;">&nbsp;Low&nbsp;</span>';
     break;
     case ((
$uv >= 3) and ($uv 6)):
       
$uv '<span style="border: solid 1px;background-color: #FBEE09;">&nbsp;Medium&nbsp;</span>';
     break;
     case ((
$uv >=) and ($uv 8)):
       
$uv '<span style="border: solid 1px; background-color: #FD9125;">&nbsp;High&nbsp;</span>';
     break;
     case ((
$uv >=) and ($uv 11)):
       
$uv '<span style="border: solid 1px; color: #FFFFFF; background-color: #F63F37;">&nbsp;Very&nbsp;High&nbsp;</span>';
     break;
     case ((
$uv 11) ):
       
$uv '<span style="border: solid 1px; color: #FFFF00; background-color: #807780;">&nbsp;Extreme&nbsp;</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); ?>">
<?php echo $UVfcstUVI[$i]; ?></a></b>&nbsp;&nbsp;<?php echo getUVword($UVfcstUVI[$i]); ?><br/><br/> 
                    
<?php // end for loop ?>  
UV forecast: 5 Jul 2008 is 10.7   Very High 

UV forecast: 6 Jul 2008 is 9.6   Very High 

UV forecast: 7 Jul 2008 is 9.9   Very High 

UV forecast: 8 Jul 2008 is 10.0   Very High 

UV forecast: 9 Jul 2008 is 9.7   Very High 

UV forecast: 10 Jul 2008 is 10.1   Very High 

UV forecast: 11 Jul 2008 is 9.6   Very High 

UV forecast: 12 Jul 2008 is 9.0   Very High 

UV forecast: 13 Jul 2008 is 8.5   Very High 

Download: get-UV-forecast-inc.php (V1.02 - 03-Mar-2008) (see Version History)
(note: this script is included with the Carterlake-WD/AJAX/PHP website template)


Weather Station Finder USA Weather Finder  ©2006-2007 Saratoga Weather.org   Privacy Statement
Radar/maps © Weather Underground. Used with permission.    Valid XHTML 1.0     Valid CSS
Never base important decisions on this or any weather information obtained from the Internet.