$num fields in line $row:
\n";
if ($row > 1) {
$data[] = $linedata;
}
$row++;
}
fclose($handle);
function moving_average($data, $range)
{
$output = array();
foreach ($data as $key=>$value) {
$output[$key] = round(array_sum(array_slice($data,max($key-$range+1,0),$range))/count(array_slice($data,max($key-$range+1,0),$range)),4);
}
return $output;
}
// Got it loaded. Now what? Loop through the DmTs and figure out how many in each range there are.
function show_dmts($data, $buckets, $places) {
$dmts = array();
foreach (range(0, $buckets) as $bucket) {
$dmts[$bucket] = 0;
}
foreach ($data as $line) {
if ($places == 0) {
$rounded_dmt = round($line[9]);
} else {
$rounded_dmt = round($line[9], $places) * ($places * 10);
}
// echo $line[9], 'rounds to:', $rounded_dmt, '
';
$dmts[$rounded_dmt]++;
// print_r($line);
}
// print_r($dmts); echo "
";
$dmts = moving_average($dmts, 1+($places*10));
// print_r($dmts); echo "
";
// Okay, now we know how many sites are in each dmt range. Graph 'em.
echo '
';
}
function show_dmts_whole($data) {
show_dmts($data, 9, 0);
}
function show_dmts_fractional($data) {
show_dmts($data, 99, 1);
}
show_dmts_whole($data);
show_dmts_fractional($data);
?>