deformed-offering

Weather station scripts

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.
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 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 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 America/Los_Angeles<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 25 Apr 2017 is 8.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 (  $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;">&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); ?>">
<b><?php echo $UVfcstUVI[$i]; ?></b></a>&nbsp;&nbsp;<?php echo getUVword($UVfcstUVI[$i]); ?><br/><br/> 
                    
<?php // end for loop ?>  
UV forecast: 25 Apr 2017 is 8.7   Very High 

UV forecast: 26 Apr 2017 is 9.1   Very High 

UV forecast: 27 Apr 2017 is 8.7   Very High 

UV forecast: 28 Apr 2017 is 8.6   Very High 

UV forecast: 29 Apr 2017 is 8.7   Very High 

UV forecast: 30 Apr 2017 is 8.8   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)

deformed-offering