Wilmslow, UK - latitude N 53° 19' 32" longitude W 02° 14' 33" elevation 70 m
View Source - Hint, actually 'View the page source!'
======= SCRIPT CONTENTS BELOW HERE - VIEW THE PAGE SOURCE! ========
(isset($SITE['uomTemp']) ? substr($SITE['uomTemp'], -1) : 'C'),
'rain' => (isset($SITE['uomRain']) ? substr($SITE['uomRain'], 1) : 'mm'),
'wind' => (isset($SITE['uomWind']) ? substr($SITE['uomWind'], 1) : 'mph'),
'baro' => (isset($SITE['uomBaro']) ? substr($SITE['uomBaro'], 1) : 'hPa')
);
// language ........
$default_lang = 'en'; // 'look-up' array to use if not passed or defined elsewhere
// get language files
if (file_exists('datasummary/datasummaryLanguagesSQL.php')) {
(@include_once 'datasummary/datasummaryLanguagesSQL.php') or die('FATAL ERROR - Language File FAIL !!');
} else {
(@include_once 'datasummaryLanguagesSQL.php') or die('FATAL ERROR - Language File FAIL !!');
}
// look for a 'posted' lang - change post name if required
if (isset($_REQUEST['lang']) && $_REQUEST['lang'] != '') { // change from $default_lang
if (array_key_exists($_REQUEST['lang'], $translit)) {
$dayfileLang = $_REQUEST['lang'];
}
}
if (!isset($dayfileLang)) {
$dayfileLang = $default_lang;
}
/*
$label_items FORMAT
array(*var name of data*,
menu button text,
table heading,
true OR false = show menu button - DO NOT COMMENT OUT LINE !!,
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* - 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(
//Data Set Short Name Long Name Menu? Row field Units ashl
'maxtemp' => array($translit[$dayfileLang]['maxtemp'][0], $translit[$dayfileLang]['maxtemp'][1], true, 1, 'temp', 'ahl'),
'mintemp' => array($translit[$dayfileLang]['mintemp'][0], $translit[$dayfileLang]['mintemp'][1], true, 1, 'temp', 'ahl'),
'tdiff' => array($translit[$dayfileLang]['tdiff'][0], $translit[$dayfileLang]['tdiff'][1], true, array(1, 2), 'temp', 'ahl'), // NB: Example of more than one data value grab
'avgtemp' => array($translit[$dayfileLang]['avgtemp'][0], $translit[$dayfileLang]['avgtemp'][1], true, 1, 'temp', 'ahl'),
'MaxFeelsLike' => array($translit[$dayfileLang]['MaxFeelsLike'][0], $translit[$dayfileLang]['MaxFeelsLike'][1], true, 1, 'temp', 'ahl'),
'MinFeelsLike' => array($translit[$dayfileLang]['MinFeelsLike'][0], $translit[$dayfileLang]['MinFeelsLike'][1], true, 1, 'temp', 'ahl'),
'highDewPoint' => array($translit[$dayfileLang]['highDewPoint'][0], $translit[$dayfileLang]['highDewPoint'][1], true, 1, 'temp', 'ahl'),
'lowDewPoint' => array($translit[$dayfileLang]['lowDewPoint'][0], $translit[$dayfileLang]['lowDewPoint'][1], true, 1, 'temp', 'ahl'),
'highHum' => array($translit[$dayfileLang]['highHum'][0], $translit[$dayfileLang]['highHum'][1], true, 1, null, 'ahl'),
'lowHum' => array($translit[$dayfileLang]['lowHum'][0], $translit[$dayfileLang]['lowHum'][1], true, 1, null, 'ahl'),
'totRainFall' => array($translit[$dayfileLang]['totRainFall'][0], $translit[$dayfileLang]['totRainFall'][1], true, 1, 'rain', 'sah'),
'totRainDays' => array($translit[$dayfileLang]['totRainDays'][0], $translit[$dayfileLang]['totRainDays'][1], true, 1, 'rain', 's'),
'highAvgWspeed' => array($translit[$dayfileLang]['highAvgWspeed'][0], $translit[$dayfileLang]['highAvgWspeed'][1], true, 1, 'wind', 'ah'),
'highWindGust' => array($translit[$dayfileLang]['highWindGust'][0], $translit[$dayfileLang]['highWindGust'][1], true, 1, 'wind', 'ah'),
'totWindRun' => array($translit[$dayfileLang]['totWindRun'][0], $translit[$dayfileLang]['totWindRun'][1], true, 1, null, 'sah'),
'domWindDir' => array($translit[$dayfileLang]['domWindDir'][0], $translit[$dayfileLang]['domWindDir'][1], true, 1, null, 'a'), // NB: also looks for a windspeed to to be valid
'maxPress' => array($translit[$dayfileLang]['maxPress'][0], $translit[$dayfileLang]['maxPress'][1], true, 1, 'baro', 'ahl'),
'minPress' => array($translit[$dayfileLang]['minPress'][0], $translit[$dayfileLang]['minPress'][1], true, 1, 'baro', 'ahl'),
'HoursSun' => array($translit[$dayfileLang]['HoursSun'][0], $translit[$dayfileLang]['HoursSun'][1], true, 1, null, 'sah'),
'HighSolarRad' => array($translit[$dayfileLang]['HighSolarRad'][0], $translit[$dayfileLang]['HighSolarRad'][1], true, 1, null, 'ah'),
'totInsol' => array($translit[$dayfileLang]['totInsol'][0], $translit[$dayfileLang]['totInsol'][1], true, 1, null, 'sah'),
//'HighUV' => array($translit[$dayfileLang]['HighUV'][0], $translit[$dayfileLang]['HighUV'][1], true, 1, null, 'ah'),
'totalEvap' => array($translit[$dayfileLang]['totalEvap'][0], $translit[$dayfileLang]['totalEvap'][1], true, 1, 'rain', 'sah'),
'HeatDegDays' => array($translit[$dayfileLang]['HeatDegDays'][0], $translit[$dayfileLang]['HeatDegDays'][1], true, 1, 'temp', 'sah'),
'CoolDegDays' => array($translit[$dayfileLang]['CoolDegDays'][0], $translit[$dayfileLang]['CoolDegDays'][1], true, 1, 'temp', 'sah'),
'AirQuality' => array($translit[$dayfileLang]['AirQuality'][0], $translit[$dayfileLang]['AirQuality'][1], true, 1, null, 'a')
);
// 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:
// ... 'highAvgWspeed', 'highWindGust', 'totWindRun', 'HoursSun', 'HighSolarRad', 'HighUV', totalEvap
$SANITIZE = false; // true OR false - attempt to ignore zero in the following datasets:
//$zero_as_null = array('highAvgWspeed', 'highWindGust', 'totWindRun', 'HoursSun', 'HighSolarRad', 'HighUV'); // datasets to 'fix' - EDIT TO SUIT
$zero_as_null = array(); // datasets to 'fix' - EDIT TO SUIT
$type_data = array(); //Global to hold the raw data for the selected data type
$type_year = array();
// Solar bar stuff
$bg_lat = 53.326; // If $maxsunhours 0 or 1 set your Latitude in decimal, -negative values for Southern hemisphere
$bg_lon = -2.243; // If $maxsunhours 0 or 1 set your Longitude in decimal, -negative values for West
$bg_time_zone = ""; // If $maxsunhours 0 or 1 set your timezone ONLY if your data is a different TZ to your server - see: http://php.net/manual/en/timezones.php
$maxsunhours = 24; // Set sunshine bar graph option as above
$sunAvailable = 0; // No of hours of available sunshine today
// parse / display code for defined datasets
function formatOP($monthly = false) {
global $thisValue, $part2, $dataSet, $decimals, $native, $sunAvailable;
if ($thisValue != '' || $thisValue == 0) { // ***************** added || $thisValue == 0, don't like it !!!!!!!
switch ($dataSet) {
case 'highWindGust':
$col = gustColour(DoWind($thisValue, 'mph')); // format to colour range uom
$part2 .= ' style="background-color:#' . $col[0] . '; color:#' . $col[1] . '"';
$native = $thisValue;
$thisValue = DoWind($thisValue, null); // format to DISPLAY uom
break;
case 'highAvgWspeed':
$col = windColour(DoWind($thisValue, 'mph')); // format to colour range uom
$part2 .= ' style="background-color:#' . $col[0] . '; color:#' . $col[1] . '"';
$native = $thisValue;
$thisValue = DoWind($thisValue, null); // format to DISPLAY uom
break;
case 'maxtemp':
case 'mintemp':
case 'avgtemp':
case 'MaxFeelsLike':
case 'MinFeelsLike':
case 'highDewPoint':
case 'lowDewPoint':
$col = tempColour(DoTemp($thisValue, 'C')); // format to colour range uom
$part2 .= ' style="background-color:#' . $col[0] . '; color:#' . $col[1] . '"';
$native = $thisValue;
$thisValue = DoTemp($thisValue, null); // format to DISPLAY uom
break;
case 'HeatDegDays':
$native = $thisValue; // used to populate array for seasonal average
$scaler = $monthly ? 40 : 1;
if ($thisValue == 0) {
$col = array('FFF', '9A9A9A');
} else {
// need to reverse the scale for heating days - bigger number means it is colder!
$col = tempColour(DoTempDiff(12 - $thisValue / $scaler, 'C')); // format to colour range uom
}
$thisValue = DoTempDiff($thisValue, null); // format to DISPLAY uom
$part2 .= ' style="background-color:#' . $col[0] . '; color:#' . $col[1] . '"';
break;
case 'CoolDegDays':
$native = $thisValue; // used to populate array for seasonal average
$scaler = $monthly ? 8 : 1;
if ($thisValue == 0) {
$col = array('FFF', '9A9A9A');
} else {
$col = tempColour(DoTempDiff($thisValue, 'C') / $scaler * 2 + 10); // format to colour range uom
}
$thisValue = DoTempDiff($thisValue, null); // format to DISPLAY uom
$part2 .= ' style="background-color:#' . $col[0] . '; color:#' . $col[1] . '"';
break;
/*
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
*/
case 'tdiff':
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 = tempDiffColour(DoTempDiff($native, 'C')); // format to colour range uom
$thisValue = 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 = tempDiffColour(DoTempDiff($thisValue, 'C')); // format to colour range uom
$thisValue = DoTempDiff($thisValue, null); // format to DISPLAY uom
}
$part2 .= ' style="background-color:#' . $col[0] . '; color:#' . $col[1] . '"';
break;
// END calculated example
case 'totalEvap':
case 'totRainFall':
$val = $dataSet == 'totalEvap' ? $thisValue * 4 : $thisValue; // frig: evap is much less than rainfall
$val = DoRain($val, 'mm');
$val = $monthly ? $val / 15 : $val; // frig: divide value by 15 for monthly totals
$col = rainColour($val); // format to colour range uom;
$part2 .= ' style="background-color:#' . $col[0] . '; color:#' . $col[1] . '"';
$native = $thisValue;
$thisValue = DoRain($thisValue, null); // format to DISPLAY uom
break;
case 'totWindRun':
$baseTot = $monthly ? 22 : 1; // frig: divide by 22 for monthly totals
$col = runColour(DoWind($thisValue / $baseTot, 'mph')); // format to colour range uom;
$part2 .= ' style="background-color:#' . $col[0] . '; color:#' . $col[1] . '"';
$native = $thisValue;
$thisValue = DoWind($thisValue, null); // format to DISPLAY uom
break;
case 'domWindDir':
if (intval($thisValue) > 0) {
$thisValue = getHeading(intval($thisValue));
}
break;
case 'maxPress':
case 'minPress':
$col = baroColour(DoBaro($thisValue, 'hPa')); // format to colour range uom;
$part2 .= ' style="background-color:#' . $col[0] . '; color:#' . $col[1] . '"';
$native = $thisValue;
$thisValue = DoBaro($thisValue, null); // format to DISPLAY uom
break;
case 'highHum':
case 'lowHum':
$col = humColour($thisValue);
$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, '.', '');
break;
case 'HighUV':
$col = uvColour($thisValue);
$part2 .= ' style="background-color:#' . $col[0] . '; color:#' . $col[1] . '"';
$native = $thisValue;
// no Unit conversions to do - so 'format' directly
$thisValue = number_format((float)$thisValue, 1, '.', '');
break;
case 'HoursSun': // based on code by Mark Crossley
$part2 .= '>
'') { // belts'n'braces
if ($dataSet === 'domWindDir') {
//if ($thisValue[0] >0 && $thisValue[1] >0 ) {
$wval = round($thisValue / 22.5);
$mondomWindDir[$m][$wval]++; // creating a 'counter' whose 'key' is the direction (0 > 15)
//$thisValue = $thisValue[0];
//} else {
//$thisValue = '';
//}
}
if ($thisValue <> '') {
if ($dataSet == "HoursSun") {
$sunAvailable = maxsunhours($theDate);
$bg_monSum[$m][] = $sunAvailable;
}
formatOP(); // $thisValue is a global so doesn't need to be 'passed'
$part2 .= '>';
$part2 .= $thisValue; // may have been converted by formatOP()
$monSum[$m][] = $native;
if ($dataSet === 'HoursSun') {
$thisValue = true; // a fiddle because of the way it is formated
}
}
//}
}
}
}
if ($thisValue === '') {
$part2 .= '"> '; // *** attempted logic fix
}
} else { // not a valid day of month
$part2 .= '
\n";
$line = true;
} // END calcSum
if ($calcAvg) { // windirection is an exception where we need to find 'dominant' value
if ($dataSet === 'totWindRun') {
$decimals = 0;
}
$fixthis = ($line ? '' : ' topborder');
$tablelayout .= '
\n";
$line = true;
} // END calcLo
$sanitized = '';
if ($SANITIZE && in_array($dataSet, $zero_as_null)) { // we want to try to 'nullify' zero values in some datasets
$sanitized = ' - '.$translit[$dayfileLang]['note'][2]; // prepare 'Note;' advisory
}
// 'Note:' line
$tablelayout .= '
\n";
} // END year walk
// now do overall month averages - not for wind direction - too ambitous!
// Not for total rain days and total rainfall - only display sum
if ($dataSet !== 'domWindDir') {
if ($dataSet !== 'domWindDir' && $dataSet !== 'totRainDays') {
$decimals = 1;
}
$tablelayout .= '