home
 
 
 
Code: Graph of Binaries
<?php
											 
											/*
												Code: Graph of Binaries
												© Charles Chandler
												http://qdl.scs-inc.us/?top=13752
											*/
											 
											$result = $errors = $pts = array();
											$folder = '2ndParty/Images/Charles/Stars/binaries/';
											foreach(explode(kLF, file_get_contents($folder.'data_all.txt')) as $oneLine) {
											$str = trim(substr($oneLine, 57, 71 - 58));
											if ($str) {
											$str = str_replace('     ', ' ', $str);
											$str = str_replace('    ',  ' ', $str);
											$str = str_replace('   ',   ' ', $str);
											$str = str_replace('  ',    ' ', $str);
											if ($str == '18.7 19. 9') $str = '18.7 19.9';
											if (is_numeric($str)) $str = $str.' '.$str;
											if ($str != '. .') {
											$pair = explode(' ', $str);
											if (count($pair) == 2) {
											if ($pair[1] == '.') $pair[1] = $pair[0];
											if ($pair[0] == '.') $pair[0] = $pair[1];
											if ($pair[1] ==  0 ) $pair[1] = $pair[0];
											if ($pair[0] ==  0 ) $pair[0] = $pair[1];
											if ($pair[0] > $pair[1]) {
											$a = $pair[0];
											$b = $pair[1];
											} else {
											$a = $pair[1];
											$b = $pair[0];
											}
											if (($a == 0) or ($b == 0)) {
											$errors[] = '['.$str.']';
											} else $result[] = strval(round(($a / $b) * 100));
											} else $errors[] = '['.$str.']';
											}
											}
											}
											$tmp = array_count_values($result);
											ksort($tmp);
											include_once('Geometry.php');
											$pts[] = Pt('primary / secondary magnitude', 'number of binary systems (thousands)');
											$within = $without = 0; // how many are within 10%
											foreach($tmp as $ratio => $count) {
											if ($count > 99) {
											if ($ratio > 99) {
											$pts[] = Pt($ratio / 100, $count);
											if ($ratio > 110) {
											$without += $count;
											} else {
											$within += $count;
											}
											} else $errors[] = '['.$ratio.' '.$count.']';
											}
											}
											$pts[] = Pt(2, 100);
											$pts[] = Pt(2, 0);
											foreach($errors as $oneError) AlertBox(1, $oneError);
											$result = '';
											foreach($pts as $pt) {
											if (is_numeric($pt['y'])) $pt['y'] = $pt['y'] / 1000;
											$result .= $pt['x'].kTAB.$pt['y'].kLF;
											}
											file_put_contents($folder.'results.txt', $result);
											 
										?>

← PREV Powered by Quick Disclosure Lite®
© 2010~2017 SCS-INC.US
NEXT →