CVS: phpweather-1.x images.inc,NONE,1.1 list.php,NONE,1.1 table.php,NONE,1.1
Brought to you by:
iridium
From: Martin G. <gim...@us...> - 2002-03-10 20:22:40
|
Update of /cvsroot/phpweather/phpweather-1.x In directory usw-pr-cvs1:/tmp/cvs-serv15822 Added Files: images.inc list.php table.php Log Message: This is the files that enables you to use icons in PHP Weather - Raymond van Beek <ra...@de...> has made the hard work. --- NEW FILE --- <?php /* Copyright (c) 2002 Raymond van Beek <ra...@de...>. Licensed under the GPL, see the file COPYING. Parts of this code are derived from the phpweather.inc code by Martin Geisler <gim...@gi...> Also see http://www.gimpster.com/php/phpweather/ or http://www.sourceforge.net/projects/phpweather for updates and further instructions on how to use PHP Weather. */ // ======================================================================= // This section contains user configurable items: The user can configure // the image filenames to be generated by the script. // Specify the absolute path to the directory that contains the weather // icon files. $abs_image_path = 'icons/'; // An array to convert the weather group codes to an index of the // $images and $n_images array. $phenomena_array = array ( '#' => 'None', 'TS' => 'Thun', 'RA' => 'Rain', 'DZ' => 'Rain', 'SN' => 'Snow', 'SG' => 'Snow', 'GR' => 'Hail', 'GS' => 'Hail', 'PE' => 'Hail', 'IC' => 'Hail', 'BR' => 'Fog', 'FG' => 'Fog' ); // An array to convert the cloud coverage codes to an index of the // $images and $n_images array. $coverage = array ( 'CLR' => '0', 'SKC' => '0', 'FEW' => '1', 'SCT' => '2', 'BKN' => '3', 'OVC' => '4', 'VV' => '4' ); // Clear all images if (isset($images)) { unset($images); } if (isset($n_images)) { unset($n_images); } $sky_nodata_image = 'sky_nodata.gif'; // Define a lot of images for daylight weather-group/cloud condition. // It's a 2-dimensional array, indexed by the: // - Precipitation (first index) // - Cloud coverage (second index). $images = array ( 'None' => array ('0' => '0cloud.gif', '1' => '1cloud_norain.gif', '2' => '2cloud_norain.gif', '3' => '3cloud_norain.gif', '4' => '4cloud_norain.gif'), '-Rain' => array ('0' => '0cloud.gif', '1' => '1cloud_lightrain.gif', '2' => '2cloud_lightrain.gif', '3' => '3cloud_lightrain.gif', '4' => '4cloud_lightrain.gif'), 'Rain' => array ('0' => '0cloud.gif', '1' => '1cloud_modrain.gif', '2' => '2cloud_modrain.gif', '3' => '3cloud_modrain.gif', '4' => '4cloud_modrain.gif'), '+Rain' => array ('0' => '0cloud.gif', '1' => '1cloud_heavyrain.gif', '2' => '2cloud_heavyrain.gif', '3' => '3cloud_heavyrain.gif', '4' => '4cloud_heavyrain.gif'), '-Snow' => array ('0' => '0cloud.gif', '1' => '2cloud_snow.gif', '2' => '2cloud_snow.gif', '3' => '3cloud_snow.gif', '4' => '4cloud_lightsnow.gif'), '+Snow' => array ('0' => '0cloud.gif', '1' => '2cloud_snow.gif', '2' => '2cloud_snow.gif', '3' => '3cloud_snow.gif', '4' => '4cloud_heavysnow.gif'), '-Hail' => array ('0' => '0cloud.gif', '1' => '2cloud_hail.gif', '2' => '2cloud_hail.gif', '3' => '3cloud_hail.gif', '4' => '4cloud_lighthail.gif'), '+Hail' => array ('0' => '0cloud.gif', '1' => '2cloud_hail.gif', '2' => '2cloud_hail.gif', '3' => '3cloud_hail.gif', '4' => '4cloud_heavyhail.gif'), 'Thun' => array ('0' => '0cloud.gif', '1' => '2cloud_thunders.gif', '2' => '2cloud_thunders.gif', '3' => '3cloud_thunders.gif', '4' => '4cloud_thunders.gif'), 'Fog' => array ('0' => '0cloud_fog.gif', '1' => '1cloud_fog.gif', '2' => '2cloud_fog.gif', '3' => '3cloud_fog.gif', '4' => '4cloud_fog.gif') ); // Define a lot of images for nigh time weather-group/cloud condition. // It has the same structure as the daylight array $images // It's a 2-dimensional array, indexed by the: // - Precipitation (first index) // - Cloud coverage (second index). $n_images = array ( 'None' => array ('0' => 'n_0cloud.gif', '1' => 'n_1cloud_norain.gif', '2' => 'n_2cloud_norain.gif', '3' => 'n_3cloud_norain.gif', '4' => '4cloud_norain.gif'), '-Rain' => array ('0' => 'n_0cloud.gif', '1' => 'n_1cloud_lightrain.gif', '2' => 'n_2cloud_lightrain.gif', '3' => 'n_3cloud_lightrain.gif', '4' => '4cloud_lightrain.gif'), 'Rain' => array ('0' => 'n_0cloud.gif', '1' => 'n_1cloud_modrain.gif', '2' => 'n_2cloud_modrain.gif', '3' => 'n_3cloud_modrain.gif', '4' => '4cloud_modrain.gif'), '+Rain' => array ('0' => 'n_0cloud.gif', '1' => 'n_1cloud_heavyrain.gif', '2' => 'n_2cloud_heavyrain.gif', '3' => 'n_3cloud_heavyrain.gif', '4' => '4cloud_heavyrain.gif'), '-Snow' => array ('0' => 'n_0cloud.gif', '1' => 'n_2cloud_snow.gif', '2' => 'n_2cloud_snow.gif', '3' => 'n_3cloud_snow.gif', '4' => '4cloud_lightsnow.gif'), '+Snow' => array ('0' => 'n_0cloud.gif', '1' => 'n_2cloud_snow.gif', '2' => 'n_2cloud_snow.gif', '3' => 'n_3cloud_snow.gif', '4' => '4cloud_heavysnow.gif'), '-Hail' => array ('0' => 'n_0cloud.gif', '1' => 'n_2cloud_hail.gif', '2' => 'n_2cloud_hail.gif', '3' => 'n_3cloud_hail.gif', '4' => '4cloud_lighthail.gif'), '+Hail' => array ('0' => 'n_0cloud.gif', '1' => 'n_2cloud_hail.gif', '2' => 'n_2cloud_hail.gif', '3' => 'n_3cloud_hail.gif', '4' => '4cloud_heavyhail.gif'), 'Thun' => array ('0' => 'n_0cloud.gif', '1' => 'n_2cloud_thunders.gif', '2' => 'n_2cloud_thunders.gif', '3' => 'n_3cloud_thunders.gif', '4' => '4cloud_thunders.gif'), 'Fog' => array ('0' => 'n_0cloud_fog.gif', '1' => 'n_1cloud_fog.gif', '2' => 'n_2cloud_fog.gif', '3' => 'n_3cloud_fog.gif', '4' => '4cloud_fog.gif') ); // Define image filenames for: // - 16 wind directions, // - 'no wind direction data' // - variable wind direction (VRB) // - calm wind (00000KT), or 'nodir' $wind_dir_images = array ( 0 => 'nnn.gif', 1 => 'nne.gif', 2 => 'ne.gif', 3 => 'nee.gif', 4 => 'eee.gif', 5 => 'see.gif', 6 => 'se.gif', 7 => 'sse.gif', 8 => 'sss.gif', 9 => 'ssw.gif', 10 => 'sw.gif', 11 => 'sww.gif', 12 => 'www.gif', 13 => 'nww.gif', 14 => 'nw.gif', 15 => 'nnw.gif', 16 => 'nnn.gif'); $wind_nodata_image = 'wind_nodata.gif'; $wind_vrb_image = 'vrb.gif'; $wind_nodir_image = 'nodir.gif'; // Define image filenames for: // - 'no data' condition, // - 'temperature zero or below zero degrees Celcius // - 'temperature above zero degrees Celcius $temp_nodata_image = 'temp_nodata.gif'; $temp_low_image = 'templow.gif'; $temp_high_image = 'temphigh.gif'; // ====================================================================== // The wind_speeds array can be used to convert wind speed values in [m/s] // to [Bft] (beaufort). $wind_speeds = array ( 'beaufort' => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), 'ms' => array (0.3, 1.6, 3.4, 5.5, 8.0, 10.8, 13.9, 17.2, 20.8, 24.5, 28.5, 32.7, 999)); // ------------------------------------------------------------------------ // The get_sky_image() function takes the processed metar data and // returns the sky image filename. The function combines the weather // group and cloud group to a specific image. Example html code: // // <img src="< ?php // get_image($processed_metar) // ? >" height="50" width="80" border="1"> function get_sky_image($processed_metar_data) { global $abs_image_path, $strings; global $itime; global $phenomena_array, $coverage, $images, $n_images; $metar = $processed_metar_data['metar']; $parts = explode(' ', $metar); $num_parts = count($parts); $night = 0; $maxcoverage = 0; for ($i = 0; $i < $num_parts; $i++) { $part = $parts[$i]; if (ereg('RMK|TEMPO|BECMG', $part)) { /* The rest of the METAR is either a remark or temporary information. We skip the rest of the METAR. */ break; } elseif (ereg('([0-9]{2})([0-9]{2})([0-9]{2})Z', $part, $regs)) { if (($regs[2] < 6) || ($regs[2] > 18)) { $night = 1; } } elseif (ereg('^(-|\+|VC)?(TS|SH|FZ|BL|DR|MI|BC|PR|RA|DZ|SN|SG|GR|GS|PE|IC|UP|BR|FG|FU|VA|DU|SA|HZ|PY|PO|SQ|FC|SS|DS)+$', $part)) { /* * Is this the current weather group? */ // Get the intensity and get rid of it in the $part string $intensity = ''; if (ereg('^(-|\+|VC)(..)*$',$part)) { if ($part[0] == '-') { $intensity = '-'; $part = substr($part,1); } elseif ($part[0] == '+') { $intensity = '+'; $part = substr($part,1); } elseif ($part[0] . $part[1] == 'VC') { $intensity = ''; $part = substr($part,2); } } // Now, take only the precipitation types that have icons. // Ignore the others In case more then one exist, take only the // first one (highest predominance). ereg('(TS|RA|DZ|SN|SG|GR|GS|PE|IC|BR|FG)(..)*$',$part,$match); if ($match[1] != '') { $phenomena = $match[1]; } else { ereg('(..)(TS|RA|DZ|SN|SG|GR|GS|PE|IC|BR|FG)(..)*$',$part,$match); if ($match[2] != '') { $phenomena = $match[2]; } } // Not each precipitation type has a single icon with it. // Combine similar precipitation types to a phenomena group. // I.e. drizzle (DZ) and rain (RA) are both considered to be // rain (as far as the icons are concerned). Add intensity only // in case of rain and snow. if (ereg('^(Snow|Hail)$',$phenomena_array[$phenomena])) { if ($intensity == '') { $intensity = '-'; } } if (ereg('^(Rain|Snow|Hail)$',$phenomena_array[$phenomena])) { $phenomena_group = $intensity . $phenomena_array[$phenomena]; } else { $phenomena_group = $phenomena_array[$phenomena]; } } // Now check the cloud coverage. There could be three cloud // layers, so check for all of them. Iconize the most covered // clouds, thus find the highest cloudcoverage layer, by // maximizing the $maxcoverage param elseif (ereg('(SKC|CLR)(...)', $part, $regs)) { $maxcoverage = max($maxcoverage,$coverage[$regs[1]]); // if ($maxcoverage < $coverage[$regs[1]]) { // $maxcoverage = $coverage[$regs[1]]; // } } elseif (ereg('^(VV|FEW|SCT|BKN|OVC)([0-9]{3})(CB|TCU)?$', $part, $regs)) { $maxcoverage = max($maxcoverage,$coverage[$regs[1]]); // if ($maxcoverage < $coverage[$regs[1]]) { // $maxcoverage = $coverage[$regs[1]]; // } } } // If looped through all groups and not found any weather group // (meaning no precipitation?), assume a '#' phenomena, resulting in // a 'None' phenomena group if ($phenomena == '') { $phenomena = '#'; $phenomena_group = $phenomena_array[$phenomena]; } // At this point, the $phenomena_group variable contains the one // index of the $images array, while the $maxcoverage variable // contains the other index of the $images array. The correct image // can be selected from the array. if (($night == 1) || ($itime == 'nite')) { echo $abs_image_path . $n_images[$phenomena_group][$maxcoverage]; } else { echo $abs_image_path . $images[$phenomena_group][$maxcoverage]; } } // ------------------------------------------------------------------------ // The get_winddir_image() function takes the processed metar data and // returns the appropriate wind direction image filename. There are 16 // wind direction icons defined to indicate the wind direction. Beside // the 16 directions, there are icons for variable wind direction, // calm wind and and an icon for the no data condition. Example html // code: // // <img src="< ?php // get_winddir_image($processed_metar) // ? >" height="40" width="40" border="1"> function get_winddir_image($processed_metar_data) { global $abs_image_path, $wind_nodir_image,$wind_dir_images,$wind_nodata_image, $wind_vrb_image,$strings; if (isset($processed_metar_data['wind_deg'])) { if ($processed_metar_data['wind_deg'] == $strings['wind_vrb_long']) { echo $abs_image_path . $wind_vrb_image; } elseif (($processed_metar_data['wind_deg'] == 0) && ($processed_metar_data['wind_knots'] == 0)) { echo $abs_image_path . $wind_nodir_image; } else { $array_index = round($processed_metar_data['wind_deg']/22.5); echo $abs_image_path . $wind_dir_images[$array_index]; } } else { echo $abs_image_path . $wind_nodata_image; } } // ------------------------------------------------------------------------ // The get_temp_image() function takes the processed metar data and // returns the appropriate temperature image filename. It uses the // 'temp_c' value to decide weather a freezing thermometer icon or a // non-freezing thermometer icon. When the 'temp_c' data is not // available, a 'no data' icon filename is returned. Example html // code: // // <img src="< ?php // get_temp_image($processed_metar) // ? >" height="50" width="20" border="1"> function get_temp_image($processed_metar_data) { global $abs_image_path, $temp_high_image,$temp_low_image,$temp_nodata_image; if (isset($processed_metar_data['temp_c'])) { if ($processed_metar_data['temp_c'] > 0) { echo $abs_image_path . $temp_high_image; } else { echo $abs_image_path . $temp_low_image; } } else { echo $abs_image_path . $temp_nodata_image; } } // ------------------------------------------------------------------------ // The get_beaufort() function takes the 'wind_meters_per_second' // value from the $decoded_metar array and converts it to beaufort // values. This is done by iterating through a table with windspeeds // in [m/s] and [bft] values. function get_beaufort() { global $wind_speeds, $decoded_metar; $ms = $decoded_metar['wind_meters_per_second']; if ($ms != '') { $cnt = 0; while (($ms > $wind_speeds['ms'][$cnt]) && ($cnt <= 12)) { $cnt++; } return $cnt; } else { return 0; } } // ------------------------------------------------------------------------ // The set_time() function is purely added for overruling the metar // time to night time. It is only intended to support displaying all // weathergroup icons in the table.php script during daytime. function set_time($ntime) { global $itime; $itime = $ntime; } // ------------------------------------------------------------------------ ?> --- NEW FILE --- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Listing of the processed METAR</title> </head> <body> <p>You can use this simple script to test PHP Weather. After you have typed in an ICAO, the script will show you the result of the parsing.</p> <form action="list.php"> <p>Select ICAO: <input type="text" name="icao"> <input type="submit"></p> </form> <?php include('./locale_en.inc'); include('./images.inc'); include('./phpweather.inc'); if (empty($icao)) { $metar = get_metar('EHEH'); } else { $metar = get_metar($icao); } $decoded_metar = process_metar($metar); echo "<pre>\n"; while (list($key, $value) = each($decoded_metar)) { echo "[$key] => $value\n"; } ?> </body> </html> --- NEW FILE --- <html> <head> <title>PHP Weather</title> </head> <body> <?php include('./locale_en.inc'); include('./images.inc'); include('./phpweather.inc'); $metar = get_metar('EHEH'); ?> <h1>Iconize PHPWeather info</h1> <h2>Introduction</h2> <p>Over the globe, a lot of weatherstations report the local weatherconditions to the <a href="http://weather.noaa.gov/weather/metar.shtml">NOAA organisation</a>, most of the times on an hourly basis. The weatherconditions are reported in the METAR format. The METAR data is available through the internet. For example the METAR data for Eindhoven Airport, Netherlands is:</p> <blockquote><code><? echo $metar ?></code></blockquote> <p>Martin Geisler (<a href="http://www.gimpster.com">www.gimpster.com</a>) has developed a PHP-script that retrieves and parses METAR data into readable text. You can get the PHPWeather script from <a href="http://sourceforge.net/projects/phpweather/">PHP Weather</a>. By this script, the METAR data of above is converted into:</p> <blockquote><? pretty_print_metar($metar, 'Eindhoven'); ?></blockquote> <p>I thought it would be neat to represent the METAR data in a graphical way as well. This is not new. Various portals and newspaper sites have this kind of representation also. But there is no way to personalize that representation: the information is statically built into their web-pages.<br> What I had in mind was a form that gives freedom in the choice of the icons and what kind of information that is presented: wind, temperature, sky cover and precipitation. Of course the freedom of choice ends with the one that builds the webpage: the PHP script is executed on the server which contains the webpage. There is no way that a user of the page can personalize representation (at least that is what I have in mind).</p> <p>So here it is. The current weather conditions in icons (so far):</p> <blockquote> <? $decoded_metar=process_metar($metar); ?> <img src="<? get_temp_image($decoded_metar) ?>" height="50" width="20" border="1"> <img src="<? get_winddir_image($decoded_metar) ?>" height="40" width="40" border="1"> <img src="<? get_sky_image($decoded_metar) ?>" height="50" width="80" border="1"> </blockquote> <h2>At first...</h2> <p>I searched for a set of icons on the internet. There are dozens of them. But only few are closely related to METAR data. I have downloaded the set of icons that I thought came very close to the METAR data. Then I have adjusted, changed and updated them to what I think that they should be and to the PHP script that I had in mind.</p> <p>First, I started with the sky cover and precipitation group within the METAR data. The set of icons I have downloaded already distinguises between day and night time, so I decided to take that into account too. METAR data has a group that describes the sky covering in five steps. Alltough sky covering can be described with a maximum of 3 layers, the script uses the layer that has the heaviest sky cover. The reason for this is because that probably describes the weather condition best (from the point of view of someone who looks up to the sky).</p> <p>Then there is a group that describes the 'Present Weather Group'. To me, this is the precipitation and related phenomenas, at least most of the time. To reduce the set of required icons I grouped similar precipitation phenomenas. I limited the script to rain (RA/DZ), snow (SN/SG), hail (GR/GS/PE/IC), thunderstorm (TS) and fog (BR/FG). Those are the most common weather types in the Netherlands. The script can be changed to contain more types (you'll need more icons though!)</p> <p>The script takes both the sky cover figure and the precipitation phenomenas as table entries at searches for the proper image file name. Finally, the time of the metar data is taken into account: during day time (from 6:00 AM to 6:00 PM) a sun with some clouds is displayed. At night time (from 6:00 PM to 6:00 AM) a moon with some clouds is displayed. Of course, when overcast is present, no sun or moon is presented.</p> <p>Refer to the next sections that present two tables with various icons that are resolved when METAR data is processed. One table provides the day time images, while the other provides the night time images. <a href="http://www.devolder.nl/table.txt">Click here</a> to view the code of the 'images.inc' file and <a href="http://www.devolder.nl/images.txt">click here</a> to view the code of this page.</p> <h2>Things to improve</h2> <ul> <li> </li> </ul> <h2>Day time sky cover/precipitation icons</h2> <p>The script creates one icon for a sky over and precipitation combination. Basically, the METAR data distinguishes 5 different sky covering types, which are listed horizontally in the table below. There are a lot of precipitation and related types, but in this script the number is limited to the most common types (at least in the Netherlands ;-): rain, snow, hail, thunderstorm and fog.</p> <p>Remarks:</p> <ul> <li>For rain, three different intensities are distinguished: light, moderate and heavy.</li> <li>For snow and hail, it is assumed that light/moderate and heavy intensities only need to be distinguished when there is overcast (100% sky cover).</li> <li>In case of fog/mist, I use the sky cover figure to increase the 'thickness' of the fog and to blend out sun light. I'm not sure that the skycover is being used as an indication of the 'fogginess'. Anyone?</li> </ul> </p> <? set_time('day'); ?> <table class="weather" border="1"> <tr> <th class="weather" colspan="2" width=200>Sky Cover/<br>Precipitation</th> <th class="weather" width=80>Clear<br>(CLR/SKC)</th> <th class="weather" width=80>Few<br>(FEW)</th> <th class="weather" width=80>Scattered<br>(SCT)</th> <th class="weather" width=80>Broken<br>(BKN)</th> <th class="weather" width=80>Overcast<br>(OVC/VV)</th> </tr> <tr> <th class="weather" colspan=2>None</th> <td><img src="<? $test['metar'] = 'CLR'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'FEW000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'SCT000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'BKN000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'OVC000'; get_sky_image($test) ?>" height="50" width="80"></td> </tr> <tr> <th class="weather" rowspan=3>Drizzle/Rain<br>(DZ/RA)</th> <td>light</td> <td rowspan=3><img src="<? $test['metar'] = 'CLR'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = '-RA FEW000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = '-RA SCT000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = '-RA BKN000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = '-RA OVC000'; get_sky_image($test) ?>" height="50" width="80"></td> </tr> <tr> <td>moderate</td> <td><img src="<? $test['metar'] = 'RA FEW000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'RA SCT000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'RA BKN000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'RA OVC000'; get_sky_image($test) ?>" height="50" width="80"></td> </tr> <tr> <td>heavy</td> <td><img src="<? $test['metar'] = '+RA FEW000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = '+RA SCT000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = '+RA BKN000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = '+RA OVC000'; get_sky_image($test) ?>" height="50" width="80"></td> </tr> <tr> <th class="weather" rowspan=2>Snow/Snow Grains<br>(SN/SG)</th> <td>light/<br>moderate</td> <td rowspan=2><img src="<? $test['metar'] = 'CLR'; get_sky_image($test) ?>" height="50" width="80"></td> <td rowspan=2><img src="<? $test['metar'] = 'SN FEW000'; get_sky_image($test) ?>" height="50" width="80"></td> <td rowspan=2><img src="<? $test['metar'] = 'SN SCT000'; get_sky_image($test) ?>" height="50" width="80"></td> <td rowspan=2><img src="<? $test['metar'] = 'SN BKN000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'SN OVC000'; get_sky_image($test) ?>" height="50" width="80"></td> </tr> <tr> <td>heavy</td> <td><img src="<? $test['metar'] = '+SN OVC000'; get_sky_image($test) ?>" height="50" width="80"></td> </tr> <tr> <th class="weather" rowspan=2>Ice Crystals/Ice Pellets/<br>Hail/Small Hail<br>(IC/PE/GR/GS)</th> <td>light/<br>moderate</td> <td rowspan=2><img src="<? $test['metar'] = 'CLR'; get_sky_image($test) ?>" height="50" width="80"></td> <td rowspan=2><img src="<? $test['metar'] = 'IC FEW000'; get_sky_image($test) ?>" height="50" width="80"></td> <td rowspan=2><img src="<? $test['metar'] = 'IC SCT000'; get_sky_image($test) ?>" height="50" width="80"></td> <td rowspan=2><img src="<? $test['metar'] = 'IC BKN000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'IC OVC000'; get_sky_image($test) ?>" height="50" width="80"></td> </tr> <tr> <td>heavy</td> <td><img src="<? $test['metar'] = '+IC OVC000'; get_sky_image($test) ?>" height="50" width="80"></td> </tr> <tr> <th class="weather" colspan=2>Thunderstorm<br>(TS)</th> <td><img src="<? $test['metar'] = 'CLR'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'TS FEW000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'TS SCT000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'TS BKN000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'TS OVC000'; get_sky_image($test) ?>" height="50" width="80"></td> </tr> <tr> <th class="weather" colspan=2>Mist/Fog<br>(BR/FG)</th> <td><img src="<? $test['metar'] = 'FG CLR000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'FG FEW000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'FG SCT000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'FG BKN000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'FG OVC000'; get_sky_image($test) ?>" height="50" width="80"></td> </tr> </table> <p>Note: with the sky cover/precipitation icons, there is no such thing as 'no data'. When both groups are omitted, this could mean sunny and no precipitation, and 'no data' as well. Since the metar exists, I decided to show the 'sunny' icon.</p> <h2>Night time sky cover/precipitation icons</h2> <p>To the night time sky cover/precipitation icons the same remarks as to the day tim icons apply.</p> <? set_time('nite'); ?> <table border="1" class="weather"> <tr> <th class="weather" colspan=2 width=200>Sky Cover/<br>Precipitation</th> <th width=80>Clear<br>(CLR/SKC)</th> <th width=80>Few<br>(FEW)</th> <th width=80>Scattered<br>(SCT)</th> <th width=80>Broken<br>(BKN)</th> <th width=80>Overcast<br>(OVC/VV)</th> </tr> <tr> <th class="weather" colspan=2>None</th> <td><img src="<? $test['metar'] = 'CLR'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'FEW000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'SCT000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'BKN000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'OVC000'; get_sky_image($test) ?>" height="50" width="80"></td> </tr> <tr> <th class="weather" rowspan=3>Drizzle/Rain<br>(DZ/RA)</th> <td>light</td> <td rowspan=3><img src="<? $test['metar'] = 'CLR'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = '-RA FEW000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = '-RA SCT000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = '-RA BKN000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = '-RA OVC000'; get_sky_image($test) ?>" height="50" width="80"></td> </tr> <tr> <td>moderate</td> <td><img src="<? $test['metar'] = 'RA FEW000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'RA SCT000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'RA BKN000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'RA OVC000'; get_sky_image($test) ?>" height="50" width="80"></td> </tr> <tr> <td>heavy</td> <td><img src="<? $test['metar'] = '+RA FEW000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = '+RA SCT000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = '+RA BKN000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = '+RA OVC000'; get_sky_image($test) ?>" height="50" width="80"></td> </tr> <tr> <th class="weather" rowspan=2>Snow/Snow Grains<br>(SN/SG)</th> <td>light/<br>moderate</td> <td rowspan=2><img src="<? $test['metar'] = 'CLR'; get_sky_image($test) ?>" height="50" width="80"></td> <td rowspan=2><img src="<? $test['metar'] = 'SN FEW000'; get_sky_image($test) ?>" height="50" width="80"></td> <td rowspan=2><img src="<? $test['metar'] = 'SN SCT000'; get_sky_image($test) ?>" height="50" width="80"></td> <td rowspan=2><img src="<? $test['metar'] = 'SN BKN000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'SN OVC000'; get_sky_image($test) ?>" height="50" width="80"></td> </tr> <tr> <td>heavy</td> <td><img src="<? $test['metar'] = '+SN OVC000'; get_sky_image($test) ?>" height="50" width="80"></td> </tr> <tr> <th class="weather" rowspan=2>Ice Crystals/Ice Pellets/<br>Hail/Small Hail<br>(IC/PE/GR/GS)</th> <td>light/<br>moderate</td> <td rowspan=2><img src="<? $test['metar'] = 'CLR'; get_sky_image($test) ?>" height="50" width="80"></td> <td rowspan=2><img src="<? $test['metar'] = 'IC FEW000'; get_sky_image($test) ?>" height="50" width="80"></td> <td rowspan=2><img src="<? $test['metar'] = 'IC SCT000'; get_sky_image($test) ?>" height="50" width="80"></td> <td rowspan=2><img src="<? $test['metar'] = 'IC BKN000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'IC OVC000'; get_sky_image($test) ?>" height="50" width="80"></td> </tr> <tr> <td>heavy</td> <td><img src="<? $test['metar'] = '+IC OVC000'; get_sky_image($test) ?>" height="50" width="80"></td> </tr> <tr> <th class="weather" colspan=2>Thunderstorm<br>(TS)</th> <td><img src="<? $test['metar'] = 'CLR'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'TS FEW000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'TS SCT000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'TS BKN000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'TS OVC000'; get_sky_image($test) ?>" height="50" width="80"></td> </tr> <tr> <th class="weather" colspan=2>Mist/Fog<br>(BR/FG)</th> <td><img src="<? $test['metar'] = 'FG CLR000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'FG FEW000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'FG SCT000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'FG BKN000'; get_sky_image($test) ?>" height="50" width="80"></td> <td><img src="<? $test['metar'] = 'FG OVC000'; get_sky_image($test) ?>" height="50" width="80"></td> </tr> </table> <p>Note: with the sky cover/precipitation icons, there is no such thing as 'no data'. When both groups are omitted, this could mean 'moony' (as opposed to 'sunny' ;-) and no precipitation, and 'no data' as well. Since the metar exists, I decided to show the 'moony' icon.</p> <? set_time(''); ?> <h2>Wind direction</h2> <p>A dedicated group in the METAR data provides wind related information. Of this data, the wind direction can be visualized graphically (as an arrow indicating the wind direction). I designed 16 wind direction icons (north, north-north-east, north-east etc), a special icon for variable wind direction (speed 6 knots or less) and a calm wind icon. The variable wind direction with speeds greater than 6 knots is not covered by an icon. The icon should then show the 'directional variability', which is pretty complex.</p> <p>Each of the 16 wind direction is mapped onto a icon, e.g. angles from 348.75 degrees through 11.25 degrees are mapped to the 'North' icon. Angles from 11.25 through 33.75 degrees are mapped to 'North-east' etc. This leads to the following icons:</p> <table class="weather" border="1"> <tr> <th>N</th> <th>NNE</th> <th>NE</th> <th>NEE</th> <th>E</th> <th>SEE</th> <th>SE</th> <th>SSE</th> </tr> <tr> <td><img src="<? $test['wind_deg'] = 1.0; get_winddir_image($test) ?>" height="40" width="40"></td> <td><img src="<? $test['wind_deg'] = 22.5; get_winddir_image($test) ?>" height="40" width="40"></td> <td><img src="<? $test['wind_deg'] = 45.0; get_winddir_image($test) ?>" height="40" width="40"></td> <td><img src="<? $test['wind_deg'] = 67.5; get_winddir_image($test) ?>" height="40" width="40"></td> <td><img src="<? $test['wind_deg'] = 90.0; get_winddir_image($test) ?>" height="40" width="40"></td> <td><img src="<? $test['wind_deg'] = 112.5; get_winddir_image($test) ?>" height="40" width="40"></td> <td><img src="<? $test['wind_deg'] = 135.0; get_winddir_image($test) ?>" height="40" width="40"></td> <td><img src="<? $test['wind_deg'] = 157.5; get_winddir_image($test) ?>" height="40" width="40"></td> </tr> <tr> <th>S</th> <th>SSW</th> <th>SW</th> <th>SSW</th> <th>W</th> <th>NWW</th> <th>NW</th> <th>NNW</th> </tr> <tr> <td><img src="<? $test['wind_deg'] = 180.0; get_winddir_image($test) ?>" height="40" width="40"></td> <td><img src="<? $test['wind_deg'] = 202.5; get_winddir_image($test) ?>" height="40" width="40"></td> <td><img src="<? $test['wind_deg'] = 225.0; get_winddir_image($test) ?>" height="40" width="40"></td> <td><img src="<? $test['wind_deg'] = 247.5; get_winddir_image($test) ?>" height="40" width="40"></td> <td><img src="<? $test['wind_deg'] = 270.0; get_winddir_image($test) ?>" height="40" width="40"></td> <td><img src="<? $test['wind_deg'] = 292.5; get_winddir_image($test) ?>" height="40" width="40"></td> <td><img src="<? $test['wind_deg'] = 315.0; get_winddir_image($test) ?>" height="40" width="40"></td> <td><img src="<? $test['wind_deg'] = 337.5; get_winddir_image($test) ?>" height="40" width="40"></td> </tr> <tr> <th>VRB</th> <th>Calm<br>wind</th> <th>No<br>data</th> </tr> <tr> <td><img src="<? $test['wind_deg'] = $strings['wind_vrb_long']; get_winddir_image($test) ?>" height="40" width="40"></td> <td><img src="<? $test['wind_deg'] = '0.0'; $test['wind_knots'] = '0.0'; get_winddir_image($test) ?>" height="40" width="40"></td> <td><img src="<? get_winddir_image('') ?>" height="40" width="40"></td> </tr> </table> <h2>Temperature</h2> <p>Another group in the METAR data provides temperature data. Only the actual temperature is being used to show either a blue (below 0 degrees C) or a red (above 0 degrees C) thermometer is shown. I know it is possible to generate images during php script execution with the GD lib, but I think changes in thermometer would be very small and hard to see.</p> <table class="weather" border="1"> <tr> <th>Below<br>0<br>deg C</th> <th>Above<br>0<br>deg C</th> <th>No<br>data</th> </tr> <tr> <td><img src="<? $test['temp_c'] = -1; get_temp_image($test) ?>" height="50" width="20"></td> <td><img src="<? $test['temp_c'] = 1; get_temp_image($test) ?>" height="50" width="20"></td> <td><img src="<? get_temp_image('') ?>" height="50" width="20"></td> </tr> </table> <h2>Change history</h2> <ul> <li>17 feb: EHEH 180825Z 22008KT 2500 R22/2000N -RA BR FEW008 BKN010 04/03 Q1017 YLO YLO BECMG GRN<br> Specifies Light rain, and mist. The icon shown is sun/mist. There is only clouds and rain, and no sun. Maybe the fog phenomena should only be taken into account when CLR or FEW. All others (SCT/BKN/OVC) ignore fog? <blockquote>Changed the mist icons to show clouds as well.</blockquote> </li> <li>19 feb: EHEH 191145Z 29016G30KT 4000 -SHRA BKN020CB 05/04 Q1015 TEMPO 4000 -TSRAGS<br> Specifies light showering rain, but also light thunderstorm of rain and small hail. Results in no image at all. Apparently, the script cannnot resolve this.<br> <blockquote>The metar contains a forcast part (from 'TEMPO...' and further). The script did not detect that and ran into the -TSRAGS part. Now the script stops before RMK|TEMPO|BECMG. </blockquote> </li> <li>25 feb: .... BR OVC020....<br> Specifies mist with overcast. Leads to 'fully white' image. This should be changed to normal overcast image <blockquote>Changed the mist icons to show clouds as well.</blockquote> </li> </ul> </body> </html> |