Statistics - Lake Jackson Weather

Click Here For Lake Jackson Weather Website

View Source to straighten things out ;-)

(isset($SITE['uomTemp']) ? substr($SITE['uomTemp'], -1) : 'F'), 'rain' => (isset($SITE['uomRain']) ? substr($SITE['uomRain'], 1) : 'in'), 'wind' => (isset($SITE['uomWind']) ? substr($SITE['uomWind'], 1) : 'mph'), 'baro' => (isset($SITE['uomBaro']) ? substr($SITE['uomBaro'], 1) : 'inHg') ); // language ........ $default_lang = 'en'; // 'look-up' array to use if not passed or defined elsewhere // get language files - nothing for you here !! (@include_once 'betel_dayfile_languages.php') OR die('FATAL ERROR - Language File FAIL !!'); // look for a 'posted' lang - change $_REQUEST['???'] name if DIY necessary if (isset($_REQUEST["lang"]) && $_REQUEST["lang"] != '') { // change from $default_lang if(array_key_exists($_REQUEST["lang"], $translit)) $dayfileLang = $_REQUEST["lang"]; // weatherbyyou check } elseif (isset($_REQUEST["langue"]) && $_REQUEST["langue"] != '') { // change from $default_lang if(array_key_exists($_REQUEST["langue"], $translit)) $dayfileLang = $_REQUEST["langue"]; // saratogaWX $SITE default lang } else { // nothing found so far if(isset($SITE["lang"])) { // Override $default_lang to $SITE default language if(array_key_exists($SITE["lang"], $translit)) $dayfileLang = $SITE["lang"]; } } if(!isset($dayfileLang)) $dayfileLang = $default_lang; // OK - continue ;-) // which default 'table' do we want ? if (!isset($_REQUEST["pane"])) { $pane = 0; // 0 default - show 'daily', 1 - show 'seasonal' } else { $pane = $_REQUEST["pane"]; } /* $label_items FORMAT array(*var name of data*, menu button text, table heading, true OR false = show menu button - DO NOT COMMENT OUT LINE !! NB: IF YOU DON'T HAVE or EVER HAD eg. a solar kit - SET TO false ! field# in data file (available from http://wiki.sandaysoft.com/a/Dayfile.txt), 'type' OR null = for units picker 'a' AND/OR 's' AND/OR 'h' AND/OR 'l' OR null - display (a)verage and / or (s)um, (h)i, (l)o for month(s) ) *var name of data* - anything new MUST have any parsing / display code added !! NOTE: Menu buttons will be displayed in the same order as the array ;-) so adjust order to suit your options. If you add any new items don't forget the trailing ',' on all but the last array line ! */ $label_items = array( 'maxtemp' => array($translit[$dayfileLang]['maxtemp'][0], $translit[$dayfileLang]['maxtemp'][1], true, 6, 'temp', 'ahl'), 'mintemp' => array($translit[$dayfileLang]['mintemp'][0], $translit[$dayfileLang]['mintemp'][1], true, 4, 'temp', 'ahl'), 'tdiff' => array($translit[$dayfileLang]['tdiff'][0], $translit[$dayfileLang]['tdiff'][1], true, array(6, 4), 'temp', 'ahl'), // NB: Example of more than one data value grab 'avgtemp' => array($translit[$dayfileLang]['avgtemp'][0], $translit[$dayfileLang]['avgtemp'][1], true, 15, 'temp', 'ahl'), 'tappmax' => array($translit[$dayfileLang]['tappmax'][0], $translit[$dayfileLang]['tappmax'][1], true, 27, 'temp', 'ahl'), 'tappmin' => array($translit[$dayfileLang]['tappmin'][0], $translit[$dayfileLang]['tappmin'][1], true, 29, 'temp', 'ahl'), 'dpmax' => array($translit[$dayfileLang]['dpmax'][0], $translit[$dayfileLang]['dpmax'][1], true, 35, 'temp', 'ahl'), 'dpmin' => array($translit[$dayfileLang]['dpmin'][0], $translit[$dayfileLang]['dpmin'][1], true, 37, 'temp', 'ahl'), 'rhmax' => array($translit[$dayfileLang]['rhmax'][0], $translit[$dayfileLang]['rhmax'][1], true, 21, null, 'ahl'), 'rhmin' => array($translit[$dayfileLang]['rhmin'][0], $translit[$dayfileLang]['rhmin'][1], true, 19, null, 'ahl'), 'rainfall' => array($translit[$dayfileLang]['rainfall'][0], $translit[$dayfileLang]['rainfall'][1], true, 14, 'rain', 'sah'), 'windspd' => array($translit[$dayfileLang]['windspd'][0], $translit[$dayfileLang]['windspd'][1], true, 17, 'wind', 'ah'), 'windgust' => array($translit[$dayfileLang]['windgust'][0], $translit[$dayfileLang]['windgust'][1], true, 1, 'wind', 'ah'), 'windrun' => array($translit[$dayfileLang]['windrun'][0], $translit[$dayfileLang]['windrun'][1], true, 16, null, 'sah'), 'winddir' => array($translit[$dayfileLang]['winddir'][0], $translit[$dayfileLang]['winddir'][1], true, array(39, 17), null, 'a'), // NB: also looks for a windspeed to to be valid 'baromax' => array($translit[$dayfileLang]['baromax'][0], $translit[$dayfileLang]['baromax'][1], true, 10, 'baro', 'ahl'), 'baromin' => array($translit[$dayfileLang]['baromin'][0], $translit[$dayfileLang]['baromin'][1], true, 8, 'baro', 'ahl'), 'HoursSun' => array($translit[$dayfileLang]['HoursSun'][0], $translit[$dayfileLang]['HoursSun'][1], true, 24, null, 'sah'), 'Solar' => array($translit[$dayfileLang]['Solar'][0], $translit[$dayfileLang]['Solar'][1], true, 42, null, 'ah'), 'HighUV' => array($translit[$dayfileLang]['HighUV'][0], $translit[$dayfileLang]['HighUV'][1], true, 44, null, 'ah'), 'evt' => array($translit[$dayfileLang]['evt'][0], $translit[$dayfileLang]['evt'][1], true, 23, 'rain', 'sah'), 'heatday' => array($translit[$dayfileLang]['heatday'][0], $translit[$dayfileLang]['heatday'][1], true, 40, 'temp', 'sah'), 'coolday' => array($translit[$dayfileLang]['coolday'][0], $translit[$dayfileLang]['coolday'][1], true, 41, 'temp', 'sah') ); // Cumulus provides 0 or 0.0 for missing or invalid data - this can make a nonsense of minimum and average values. // The best thing to do is to edit your dayfile.txt and nullify (,,) any false data. // However; depending upon your location, some datasets can reasonably be expected to be > 0 (remember these are daily values) // These COULD include: // ... 'windspd', 'windgust', 'windrun', 'HoursSun', 'Solar', 'HighUV', 'evt' $SANITIZE = true; // true OR false - attempt to ignore zero in the following datasets: // $zero_as_null = array('windspd', 'windgust', 'windrun', 'HoursSun', 'Solar', 'HighUV'); // datasets to 'fix' - EDIT TO SUIT $zero_as_null = array('windspd', 'windgust', 'windrun'); // datasets to 'fix' - EDIT TO SUIT // *** END * END * END USER VARIABLES ********************************************************************************************************* // parse / display code for defined datasets function formatOP() { global $rainDayInfo, $gradFactor, $thisValue, $part2, $dataSet, $decimals, $native, $maxsunhours, $bg_daily, $sunAvailable, $run_sun, $translit, $dayfileLang, $delim; if ($thisValue <> '' || $thisValue == 0) { if ($dataSet == 'windgust') { $col = gustColour(DoWind($thisValue, 'mph')); // format to colour range uom $part2 .= ' style="background-color:#' . $col[0] . '; color:#' . $col[1] . ';"'; $native = $thisValue; $thisValue = delimIT(DoWind($thisValue, null)); // format to DISPLAY uom } if ($dataSet == 'windspd') { $col = windColour(DoWind($thisValue, 'mph')); // format to colour range uom $part2 .= ' style="background-color:#' . $col[0] . '; color:#' . $col[1] . ';"'; $native = $thisValue; $thisValue = delimIT(DoWind($thisValue, null)); // format to DISPLAY uom } if ($dataSet == 'maxtemp' || $dataSet == 'mintemp' || $dataSet == 'avgtemp' || $dataSet == 'tappmax' || $dataSet == 'tappmin' || $dataSet == 'dpmax' || $dataSet == 'dpmin') { $col = tempColour(DoTemp($thisValue, 'C')); // format to colour range uom $part2 .= ' style="background-color:#' . $col[0] . '; color:#' . $col[1] . ';"'; $native = $thisValue; $thisValue = delimIT(DoTemp($thisValue, null)); // format to DISPLAY uom } /* An example of a calculated value using more than one data field. $thisValue *should* be an ARRAY of the data requested - the array will only exist if ALL data is present. YOU need to remember in what order you asked for the data ! In the example below $thisValue[0] is max temp and $thisValue[1] is min temp. HOWEVER: when doing averages, hi, lo, etc. OR heat / cooling days it will be a single value !! NOTE: Although this is temp 'type', changing eg. one degree C > F is NOT the same as 1 deg C > F !!! so we need another bit of code that does NOT give 32 +/- offset */ if ($dataSet == 'tdiff' || $dataSet == 'heatday' || $dataSet == 'coolday') { if(is_array($thisValue)){ // we need to do some calculations with the multiple data $native = $thisValue[0] - $thisValue[1]; // used to populate arrays for hi / lo / average $col = tempColour(DoTempDiff($native, 'C')); // format to colour range uom $thisValue = delimIT(DoTempDiff($native, null)); // format to DISPLAY uom } else { // is a single value from hi / lo / avg $native = $thisValue; // used to populate array for seasonal average $col = tempColour(DoTempDiff($thisValue, 'C')); // format to colour range uom $thisValue = delimIT(DoTempDiff($thisValue, null)); // format to DISPLAY uom } $part2 .= ' style="background-color:#' . $col[0] . '; color:#' . $col[1] . '"'; } // END calculated example if(!$gradFactor) $gradFactor = 1; // currently being used by rainfall / evt / windrun if ($dataSet == 'rainfall' || $dataSet == 'evt') { $col = rainColour(DoRain($thisValue / $gradFactor, 'mm')); // format to colour range uom; $part2 .= ' style="background-color:#' . $col[0] . '; color:#' . $col[1] . '"'; $native = $thisValue; $thisValue = delimIT(DoRain($thisValue, null)); // format to DISPLAY uom } if ($dataSet == 'windrun') { $col = runColour(DoWind($thisValue / $gradFactor, 'mph')); // format to colour range uom; $part2 .= ' style="background-color:#' . $col[0] . '; color:#' . $col[1] . '"'; $native = $thisValue; $thisValue = delimIT(DoWind($thisValue, null)); // format to DISPLAY uom } if ($dataSet == 'winddir' && intval($thisValue) > 0) { $thisValue = getHeading(intval($thisValue)); } if ($dataSet == 'baromax' || $dataSet == 'baromin') { $col = baroColour(DoBaro($thisValue, 'hPa')); // format to colour range uom; $part2 .= ' style="background-color:#' . $col[0] . '; color:#' . $col[1] . '"'; $native = $thisValue; $thisValue = delimIT(DoBaro($thisValue, null)); // format to DISPLAY uom } if ($dataSet == 'rhmax' || $dataSet == 'rhmin') { $col = tempColour(((100 - $thisValue) / 2.5) -10); // a fiddle ;-) $part2 .= ' style="background-color:#' . $col[0] . '; color:#' . $col[1] . '"'; $native = $thisValue; // no Unit conversions to do - so 'format' directly $thisValue = number_format((float)$thisValue, 0, '.' , ''); } if ($dataSet == 'HighUV') { $col = uvColour($thisValue); $part2 .= ' style="background-color:#' . $col[0] . '; color:#' . $col[1] . '"'; $native = $thisValue; // no Unit conversions to do - so 'format' directly $thisValue = delimIT(number_format((float)$thisValue, 1, '.' , '')); } if ($dataSet == 'HoursSun'){ // based on code by Mark Crossley $sundecimals = 1; // special case - not handled elsewhere if($bg_daily === true) $maxsunhours = $sunAvailable; $actual_txt = delimIT(round($thisValue, $sundecimals)); if($run_sun) { $available_txt = (string)$sunAvailable; } else { $availble_txt = ''; // shouldn't be seen anyway ! } $available_txt = delimIT($available_txt); $part2 .= '>
' . '' . $actual_txt . '
View Source to straighten things out ;-)"; readfile($filenameReal); exit; } else { echo "

Tough ! - I changed the password !!!

"; } } // $disp DEcode look-up array // (t)emp, (r)ain, (w)ind, (b)aro $plank['t'] = array('0' => 'C', '1' => 'F'); $plank['r'] = array('0' => 'mm', '1' => 'in'); $plank['w'] = array('0' => 'mph', '1' => 'm/s', '2' => 'km/h', '3' => 'kts'); $plank['b'] = array('0' => 'hPa', '1' => 'mb', '2' => 'inHg'); // print_r($plank); /* TABLE DISPLAY Units Of Measure */ $displayUOM = array('temp' => null, 'rain' => null, 'wind' => null, 'baro' => null); // if (isset($_COOKIE["theseUOM"])) { $displayUOM = $_COOKIE["theseUOM"]; // is an array from users browser if allowed } if (!isset($_REQUEST["disp"])) { // 1st time in - populate display units array from cookies if available else defaults $disp = ""; if(!isset($displayUOM['temp'])) $displayUOM['temp'] = $uom['temp']; // no history - use default if(!isset($displayUOM['rain'])) $displayUOM['rain'] = $uom['rain']; // no history - use default if(!isset($displayUOM['wind'])) $displayUOM['wind'] = $uom['wind']; // no history - use default if(!isset($displayUOM['baro'])) $displayUOM['baro'] = $uom['baro']; // no history - use default } else { $disp = $_REQUEST["disp"]; } if (isset($_REQUEST["change"])) { // we already have display UOM set one way or another but user wants to change them $flag1 = substr($_REQUEST["change"], 0, 1); $flag2 = substr($_REQUEST["change"], 1, 1); if($flag1 == "t"){ $displayUOM['temp'] = $plank['t'][$flag2]; } if($flag1 == "r"){ $displayUOM['rain'] = $plank['r'][$flag2]; } if($flag1 == "w"){ $displayUOM['wind'] = $plank['w'][$flag2]; } if($flag1 == "b"){ $displayUOM['baro'] = $plank['b'][$flag2]; } } // display units array has been updated if (isset($_REQUEST["change"]) || !isset($_REQUEST["disp"])) { // rebuild $disp (to be carried around pages) $disp = ""; if($displayUOM['temp'] == "C") $disp .= "t0"; if($displayUOM['temp'] == "F") $disp .= "t1"; if($displayUOM['rain'] == "mm") $disp .= "r0"; if($displayUOM['rain'] == "in") $disp .= "r1"; if($displayUOM['wind'] == "mph") $disp .= "w0"; if($displayUOM['wind'] == "m/s") $disp .= "w1"; if($displayUOM['wind'] == "km/h") $disp .= "w2"; if($displayUOM['wind'] == "kts") $disp .= "w3"; if($displayUOM['baro'] == "hPa") $disp .= "b0"; if($displayUOM['baro'] == "mb") $disp .= "b1"; if($displayUOM['baro'] == "inHg") $disp .= "b2"; } // By now $disp MUST now exist AND be uptodate - However; $displayUOM might not be !! // DEcode $disp to ensure $displayUOM is uptodate $thislen = strlen($disp); for($x = 0; $x <= $thislen-2; $x+=2) { if(substr($disp, $x, 2) == "t0") $displayUOM['temp'] = "C"; if(substr($disp, $x, 2) == "t1") $displayUOM['temp'] = "F"; if(substr($disp, $x, 2) == "r0") $displayUOM['rain'] = "mm"; if(substr($disp, $x, 2) == "r1") $displayUOM['rain'] = "in"; if(substr($disp, $x, 2) == "w0") $displayUOM['wind'] = "mph"; if(substr($disp, $x, 2) == "w1") $displayUOM['wind'] = "m/s"; if(substr($disp, $x, 2) == "w2") $displayUOM['wind'] = "km/h"; if(substr($disp, $x, 2) == "w3") $displayUOM['wind'] = "kts"; if(substr($disp, $x, 2) == "b0") $displayUOM['baro'] = "hPa"; if(substr($disp, $x, 2) == "b1") $displayUOM['baro'] = "mb"; if(substr($disp, $x, 2) == "b2") $displayUOM['baro'] = "inHg"; } // speed conversions --- mph, kts, m/s, km/h $mph = array(1, 0.8689762, 0.44704, 1.60934); $kts = array(1.1507794, 1, 0.514444, 1.852); $ms = array(2.23694, 1.9438445, 1, 3.6); $kmh = array(0.621371, 0.5399568, 0.277778, 1); // temperature gradient colours $tempGrad = array_merge( gradient('3D0060','6100A7',100), // -50 > -40 gradient('6100A7','BA00FF',100), // -40 > -30 gradient('BA00FF','000096',100), // -30 > -20 gradient('000096','54509F',100), // -20 > -10 gradient('54509F','00FFD4',100), // -10 > 0 gradient('00FFD4','48FF00',100), // 0 > 10 gradient('48FF00','FFDD00',100), // 10 > 20 gradient('FFDD00','FF0000',100), // 20 > 30 gradient('FF0000','BC0000',100), // 30 > 40 gradient('BC0000','640000',100) // 40 > 50 ); // average wind speed colours $windGrad0to50 = gradient('FFFFFF','FF0000',50); // gust wind speed colours $gustGrad0to80 = gradient('FFFFFF','FF0000',80); // rainfall colours $rainGrad0to30 = gradient('E8E8FF','0000FF',30); // windrun colours $runGrad0to300 = gradient('FFFFFF','00C000',300); // barometer colours $baroGrad900to1100 = gradient('FFFFFF','449a36',70); // solar irradiance colours $sunGrad0to10 = gradient('FFFF00','FF0000',1500); // value suggested by Graham64 // UV-I colours (=<1.6 is lo, >= 10 is hi) - gradients suggested by nossis $uvGrad = array_merge( gradient('96CC00','FFFF00',14), // 1.6 - 3.0 gradient('FFFF00','FF9928',30), // 3.0 - 6.0 gradient('FF9928','FF0000',20), // 6.0 - 8.0 gradient('FF0000','BF00BF',30), // 8.0 - 11.0 gradient('BF00BF','7D76AD',50) // 11.0 - 16.0 ); // windrun 'lookup' units $wrun = array( 'mph' => "- miles", 'm/s' => "- km", 'km/h' => "- km", 'kts' => "- nm" ); // ##### betel NEW graph stuff ################################################################################################################### if(isset($_REQUEST['bgraph'])){ // TEST SITE ONLY - check for 'posted' value $maxsunhours = $_REQUEST['bgraph']; } /************ Function Definitions *************/ function DoTemp($value, $to){ // convert temperatures global $displayUOM, $uom, $decimals; $temp_dec = 1; $decimals = $temp_dec; if(!$to) $to = $displayUOM['temp']; if( $to== "F" && $uom['temp'] == "C"){ // C => F return number_format((1.8* $value) + 32, $temp_dec, '.' , ''); } elseif($to == "C" && $uom['temp'] == "F"){ // F => C return number_format(($value - 32) / 1.8, $temp_dec, '.' , ''); } else { // no change return number_format((float)$value, $temp_dec, '.' , ''); } } // END function DoTemp() function DoTempDiff($value, $to){ // convert temperatures relative global $displayUOM, $uom, $decimals; $temp_dec = 1; $decimals = $temp_dec; if(!$to) $to = $displayUOM['temp']; if( $to== "F" && $uom['temp'] == "C"){ // C => F return number_format((1.8* $value), $temp_dec, '.' , ''); } elseif($to == "C" && $uom['temp'] == "F"){ // F => C return number_format($value / 1.8, $temp_dec, '.' , ''); } else { // no change return number_format((float)$value, $temp_dec, '.' , ''); } } // END function DoTempDiff() function DoRain($value, $to){ // convert rain units global $displayUOM, $uom, $decimals; if($displayUOM['rain'] == 'mm'){ $rain_dec = 1; } else { $rain_dec = 2; } $decimals = $rain_dec; if(!$to) $to = $displayUOM['rain']; if($uom['rain'] == "in" && $to == "mm"){ // in => mm return number_format(($value * 25.4), $rain_dec, '.' , ''); } elseif($uom['rain'] == "mm" && $to == "in"){ // mm => in return number_format(($value / 25.4), $rain_dec, '.' , ''); } else { // no change return number_format((float)$value, $rain_dec, '.' , ''); } } // END function DoRain() function DoWind($value, $to) { // convert windspeeds global $displayUOM, $uom, $mph, $kts, $kmh, $ms, $dataSet, $decimals; $wind_dec = ($dataSet == 'windrun' ? 0: 1); $decimals = $wind_dec; if(!$to) $to = $displayUOM['wind']; if($to == "mph") { $ethel=0; } else { if($to == "kts") { $ethel=1; } else { if($to == "m/s") { $ethel= ($dataSet == 'windrun' ? 3 : 2); } else { if($to == "km/h") { $ethel=3; }}} } if($uom['wind'] == "mph") { $factor = $mph[$ethel]; } if($uom['wind'] == "kts") { $factor = $kts[$ethel]; } if($uom['wind'] == "m/s") { $factor = ($dataSet == 'windrun' ? $kmh[$ethel] : $ms[$ethel]); } if($uom['wind'] == "km/h") { $factor = $kmh[$ethel]; } if($factor != 1){ // conversion required return number_format($value * $factor, $wind_dec, '.' , ''); } else { return number_format((float)$value, $wind_dec, '.' , ''); } } // END function DoWind() function DoBaro($value, $to){ // convert pressure units global $displayUOM, $uom, $decimals; $baro_dec = ($displayUOM['baro'] == 'inHg' ? 2 : 1); $decimals = $baro_dec; if(!$to) $to = $displayUOM['baro']; if(($to == "hPa" || $to == "mb") && $uom['baro'] == "inHg"){ // inHg => hPa or mb return number_format($value * 33.86388158,$baro_dec, '.' , ''); } elseif($to == "inHg" && ($uom['baro'] == "hPa" || $uom['baro'] == "mb")){ // hPa or mb => inHg return number_format($value / 33.86388158,$baro_dec, '.' , ''); } else { // no change return number_format((float)$value, $baro_dec, '.' , ''); } } // END function DoBaro() // *** MAIN table creation function *** // function drawCalendar($tableYear) { global $rainDayInfo, $gradFactor, $dataSet, $tableYear, $label_items, $data, $year_list, $displayUOM, $disp, $wrun, $season_data, $translit, $dayfileLang, $decimals, $type_data, $type_year, $thisValue, $part2, $pane, $native, $show_year_averages, $SANITIZE, $zero_as_null, $north_hemisphere, $buttons, $this_file_name, $windrunUnit, $maxsunhours, $bg_daily, $sunAvailable, $run_sun, $bg_maxyear, $delim, $typeS_year; insane(); // user vars checks readDayfile($tableYear, $dataSet); what_delim(); $tablelayout = '
'; if($buttons){ // start buttons 'menu' $tablelayout .= '
    '; foreach($label_items as $k => $v) { if($v[2] == true){ $tablelayout .= '
  • '.$v[0].'
  • '; } } $tablelayout .= "
\n"; } // table 'title' $tablelayout .= '

'; // daily / seasonal selector $tablelayout .= ''; foreach($label_items as $k => $v) { if($k == $dataSet){ if($buttons) { $tablelayout .= $v[1]. ($v[4] ? ' ' .picker($v[4]) : '') . ($dataSet == 'windrun' ? ' ' .$wrun[$displayUOM['wind']] : ''); } else { $windrunUnit = $wrun[$displayUOM['wind']]; // must be a global in picker2 if($dataSet != 'windrun') { $tablelayout .= picker2(). ($v[4] ? ' ' .picker($v[4]) : ''); } else { $tablelayout .= picker2(); } } $dayfilecol = $v[3]; $calcAvg = (strpos($v[5], 'a') > -1 ? true : false); $calcSum = (strpos($v[5], 's') > -1 ? true : false); $calcHi = (strpos($v[5], 'h') > -1 ? true : false); $calcLo = (strpos($v[5], 'l') > -1 ? true : false); break; } } $tablelayout .= "

\n
\n
\n"; // END 'menu' and table 'title' $tablelayout .= "
\n"; // daily summaries table $tablelayout .= "
\n \n"; $tablelayout .= "\n"; $tablelayout .= ''; $monWindDir = array(); for ($m = 1; $m <= 12; $m++) { $tablelayout .= '\n"; $wetday = array(1 => null, 2 => null, 2 => null, 3 => null, 4 => null, 5 => null, 6 => null, 7 => null, 8 => null, 9 => null, 10 => null, 11 => null, 12 => null); $rd_season_data = array(); $monSum = array(); $bg_monSum = array(); for ($d = 1; $d <= 31; $d++) { $tablelayout .= ''; $part1 = ''; } // END months 1 > 12 $tablelayout .= $part1 .= ' ' .$d. '' . $part2; // stitch table together $tablelayout .= "\n"; } // END days upto 31 // total / avg / hi / lo outputs (on-demand) $line = false; $exception = false; if($calcSum){ if($dataSet == 'windrun') $decimals = 0; $tablelayout .= "\n"; for ($m = 1; $m < 13; $m++) { if(array_key_exists($m, $monSum)){ $short = (count($monSum[$m]) < cal_days_in_month(CAL_GREGORIAN, $m, $tableYear) ? "* " : ""); if($short) $exception = true; $thisValue = array_sum($monSum[$m]); $gradFactor = 30; $part2 = ''; if($dataSet != 'HoursSun') formatOP(); $thatValue = ""; if($dataSet == 'HoursSun' && $run_sun) { // new stuff if(array_key_exists($m, $bg_monSum)){ $bg_value = array_sum($bg_monSum[$m]); $thatValue = ' title="' .$thisValue. ' (' .$bg_value. ' ' .$translit[$dayfileLang]['sunAdvisory'][4]. ')"'; $sunAvailable = round($bg_value, 1); } $tablelayout .= ''; } else { // NOT HoursSun $tablelayout .= ''; } } else { $tablelayout .= ''; } } $tablelayout .= "\n"; $line = true; } // END calcSum if($calcAvg){ // windirection is an exception where we need to find 'dominant' value if($dataSet == 'windrun') $decimals = 0; $fixthis = ($line ? '' : ' topborder'); $tablelayout .= "\n"; for ($m = 1; $m <= 12; $m++) { $tablelayout .= ' $v){ if($v == $workMax){ // see if number of occurences = max $thisValue = ($k === 0 ? 44 : $k * 45); // sort of put back into a degree range break; // only looking for first (clockwise) event } } } else { // everything that really needs averages $thisValue = array_sum($monSum[$m]) / count($monSum[$m]); if($dataSet == 'HoursSun' && $run_sun) { // new $bg_value = array_sum($bg_monSum[$m]) / count($bg_monSum[$m]); $sunAvailable = round($bg_value, 1); } $gradFactor = 1; } if($thisValue <> '' || (float)$thisValue === 0){ formatOP(); $short = (count($monSum[$m]) < cal_days_in_month(CAL_GREGORIAN, $m, $tableYear) ? "* " : ""); if($short) $exception = true; $tablelayout .= " class=\"datacell" .$fixthis."\"".$part2.">".($dataSet != 'HoursSun' ? $short : '').$thisValue.""; }else { $tablelayout .= " class=\"datacell" .$fixthis."\"> "; } }else{ $tablelayout .= " class=\"datacell" .$fixthis."\"> "; } } $tablelayout .= "\n"; $line = true; } // END calcAvg if($calcHi){ $fixthis = ($line ? '' : ' topborder'); $tablelayout .= "\n"; for ($m = 1; $m <= 12; $m++) { $tablelayout .= ' '' || (float)$thisValue === 0){ formatOP(); $short = (count($monSum[$m]) < cal_days_in_month(CAL_GREGORIAN, $m, $tableYear) ? "* " : ""); if($short) $exception = true; $tablelayout .= " class=\"datacell" .$fixthis."\"".$part2.">".($dataSet != 'HoursSun' ? $short : '').$thisValue.""; }else { $tablelayout .= " class=\"datacell" .$fixthis."\"> "; } }else{ $tablelayout .= " class=\"datacell" .$fixthis."\"> "; } } $tablelayout .= "\n"; $line = true; } // END calcHi if($calcLo){ $fixthis = ($line ? '' : ' topborder'); $tablelayout .= "\n"; for ($m = 1; $m <= 12; $m++) { $tablelayout .= ' '' || (float)$thisValue === 0){ formatOP(); $short = (count($monSum[$m]) < cal_days_in_month(CAL_GREGORIAN, $m, $tableYear) ? "* " : ""); if($short) $exception = true; $tablelayout .= " class=\"datacell" .$fixthis."\"".$part2.">".($dataSet != 'HoursSun' ? $short : '').$thisValue.""; }else { $tablelayout .= " class=\"datacell" .$fixthis."\"> "; } }else{ $tablelayout .= " class=\"datacell" .$fixthis."\"> "; } } $tablelayout .= "\n"; $line = true; } // END calcLo if($dataSet == 'rainfall' && $rainDayInfo === true) { $fixthis = ($line ? '' : ' topborder'); $tablelayout .= ""; for ($m = 1; $m <= 12; $m++) { $tablelayout .= ""; } $tablelayout .="\n"; } $sanitized = ''; if($SANITIZE){ // we want to try to 'nullify' zero values in some datasets foreach($zero_as_null as $S){ if($S == $dataSet){ // is this one of them ? $sanitized = ' - '.$translit[$dayfileLang]['note'][2]; // prepare 'Note;' advisory break; } } } $advisory = ""; // new if($dataSet == "HoursSun") { $advisory = " " .$translit[$dayfileLang]['sunAdvisory'][0]. " = "; if($bg_daily) $advisory .= " " .$translit[$dayfileLang]['sunAdvisory'][1]; if($bg_maxyear) $advisory .= $maxsunhours. "h " .$translit[$dayfileLang]['sunAdvisory'][2]; if(!$bg_daily && !$bg_maxyear) $advisory .= $maxsunhours. "h " .$translit[$dayfileLang]['sunAdvisory'][3]; // 'daily' top note & key info $tablelayout .= "
" .$translit[$dayfileLang]['note'][0].": " . $advisory. "  " .$translit[$dayfileLang]['sunAdvisory'][8]. ": " .($bg_daily ? "max" : $maxsunhours). "" . (!$bg_daily ? "" .$translit[$dayfileLang]['sunAdvisory'][6]. "" : ''). ($run_sun ? "(" .$translit[$dayfileLang]['sunAdvisory'][4]. ")" : ''). "" .$translit[$dayfileLang]['sunAdvisory'][7]. " 0
\n"; } // 'Note:' line $tablelayout .= "\n\n"; $tablelayout .= "
'.$year_list.''; $monWindDir[$m] = array(0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0); // 'twitch fix' } $tablelayout .= "
'; $part2 = ''; for ($m = 1; $m <= 12; $m++) { if ($d <= cal_days_in_month(CAL_GREGORIAN, $m, $tableYear)) { $theDate = mktime(0,0,0,$m,$d,$tableYear); $theDay = $translit[$dayfileLang]['dy'][date('w', $theDate)]; $part1 .= ''; $part2 .=' ''){ // belts'n'braces if($dataSet == 'winddir'){ if($thisValue[0] >0 && $thisValue[1] >0 ) { $wval = round($thisValue[0] / 45); $monWindDir[$m][$wval]++; // creating a 'counter' whose 'key' is the direction (0 > 7) $thisValue = $thisValue[0]; } else { $thisValue = ''; } } if($thisValue <> '') { if($dataSet == "HoursSun" && $run_sun) $sunAvailable = maxsunhours($theDate); // new formatOP(); // $thisValue is a global so doesn't need to be 'passed' $part2 .= '>'; $part2 .= $thisValue; // may have been converted by formatOP() if($dataSet == 'rainfall' && $native > 0) $wetday[$m] += 1; $monSum[$m][] = $native; if($dataSet == "HoursSun" ) $bg_monSum[$m][] = $sunAvailable; // new if($dataSet == "HoursSun") $thisValue = true; // a fiddle because of the way it is formatted } } } } } if($thisValue == '') $part2 .= "\"> "; // *** attempted logic fix } else { // not a valid day of month $part2 .= ''; } // END valid days upto 31 $part2 .= '
".$translit[$dayfileLang]['total'].":' .$short.$thisValue. '' .$short.$thisValue. ' 
".($dataSet == 'winddir' ? $translit[$dayfileLang]['dom'] : $translit[$dayfileLang]['avg']).":
".$translit[$dayfileLang]['hi'].":
".$translit[$dayfileLang]['lo'].":
" .$wetday[$m].($wetday[$m] ? "d" : ""). "
".$translit[$dayfileLang]['note'][0].": ".($exception ? "*".$translit[$dayfileLang]['note'][1] : '').$sanitized. $advisory. "
\n"; // END daily summaries table // START year avg table $tablelayout .= " \n"; $tablelayout .= "\n"; // *** NEW for rain / evt / windrun totals // put correct 'title / symbol' at side of top row if($dataSet == 'winddir') { $tablelayout .= ''; } else { if($dataSet == 'rainfall' || $dataSet == 'evt' || $dataSet == 'windrun') { $tablelayout .= ''; } else { $tablelayout .= ''; } } $gradFactor = 30; // $tablelayout .= ''; $tablelayout .= "\n"; $bert = count($type_year) -1; $alltime = array(1 => array(), 2 => array(), 3 => array(), 4 => array(), 5 => array(), 6 => array(), 7 => array(), 8 => array(), 9 => array(), 10 => array(), 11 => array(), 12 => array()); $rtime = array(1 => array(), 2 => array(), 3 => array(), 4 => array(), 5 => array(), 6 => array(), 7 => array(), 8 => array(), 9 => array(), 10 => array(), 11 => array(), 12 => array()); $bg_alltime = array(1 => array(), 2 => array(), 3 => array(), 4 => array(), 5 => array(), 6 => array(), 7 => array(), 8 => array(), 9 => array(), 10 => array(), 11 => array(), 12 => array()); if($dataSet == 'winddir') { for($zz = 1; $zz <= 12; $zz++){ $alltime[$zz] = array( 0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0); } } $shortMon = array(); for ($d = $bert; $d >= 0; $d--) { // latest year first $shortMon[$d] = array(); $tablelayout .= ''; $tablelayout .= ''; $yeartot = 0; for ($m = 1; $m <= 12; $m++) { $shortMon[$d][$m] = false; $windd = array(0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0); // twitch fix $wetday = array(1 => 0, 2 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0, 9 => 0, 10 => 0, 11 => 0, 12 => 0); $tablelayout .= ' $v){ if($v <> ''){ // only take account of non null entries if($dataSet == 'winddir'){ if($v[0] >0 && $v[1] >0) $windd[round($v[0] / 45)]++ ; // increment wind dir count $v = ''; } if(is_array($v)){ // we are dealing with something that needs calculating $thisValue = $v; formatOP(); // only want to use 'native' result $thisValue = ''; // reset $part2 = ''; // reset $turd[] = $native; } else { // 'normal' single piece of data $turd[] = $v; // a 'normal' single data entry if($dataSet == 'rainfall' && $v > 0) $wetday[$m] += 1; // bargraph stuff ############# if($dataSet == "HoursSun" && $run_sun) { $bg_y = $type_year[$d]; $bg_when = mktime(0,0,0, $m, $k, $bg_y); $bg_turd[] = maxsunhours($bg_when); } // ### end } } } if($turd){ if($dataSet == 'winddir'){ $workMax = max($windd); // find highest occurrence $found = false; foreach($windd as $k => $v){ $alltime[$m][$k] += $v; if($found !== true && $v == $workMax){ // see if number of occurrences = max $thisValue = ($k == 0 ? 44 : $k * 45); // sort of put back into a degree range $found = true; // only looking for first (clockwise) event } } } else { // everything that really needs averages // *** NEW FOR RAIN / EVT / WINDRUN TOTALS ** // do correct daily total OR avg calculation if($dataSet == 'rainfall' || $dataSet == 'evt' || $dataSet == 'windrun') { $thisValue = array_sum($turd); // new experiment $yeartot += array_sum($turd); } else { $thisValue = array_sum($turd) / count($turd); } // // bar graph stuff #################################### $thatvalue = ""; if($dataSet == 'HoursSun' && $run_sun){ $bg_value = round(array_sum($bg_turd) / count($bg_turd), 1); $sunAvailable = $bg_value; } // end } } if($thisValue || $thisValue == 0){ if($dataSet != 'winddir') $alltime[$m][] = $thisValue; if($dataSet == 'rainfall' && $rainDayInfo) { $rtime[$m][] = $wetday[$m]; if($m <3){ $rdy = $type_year[$d] - 1; } else { $rdy = $type_year[$d]; } $rd_season_data[$rdy][$m] = $wetday[$m]; } if($dataSet == 'HoursSun' && $run_sun) $bg_alltime[$m][] = $bg_value; // ### NEW bargraph stuff $gradFactor = 30; formatOP(); $short = (count($turd) < cal_days_in_month(CAL_GREGORIAN, $m, $type_year[$d]) ? "* " : ""); if(count($turd) < cal_days_in_month(CAL_GREGORIAN, $m, $type_year[$d])) $shortMon[$d][$m] = true ; $tablelayout .= " class=\"datacell2\"".$part2.">".($dataSet != 'HoursSun' ? $short : '').$thisValue.""; }else { $tablelayout .= ' class="nondate"> '; } }else{ $tablelayout .= ' class="nondate"> '; } } // END month walk $tablelayout .= "\n"; // echo "\n"; } // END year walk // now do overall month averages $tablelayout .= ''; if($dataSet == 'rainfall' && $rainDayInfo) { $extra = ""; } $tablelayout .= ''; for ($m = 1; $m <= 12; $m++) { $tablelayout .= ' $v){ if($v == $workMax){ // see if number of occurences = max $thisValue = ($k == 0 ? 44 : $k * 45); // sort of put back into a degree range break; // only looking for first (clockwise) event } } } else { if(is_array($alltime[$m])) { if(count($alltime[$m]) != 0) $thisValue = array_sum($alltime[$m]) / count($alltime[$m]); } } if($thisValue){ if($dataSet == 'rainfall' && $rainDayInfo){ // how can I deal with genuine nowt ? // echo "\n\n"; if(is_array($rtime[$m])) { $extra .= ""; } else { $extra .= ""; } } if($dataSet == 'HoursSun' && $run_sun){ if(is_array($bg_alltime[$m])) { if(count($bg_alltime[$m]) != 0) $bg_value = round(array_sum($bg_alltime[$m]) / count($bg_alltime[$m]), 1); $sunAvailable = $bg_value; } } $gradFactor = 30; formatOP(); $short = ""; for ($d = $bert; $d >= 0; $d--) { // latest year first (not important) if($shortMon[$d][$m]){ $short = "* "; break; } } $tablelayout .= " class=\"datacell2 topborder\"".$part2.">".($dataSet != 'HoursSun' ? $short : '').$thisValue.""; }else { $tablelayout .= ' class="nondate topborder"> '; } }else{ $tablelayout .= ' class="nondate topborder"> '; } } // END month walk $tablelayout .= "\n"; if($dataSet == 'rainfall') $tablelayout .= $extra. "\n"; // END overall year averages $tablelayout .= "
'.$translit[$dayfileLang]['dom'].''.$translit[$dayfileLang]['total'].''.$translit[$dayfileLang]['avg'].''.$translit[$dayfileLang]['mn'][0].''.$translit[$dayfileLang]['mn'][1].''.$translit[$dayfileLang]['mn'][2].''.$translit[$dayfileLang]['mn'][3].''.$translit[$dayfileLang]['mn'][4].''.$translit[$dayfileLang]['mn'][5].''.$translit[$dayfileLang]['mn'][6].''.$translit[$dayfileLang]['mn'][7].''.$translit[$dayfileLang]['mn'][8].''.$translit[$dayfileLang]['mn'][9].''.$translit[$dayfileLang]['mn'][10].''.$translit[$dayfileLang]['mn'][11].'
'.$type_year[$d].'
ϴ'.($dataSet == 'winddir' ? $translit[$dayfileLang]['dom'] : $translit[$dayfileLang]['avg']).'" .round((array_sum($rtime[$m]) / count($rtime[$m])), 1). "d 
\n
\n"; // END year averages table // print_r($rd_season_data); // SEASONAL summaries table $tablelayout .= "
\n"; // $m_offset = array(null, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); // simple offset 'look-up' $m_offset = array(null, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2); // simple offset 'look-up' $exception = false; $tablelayout .= " \n"; $tablelayout .=''; $tablelayout .=''; $tablelayout .=''; $tablelayout .=''; $tablelayout .=''; $tablelayout .=''; $tablelayout .=''; $tablelayout .=''; $tablelayout .=''; $tablelayout .=''; $tablelayout .=''; $tablelayout .=''; $tablelayout .=''; $tablelayout .=''; $tablelayout .= "\n"; $tablelayout .= ''; if($north_hemisphere) { // $tablelayout .= ''; $tablelayout .= ''; $tablelayout .= ''; // $tablelayout .= ''; $tablelayout .= ''; $tablelayout .= ''; } else { // $tablelayout .= ''; $tablelayout .= ''; $tablelayout .= ''; // $tablelayout .= ''; $tablelayout .= ''; $tablelayout .= ''; } $tablelayout .= "\n"; // months header row as a separate var so as it can be duplicated after predetermined # of entries $monthRow = "\n"; $monthRow .= ''; // $monthRow .= ''; $monthRow .= ''; $monthRow .= ''; $monthRow .= ''; $monthRow .= ''; $monthRow .= "\n"; $bert = count($typeS_year) -1; for ($d = $bert; $d >= 0; $d--) { // latest year first if($dataSet == 'rainfall' && $rainDayInfo) $rd_season_extra = ""; $seasonTot = array(0 => array(), 1 => array(), 2 => array(), 3 => array()); $bg_seasonTot = array(0 => array(), 1 => array(), 2 => array(), 3 => array()); $thehardway = 0; $shortSeason = array(); $sT = 0; $season = array(); $rd_season = array(); $bg_season = array(); if($dataSet == 'winddir') { for($zz = 0; $zz < 4; $zz++) { $season[$zz] = array(0 => null, 1 => null, 2 => null, 3 => null, 4 => null, 5 => null, 6 => null, 7 => null, 8 => null); } } $s = 0; $fixrow = ($d === 0 ? "" : " bottomborder"); $widget = ''.$typeS_year[$d].''; if($dataSet == 'rainfall' && $rainDayInfo) { // every 3 years show months row if($bert - $d === 0 || $bert - $d === 3 || $bert - $d === 6 || $bert - $d === 9 || $bert - $d === 12 || $bert - $d === 15) $tablelayout .= $monthRow; } else { // every 5 years show months row if($bert - $d === 0 || $bert - $d === 5 || $bert - $d === 10 || $bert - $d === 15) $tablelayout .= $monthRow; } // come on ... how long do you expect this prog or Cumulus to be used ???? // we will ALWAYS be at least outputting Avg //total value - month (optional) if($calcSum){ $gradFactor = 30; $tablelayout .= ''; $tablelayout .= ''; $widget = ''; for ($m = 1; $m <= 12; $m++) { if($m <4) $sT = 0; if($m >= 4 && $m < 7) $sT = 1; if($m >= 7 && $m < 10) $sT = 2; if($m >= 10) $sT = 3; $fixcol = ($m === 3 || $m === 6 || $m === 9 ? " rightborder" : ""); $tablelayout .= ' $v){ $native = ''; if($v <> ''){ // only take account of non null entries if(is_array($v)){ // we are dealing with something that needs calculating $thisValue = $v; formatOP(true); // only want to use 'native' result $thisValue = ''; // reset $part2 = ''; // reset $turd[] = $native; } else { // 'normal' single piece of data $turd[] = $v; // a 'normal' single data entry // bargraph stuff ############# if($dataSet == "HoursSun" && $run_sun) { $bg_y = $typeS_year[$d]; $bg_m = $m_offset[$m]; if($bg_m <3) $bg_y++; // I think I need to do that ?????????????? $bg_when = mktime(0,0,0, $bg_m, $k, $bg_y); $bg_turd[] = maxsunhours($bg_when); } // ### end } } } if($turd) $thisValue = array_sum($turd); if($dataSet == 'HoursSun' && $run_sun) $bg_value = array_sum($bg_turd); if($thisValue){ $seasonTot[$sT][$thehardway] = $thisValue; if($dataSet == 'HoursSun' && $run_sun) $bg_seasonTot[$sT][$thehardway] = $bg_value; $thehardway++; if($dataSet == 'HoursSun') { $msh = $maxsunhours; $sunAvailable = $bg_value; $maxsunhours = $maxsunhours * count($turd); } if($dataSet != 'HoursSun') formatOP(true); if($dataSet == 'HoursSun') $maxsunhours = $msh; $short = (count($turd) < cal_days_in_month(CAL_GREGORIAN, $m_offset[$m], $typeS_year[$d]) ? "* " : ""); // doesn't matter about 'previous' December - will always be 31 if(count($turd) < cal_days_in_month(CAL_GREGORIAN, $m_offset[$m], $typeS_year[$d])) { $shortSeason[$sT] = true; } // need this if we DON'T use formatOP $actual_txt = delimIT($thisValue); if($run_sun && $dataSet == "HoursSun") { $available_txt = delimIT($bg_value); } else { $availble_txt = ''; // shouldn't be seen anyway ! } if($dataSet != 'HoursSun') { $tablelayout .= " class=\"datacell ".$fixcol."\"".$part2.">".$short.$actual_txt.""; } else { $tablelayout .= " class=\"graphcell ".$fixcol."\"".$part2.">".$short.$actual_txt. ($dataSet == 'HoursSun' && $run_sun ? "
(" .$available_txt. ")" : "") .""; } } else { $tablelayout .= ' class="nondate'.$fixcol.'"> '; } } else { $tablelayout .= ' class="nondate'.$fixcol.'"> '; } } $tablelayout .= "
\n"; // total - season(s) $tablelayout .= ''; $tablelayout .= ''; for($x = 0; $x < 4; $x++){ // step through seasons $tablelayout .= '"; } else { $tablelayout .= " class=\"graphcell" . $fixcol."\">".$short. $avail_txt.$actual_txt . ""; } } else { $tablelayout .= ' class="nondate'.$fixcol.'"> '; } }else{ $tablelayout .= ' class="nondate'.$fixcol.'"> '; } } $tablelayout .= "\n"; } // END total(s) (option) //hi value - must have if($dataSet != 'winddir'){ $gradFactor = 1; $tablelayout .= ''; $tablelayout .= ''; $widget = ''; for ($m = 1; $m <= 12; $m++) { $fixcol = ($m === 3 || $m === 6 || $m === 9 ? " rightborder" : ""); $tablelayout .= ' $v){ $native = ''; if($v <> ''){ // only take account of non null entries if(is_array($v)){ // we are dealing with something that needs calculating $thisValue = $v; formatOP(); // only want to use 'native' result $thisValue = ''; // reset $part2 = ''; // reset $turd[] = $native; } else { // 'normal' single piece of data $turd[] = $v; // a 'normal' single data entry // bargraph stuff ############# if($dataSet == "HoursSun" && $run_sun) { $bg_y = $typeS_year[$d]; $bg_m = $m_offset[$m]; if($bg_m <3) $bg_y++; // I think I need to do that ??????????????????????????????????????????????? $bg_when = mktime(0,0,0, $bg_m, $k, $bg_y); $bg_turd[] = maxsunhours($bg_when); } // ### end } } } if($turd) $thisValue = max($turd); if($dataSet == 'HoursSun') $sunAvailable = max($bg_turd); if($thisValue){ formatOP(); if($dataSet == 'HoursSun') $maxsunhours = $msh; $short = (count($turd) < cal_days_in_month(CAL_GREGORIAN, $m_offset[$m], $typeS_year[$d]) ? "* " : ""); // doesn't matter about 'previous' December - will always be 31 $tablelayout .= " class=\"datacell".$fixcol."\"".$part2.">".($dataSet != 'HoursSun' ? $short : '').$thisValue.""; }else { $tablelayout .= ' class="nondate'.$fixcol.'"> '; } }else{ $tablelayout .= ' class="nondate'.$fixcol.'"> '; } } $tablelayout .= "\n"; } // END hi //lo value - must have if($dataSet != 'winddir' && $calcLo){ $gradFactor = 1; $tablelayout .= ''; $tablelayout .= ''; $widget = ''; for ($m = 1; $m <= 12; $m++) { $fixcol = ($m === 3 || $m === 6 || $m === 9 ? " rightborder" : ""); $tablelayout .= ' $v){ $native = ''; if($v <> ''){ // only take account of non null entries if(is_array($v)){ // we are dealing with something that needs calculating $thisValue = $v; formatOP(); // only want to use 'native' result $thisValue = ''; // reset $part2 = ''; // reset $turd[] = $native; } else { // 'normal' single piece of data $turd[] = $v; // a 'normal' single data entry } } } if($turd) $thisValue = min($turd); if($thisValue <> '' || $thisValue == 0){ formatOP(); $short = (count($turd) < cal_days_in_month(CAL_GREGORIAN, $m_offset[$m], $typeS_year[$d]) ? "* " : ""); // doesn't matter about 'previous' December - will always be 31 $tablelayout .= " class=\"datacell".$fixcol."\"".$part2.">".($dataSet != 'HoursSun' ? $short : '').$thisValue.""; }else { $tablelayout .= ' class="nondate'.$fixcol.'"> '; } }else{ $tablelayout .= ' class="nondate'.$fixcol.'"> '; } } $tablelayout .= "\n"; } // END lo // month avg value - must have $tablelayout .= ''; $tablelayout .= ''; $widget = ''; for ($m = 1; $m <= 12; $m++) { $windd = array( 0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0); if($m <4) $s = 0; if($m >= 4 && $m < 7) $s = 1; if($m >= 7 && $m < 10) $s = 2; if($m >= 10) $s = 3; $fixcol = ($m == 3 || $m == 6 || $m == 9 ? " rightborder" : ""); $tablelayout .= ' $v){ $native = ''; if($v <> ''){ // only take account of non null entries if(is_array($v)){ // we are dealing with something that needs calculating $thisValue = $v; formatOP(); // only want to use 'native' result $thisValue = ''; // reset $part2 = ''; // reset $turd[] = $native; if($dataSet != 'winddir') $season[$s][] = $native; } else { // 'normal' single piece of data $turd[] = $v; // a 'normal' single data entry $season[$s][] = $v; // bargraph stuff ############# if($dataSet == "HoursSun" && $run_sun) { $bg_y = $typeS_year[$d]; $bg_m = $m_offset[$m]; if($bg_m <3) $bg_y++; // I think I need to do that ?????????????????????????????????????????????????????????????????????????????????? $bg_when = mktime(0,0,0, $bg_m, $k, $bg_y); $bg_turd[] = $bg_season[$s][] = maxsunhours($bg_when); } // ### end } } if($dataSet == 'winddir' && isset($v[0]) && isset($v[1])){ if($v[0] >0 && $v[1] > 0) $windd[round($v[0] / 45)]++ ; // increment wind dir count } } if($turd){ if($dataSet == 'winddir'){ $workMax = max($windd); // find highest occurrence $season[$s] = array(0, 0, 0, 0, 0, 0, 0, 0, 0); $found = false; foreach($windd as $k => $v){ $season[$s][$k] += $v; if($found !== true && $v == $workMax){ // see if number of occurrences = max $thisValue = ($k == 0 ? 44 : $k * 45); // sort of put back into a degree range $found = true; // only looking for first (clockwise) event } } } else { // everything that really needs averages $thisValue = array_sum($turd) / count($turd); if($dataSet == 'HoursSun') $sunAvailable = round(array_sum($bg_turd) / count($bg_turd), 1); } } if($thisValue || $thisValue === 0){ $gradFactor = 1; formatOP(); if($dataSet == 'HoursSun') $maxsunhours = $msh; $short = (count($turd) < cal_days_in_month(CAL_GREGORIAN, $m_offset[$m], $typeS_year[$d]) ? "* " : ""); // doesn't matter about 'previous' December - will always be 31 if(count($turd) < cal_days_in_month(CAL_GREGORIAN, $m_offset[$m], $typeS_year[$d])) $shortSeason[$s] = true; $tablelayout .= " class=\"datacell".$fixcol."\"".$part2.">".($dataSet != 'HoursSun' ? $short : '').$thisValue.""; }else { $tablelayout .= ' class="nondate'.$fixcol.'"> '; } }else{ $tablelayout .= ' class="nondate'.$fixcol.'"> '; } if($dataSet == 'rainfall' && $rainDayInfo) { if(array_key_exists($m_offset[$m], $rd_season_data[$typeS_year[$d]])) { $rd_v = $rd_season_data[$typeS_year[$d]][$m_offset[$m]]; // ******************** } else { $rd_v = 0; } $rd_season[$s][] = $rd_v; $rd_season_extra .= ""; } } // end month walkthrough $tablelayout .= "\n"; if($dataSet == 'rainfall' && $rainDayInfo) { $rd_season_extra .= "\n"; } // END month avg // and finally (unless raindays is selected) ... season(s) avg value $tablelayout .= ''; if($dataSet == 'rainfall' && $rainDayInfo) $fixrow = false; $tablelayout .= ''; for($x = 0; $x < 4; $x++){ // step through seasons $tablelayout .= '"; } else { $tablelayout .= ' class="nondate'.$fixcol.$fixrow.'"> '; } }else{ $tablelayout .= ' class="nondate'.$fixcol.$fixrow.'"> '; } }else{ $tablelayout .= ' class="nondate'.$fixcol.$fixrow.'"> '; } } // END season walkthrough $tablelayout .= "\n"; if($dataSet == 'rainfall' && $rainDayInfo) { // raindays $tablelayout .= $rd_season_extra; $fixrow = true; $tablelayout .= ''; for($x = 0; $x < 4; $x++){ // step through seasons $tablelayout .= '"; } else { $tablelayout .= ' class="nondate'.$fixcol.$fixrow.'"> '; // $tablelayout .= ' class="nondate'.$fixcol.$fixrow.'"> '; } } // END season walkthrough $tablelayout .= "\n"; } // end raindays // ***************** } // END year walk-through // bargraph - 'note' bar $advisory = ""; if($dataSet == "HoursSun") { $advisory = " " .$translit[$dayfileLang]['sunAdvisory'][0]. " = "; if($bg_daily) $advisory .= " " .$translit[$dayfileLang]['sunAdvisory'][5]; if($bg_maxyear) $advisory .= $maxsunhours. "h " .$translit[$dayfileLang]['sunAdvisory'][2]; if(!$bg_daily && !$bg_maxyear) $advisory .= $maxsunhours. "h " .$translit[$dayfileLang]['sunAdvisory'][3]; $tablelayout .= "
" .$translit[$dayfileLang]['note'][0].": " . $advisory. "  " .$translit[$dayfileLang]['sunAdvisory'][8]. ": " .($bg_daily ? "max" : $maxsunhours). "" . (!$bg_daily ? "" .$translit[$dayfileLang]['sunAdvisory'][6]. "" : ''). ($run_sun ? "(" .$translit[$dayfileLang]['sunAdvisory'][4]. ")" : ''). "" .$translit[$dayfileLang]['sunAdvisory'][7]. " 0
\n"; } // 'Note:' line $tablelayout .= "\n\n"; $tablelayout .= "
 '.$translit[$dayfileLang]['season_1'].''.$translit[$dayfileLang]['season_2'].''.$translit[$dayfileLang]['season_3'].''.$translit[$dayfileLang]['season_4'].''.$translit[$dayfileLang]['season_4'].''.$translit[$dayfileLang]['season_1'].''.$translit[$dayfileLang]['season_3'].''.$translit[$dayfileLang]['season_4'].''.$translit[$dayfileLang]['season_1'].''.$translit[$dayfileLang]['season_2'].''.$translit[$dayfileLang]['season_2'].''.$translit[$dayfileLang]['season_3'].'
 '.$translit[$dayfileLang]['mn'][11].''.$translit[$dayfileLang]['mn'][0].''.$translit[$dayfileLang]['mn'][1].''.$translit[$dayfileLang]['mn'][2].''.$translit[$dayfileLang]['mn'][3].''.$translit[$dayfileLang]['mn'][4].''.$translit[$dayfileLang]['mn'][5].''.$translit[$dayfileLang]['mn'][6].''.$translit[$dayfileLang]['mn'][7].''.$translit[$dayfileLang]['mn'][8].''.$translit[$dayfileLang]['mn'][9].''.$translit[$dayfileLang]['mn'][10].''.$translit[$dayfileLang]['mn'][11].''.$translit[$dayfileLang]['mn'][0].''.$translit[$dayfileLang]['mn'][1].'
 
'.$widget.$translit[$dayfileLang]['total'].'
'.$widget.$translit[$dayfileLang]['total'].'".$short.$actual_txt."
'.$widget.$translit[$dayfileLang]['hi'].'
'.$widget.$translit[$dayfileLang]['lo'].'
'.$widget.$translit[$dayfileLang]['avg'].'".$rd_v."d
'.$translit[$dayfileLang]['avg'].' $v){ if($v == $workMax){ // see if number of occurences = max $thisValue = ($k == 0 ? 44 : $k * 45); // sort of put back into a degree range if($thisValue == 44) $thisValue = ''; // unhappy fiddle break; // only looking for first (clockwise) event } } } else { $thisValue = '*'; } } else { $thisValue = array_sum($season[$x]) / count($season[$x]); if($dataSet == 'HoursSun') $sunAvailable = round(array_sum($bg_season[$x]) / count($bg_season[$x]), 1); } if($thisValue != '*'){ if($thisValue || $thisValue === 0){ $gradFactor = 1; formatOP(); $short = ""; if(array_key_exists($x, $seasonTot) && array_key_exists($x, $shortSeason)){ $short = "* "; $exception = true; } $tablelayout .= " class=\"datacell center".$fixcol.$fixrow."\"".$part2.">".($dataSet != 'HoursSun' ? $short : '').$thisValue."
ϴ ".$thisValue."d
".$translit[$dayfileLang]['note'][0].": ".($exception ? "*".$translit[$dayfileLang]['note'][1] : '').$sanitized. $advisory. "
\n"; $tablelayout .= "\n
\n"; // END season table 'holder' $tablelayout .= "\n
\n"; // END tables 'holder $tablelayout .= "
\n"; // END 'gilliam' // output table(s) to page echo $tablelayout; //print_r($rd_season_data); // 'write' page JavaScript $script = ''; echo $script; } // END function drawCalendar() function readDayfile($tableYear, $dataSet) { // grab datafile and collect data 'type' global $dayfile, $tableYear, $year_list, $disp, $label_items, $season_data, $type_data, $type_year, $translit, $dayfileLang, $delim, $SANITIZE, $zero_as_null, $delim, $date_sunsensorOK, $date_sunsensorFAIL, $testOK, $testFAIL, $typeS_year; $current_year = ''; $season_year = ''; // shouldn't this be a GLOBAL array ? $new_year = ''; $year_list = ''; } // END function readDayfile() function getHeading($deg) { global $translit, $dayfileLang; return $translit[$dayfileLang]['compass_headings'][round($deg / 45)]; } // END function getHeading() function tempColour($temp) { // expects deg C global $tempGrad; $scaledVal = ($temp < -50 ? -50 : $temp); $scaledVal = ($temp > 50 ? 50 : $temp); $scaledVal = ($scaledVal *10) +500; if($scaledVal == 1000) $scaledVal = 999; $betel = $tempGrad[$scaledVal]; $text = ($temp >= 24 || $temp <= -4 ? 'FFF': '000'); $ret = array($betel, $text); return $ret; } // END function tempColour() function gustColour($val) { // expects mph global $gustGrad0to80; $val =(int)$val; if ($val > 79) $val = 79; $text = ($val >= 36 ? 'FFF' : '000'); return array($gustGrad0to80[$val], $text); } // END function gustColour() function windColour($val) { // expects mph global $windGrad0to50; $val =(int)$val; if ($val > 49) $val = 49; $text = ($val >= 20 ? 'FFF' : '000'); return array($windGrad0to50[$val], $text); } // END function windColour() function runColour($val) { // expects miles global $runGrad0to300; $val =(int)$val; if ($val > 299) $val = 299; $text = ($val >= 200 ? 'FFF' : '000'); return array($runGrad0to300[$val], $text); } // END function runColour() function rainColour($val) { // expects mm global $rainGrad0to30; if ($val > 29) $val = 29; $text= ($val >= 8 ? 'FFF' : '000'); $val = round($val); if($val > 0){ return array($rainGrad0to30[$val],$text); } else { return array('FFF', $text); } } // END function rainColour() function baroColour($val) { // expects hPa global $baroGrad900to1100; // really 980 > 1050 $scaledVal = round(($val - 980)); if ($scaledVal < 0) $scaledVal = 0; if ($scaledVal >= 69) $scaledVal = 69; $text = ($val >= 1030 ? 'FFF' : '000'); return array($baroGrad900to1100[$scaledVal],$text); } // END function baroColour() function uvColour($val) { global $uvGrad; $text = ($val >= 7 ? 'FFF' : '000'); $val *= 10; if ($val < 16) $val = 16; $val -= 16; if ($val > 99) $val = 99; return array($uvGrad[$val],$text); } // END function uvColour() function sunColour($val) { // being used for irradiance global $sunGrad0to10; $text = ($val >= 800 ? 'FFF' : '000'); if ($val > 1499) $val = 1499; return array($sunGrad0to10[$val],$text); } // END function sunColour() function gradient($startcol, $endcol, $graduations=10) { $graduations--; $RedOrigin = hexdec(substr($startcol,0,2)); $GrnOrigin = hexdec(substr($startcol,2,2)); $BluOrigin = hexdec(substr($startcol,4,2)); $GradientSizeRed = (hexdec(substr($endcol,0,2))-$RedOrigin)/$graduations; //Graduation Size Red $GradientSizeGrn = (hexdec(substr($endcol,2,2))-$GrnOrigin)/$graduations; $GradientSizeBlu = (hexdec(substr($endcol,4,2))-$BluOrigin)/$graduations; for($i=0; $i<=$graduations; $i++) { $RetVal[$i] = str_pad(dechex($RedOrigin+($GradientSizeRed*$i)),2,'0',STR_PAD_LEFT) . str_pad(dechex($GrnOrigin+($GradientSizeGrn*$i)),2,'0',STR_PAD_LEFT) . str_pad(dechex($BluOrigin+($GradientSizeBlu*$i)),2,'0',STR_PAD_LEFT); } return $RetVal; } // build unit of measure options (call if required) function picker($type) { global $plank, $displayUOM, $disp, $tableYear, $dataSet; $opt_list = ' "; return $opt_list; } // END function picker() // build dataset options (call if required) function picker2() { global $label_items, $displayUOM, $disp, $tableYear, $dataSet, $windrunUnit; $opt_list = '