scanBins
author A.M. Thurnherr <athurnherr@yahoo.com>
Tue, 29 Mar 2016 15:01:34 -0400
changeset 33 307630665c6c
parent 0 229a0d72d2ab
permissions -rwxr-xr-x
V1.5

#!/usr/bin/perl
#======================================================================
#                    S C A N B I N S 
#                    doc: Mon Jan 27 17:55:34 2003
#                    dlm: Thu Mar 17 07:45:37 2016
#                    (c) 2003 A.M. Thurnherr
#                    uE-Info: 20 22 NIL 0 0 72 2 2 4 NIL ofnI
#======================================================================

# Collect Per-Bin Stats
#	NB: currently broken

# HISTORY:
#	Jan 27, 2003: - created
#	Sep 19, 2007: - adapted to new [RDI_BB_Read.pl] (not tested)
#   Mar 17, 2016: - adapted to new Getopt library
#				  - updated ancient library name

$0 =~ m{(.*)/[^/]+}; 
require "$1/RDI_PD0_IO.pl";
use Getopt::Std;

die("Usage: $0 " .
	"" .
	"<RDI file>\n")
		unless (&getopts("") && @ARGV == 1);

print(STDERR "Reading $ARGV[0]...");
readData($ARGV[0],\%dta);									# read data
print(STDERR "done\n");

for ($e=0; $e<=$#{$dta{ENSEMBLE}}; $e++) {
	checkEnsemble(\%dta,$e);									# sanity checks
	$nens++;

	next unless (defined($dta{ENSEMBLE}[$e]->{VELOCITY}[0][0]) &&
				 defined($dta{ENSEMBLE}[$e]->{VELOCITY}[0][1]) &&
				 defined($dta{ENSEMBLE}[$e]->{VELOCITY}[0][2]) &&
				 defined($dta{ENSEMBLE}[$e]->{VELOCITY}[0][3]));
	$ngoodens++;
	
	for ($b=0; $b<$dta{N_BINS}; $b++) {					# collect stats
		my($ngood) = defined($dta{ENSEMBLE}[$e]->{VELOCITY}[$b][0])
				   + defined($dta{ENSEMBLE}[$e]->{VELOCITY}[$b][1])
				   + defined($dta{ENSEMBLE}[$e]->{VELOCITY}[$b][2])
				   + defined($dta{ENSEMBLE}[$e]->{VELOCITY}[$b][3]);
		if 	  ($ngood == 4) { $ngood4[$b]++; }
		elsif ($ngood == 3) { $ngood3[$b]++; }
		else				{ $nbad[$b]++; }

		for ($i=0; $i<4; $i++) {
			if (defined($dta{ENSEMBLE}[$e]->{VELOCITY}[$b][$i])) {
				$ngood[$b][$i]++;
				$sumcor[$b][$i] += $dta{ENSEMBLE}[$e]->{CORRELATION}[$b][$i];
				$sumamp[$b][$i] += $dta{ENSEMBLE}[$e]->{ECHO_AMPLITUDE}[$b][$i];
			}
		}
	}
}

printf("$ngoodens good ensembles out of $nens\n");
for ($b=0; $b<$dta{N_BINS}; $b++) {						# gen output
	printf("%2d: vels: %3d%% 4-bin, %3d%% 3-bin, %3d%% bad; ",
		$b+1,
		100*$ngood4[$b]/$ngoodens,100*$ngood3[$b]/$ngoodens,
		100*$nbad[$b]/$ngoodens);
	printf("mean corr: %3d/%3d/%3d/%3d; mean amp: %3d/%3d/%3d/%3d",
		$sumcor[$b][0]/$ngood[$b][0], $sumcor[$b][1]/$ngood[$b][1],
		$sumcor[$b][2]/$ngood[$b][2], $sumcor[$b][3]/$ngood[$b][3],
		$sumamp[$b][0]/$ngood[$b][0], $sumamp[$b][1]/$ngood[$b][1],
		$sumamp[$b][2]/$ngood[$b][2], $sumamp[$b][3]/$ngood[$b][3]);
	print("\n");
}

exit(0);