LADCPproc.BT
author A.M. Thurnherr <athurnherr@yahoo.com>
Wed, 13 May 2015 21:30:27 +0000
changeset 35 3d769eee8c4f
parent 31 af03ca38fc2a
permissions -rw-r--r--
V1.4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     1
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     2
#                    L A D C P P R O C . B T 
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     3
#                    doc: Wed Oct 20 21:05:37 2010
31
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
     4
#                    dlm: Tue Aug  5 14:38:08 2014
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     5
#                    (c) 2010 A.M. Thurnherr
31
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
     6
#                    uE-Info: 205 0 NIL 0 0 72 10 2 4 NIL ofnI
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     7
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     8
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     9
# HISTORY:
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    10
#	Oct 20, 2010: - created
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
    11
#	Jan 10, 2010: - -o => -k
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    12
#	Jul  7, 2010: - added $DEBUG
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    13
#				  - added BTrangeFlag
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    14
#				  - added $BT processing parameters
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    15
#				  - changed from echo amplitude to Sv
12
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
    16
#	May 16, 2012: - added support for -r)DI BT data
22
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    17
#	Sep 19, 2013: - added support for $BT_range_method
31
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
    18
#	Aug  5, 2014: - BUG: invalid velocities were used; see July 15 bug fix
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
    19
#						 in [LADCPproc.shearmethod]
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
    20
#				  - artifically removed BT profile data apparently below
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
    21
#				    seabed but that had passed previous tests
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    22
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    23
my($BEAM1) = 0;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    24
my($BEAM2) = 1;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    25
my($BEAM3) = 2;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    26
my($BEAM4) = 3;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    27
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    28
my($nBTfound,$nBTrangeFlag,$nBTdepthFlag,$nBTvalidVelFlag,$nBTwFlag) = (0,0,0,0,0);
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    29
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    30
my($DEBUG) = 0;
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    31
12
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
    32
sub CTDvelFromSv($)
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    33
{
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    34
	my($ens) = @_;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    35
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    36
	my(@Sv_max) = (-9e99,-9e99,-9e99,-9e99); my(@Sv_max_bin) = (nan,nan,nan,nan);
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    37
	for (my($bin)=$BT_bin_start-1; $bin<$LADCP{N_BINS}; $bin++) {
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    38
		if (defined($BT_min_depth)) {								# manually supplied bottom depth range
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    39
			my($dob) = &depthOfBin($ens,$bin);
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    40
			next unless ($dob >= $BT_min_depth && $dob <= $BT_max_depth);
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    41
		}
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    42
		$Sv_max[$BEAM1] = $LADCP{ENSEMBLE}[$ens]->{SV}[$bin][$BEAM1],
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    43
		$Sv_max_bin[$BEAM1] = $bin
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    44
			if ($LADCP{ENSEMBLE}[$ens]->{SV}[$bin][$BEAM1] > $Sv_max[$BEAM1]);
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    45
		$Sv_max[$BEAM2] = $LADCP{ENSEMBLE}[$ens]->{SV}[$bin][$BEAM2],
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    46
		$Sv_max_bin[$BEAM2] = $bin
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    47
			if ($LADCP{ENSEMBLE}[$ens]->{SV}[$bin][$BEAM2] > $Sv_max[$BEAM2]);
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    48
		$Sv_max[$BEAM3] = $LADCP{ENSEMBLE}[$ens]->{SV}[$bin][$BEAM3],
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    49
		$Sv_max_bin[$BEAM3] = $bin
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    50
			if ($LADCP{ENSEMBLE}[$ens]->{SV}[$bin][$BEAM3] > $Sv_max[$BEAM3]);
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    51
		$Sv_max[$BEAM4] = $LADCP{ENSEMBLE}[$ens]->{SV}[$bin][$BEAM4],
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    52
		$Sv_max_bin[$BEAM4] = $bin
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    53
			if ($LADCP{ENSEMBLE}[$ens]->{SV}[$bin][$BEAM4] > $Sv_max[$BEAM4]);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    54
	}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    55
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    56
	print(STDERR "@Sv_max | @Sv_max_bin\n") if ($DEBUG);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    57
	$nBTfound++;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    58
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    59
	$nBTrangeFlag++,return											# inconsistent range (&, impliclity, large tilt)
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    60
		unless (max(@Sv_max_bin)-min(@Sv_max_bin) <= $BT_max_bin_spread);
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    61
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    62
	my($range_bin) = round(avg(@Sv_max_bin));
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    63
	printf(STDERR "water_depth = $water_depth; BT peak depth = %d in bin $range_bin\n",depthOfBin($ens,$range_bin))
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    64
		if ($DEBUG);
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    65
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    66
	$nBTdepthFlag++,return											# BT range inconsistent with water depth
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    67
		unless defined($BT_min_depth) ||
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
    68
			   (abs($water_depth-depthOfBin($ens,$range_bin)) < $sig_water_depth + $BT_max_depth_error);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    69
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    70
	my($CTD_u,$CTD_v,$CTD_w);
22
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    71
	
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    72
	if ($BT_range_method == 0) {										# take BT vel from bin with Sv max
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    73
		
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    74
		$nBTvalidVelFlag++,return unless numberp($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin][$W]);
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    75
		$CTD_u = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin][$U];
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    76
		$CTD_v = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin][$V];
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    77
		$CTD_w = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin][$W];
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    78
		
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    79
	} elsif ($BT_range_method == 1) {									# take "best-fit" with w_reflr
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    80
22
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    81
		# try bin of max plus one above and below
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    82
		# this does not really work because, often, only one of the bins has valid velocities
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    83
		my($w1) = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin-1][$W];
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    84
		my($w2) = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin][$W];
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    85
		my($w3) = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin+1][$W];
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    86
	
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    87
		printf(STDERR "w123 = %.1f,%.1f,%.1f\n",$w1,$w2,$w3)
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    88
			if ($DEBUG);
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    89
	
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    90
		$w1 = 9e99 unless numberp($w1); 								# no valid velocities
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    91
		$w2 = 9e99 unless numberp($w1);
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    92
		$w3 = 9e99 unless numberp($w1);
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    93
	
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    94
		if (abs($LADCP{ENSEMBLE}[$ens]->{W}-$w1) < abs($LADCP{ENSEMBLE}[$ens]->{W}-$w2) &&
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    95
			abs($LADCP{ENSEMBLE}[$ens]->{W}-$w1) < abs($LADCP{ENSEMBLE}[$ens]->{W}-$w3)) {
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    96
				$CTD_u = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin-1][$U];
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    97
				$CTD_v = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin-1][$V];
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    98
				$CTD_w = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin-1][$W];
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
    99
		} elsif (abs($LADCP{ENSEMBLE}[$ens]->{W}-$w1) < abs($LADCP{ENSEMBLE}[$ens]->{W}-$w2)) {
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   100
				$CTD_u = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin+1][$U];
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   101
				$CTD_v = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin+1][$V];
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   102
				$CTD_w = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin+1][$W];
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   103
		} else {
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   104
				$nBTvalidVelFlag++,return if ($w2 == 9e99); 			# none of 3 bins has valid velocity
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   105
				$CTD_u = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin][$U];
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   106
				$CTD_v = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin][$V];
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   107
				$CTD_w = $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin][$W];
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   108
	    }
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   109
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   110
	} elsif ($BT_range_method == 2) {									# Visbeck method (median from 3 bins)
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   111
		croak("$0: need \$BT_range_Visbeck_center\n")
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   112
			unless defined($BT_range_Visbeck_center);
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   113
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   114
		$CTD_u = median($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin+$BT_range_Visbeck_center+1][$U],
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   115
						$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin+$BT_range_Visbeck_center][$U],
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   116
						$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin+$BT_range_Visbeck_center-1][$U]);
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   117
		$nBTvalidVelFlag++,return unless numberp($CTD_u);
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   118
		$CTD_v = median($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin+$BT_range_Visbeck_center+1][$V],
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   119
						$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin+$BT_range_Visbeck_center][$V],
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   120
						$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin+$BT_range_Visbeck_center-1][$V]);
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   121
		$CTD_w = median($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin+$BT_range_Visbeck_center+1][$W],
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   122
						$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin+$BT_range_Visbeck_center][$W],
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   123
						$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$range_bin+$BT_range_Visbeck_center-1][$W]);
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   124
		
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   125
	} else {
22
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   126
		
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   127
		croak("$0: unknown \$BT_range_method == $BT_range_method\n");
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   128
	}
22
f6635c0384b7 beginning of DIMES US5 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 12
diff changeset
   129
			
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   130
12
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   131
	return ($CTD_u,$CTD_v,$CTD_w);
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   132
}
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   133
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   134
sub depthAtRange($$)
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   135
{
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   136
	my($ens,$range) = @_;
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   137
	return $LADCP{ENSEMBLE}[$ens]->{XDUCER_FACING_UP} ?
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   138
	       $LADCP{ENSEMBLE}[$ens]->{DEPTH} - $range :
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   139
	       $LADCP{ENSEMBLE}[$ens]->{DEPTH} + $range;
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   140
}
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   141
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   142
sub CTDvelFromBT($)
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   143
{
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   144
	my($ens) = @_;
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   145
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   146
	return (undef,undef,undef)
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   147
		unless defined($LADCP{ENSEMBLE}[$ens]->{BT_VELOCITY}[$W]);
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   148
	$nBTfound++;
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   149
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   150
	$nBTrangeFlag++,return											# inconsistent range (&, impliclity, large tilt)
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   151
		unless (max(@{$LADCP{ENSEMBLE}[$ens]->{BT_RANGE}})-min(@{$LADCP{ENSEMBLE}[$ens]->{BT_RANGE}})
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   152
					<= $BT_max_bin_spread*$LADCP{BIN_LENGTH});
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   153
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   154
	my($range) = round(avg(@{$LADCP{ENSEMBLE}[$ens]->{BT_RANGE}}));
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   155
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   156
	$nBTdepthFlag++,return											# BT range inconsistent with water depth
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   157
		unless defined($BT_min_depth) ||
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   158
			   (abs($water_depth-depthAtRange($ens,$range)) < $sig_water_depth + $BT_max_depth_error);
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   159
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   160
	return ($LADCP{ENSEMBLE}[$ens]->{BT_VELOCITY}[$U],
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   161
			$LADCP{ENSEMBLE}[$ens]->{BT_VELOCITY}[$V],
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   162
			$LADCP{ENSEMBLE}[$ens]->{BT_VELOCITY}[$W]);
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   163
}
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   164
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   165
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   166
sub binBTprof($)
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   167
{
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   168
	my($ens) = @_;
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   169
	my($CTD_u,$CTD_v,$CTD_w);
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   170
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   171
	($CTD_u,$CTD_v,$CTD_w) = $opt_r ? CTDvelFromBT($ens) : CTDvelFromSv($ens);
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   172
	return unless defined($CTD_w);
65582c172355 V1.0beta3
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 3
diff changeset
   173
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
   174
	$nBTwFlag++,return if (abs($CTD_w-$LADCP{ENSEMBLE}[$ens]->{W}) > $BT_max_w_difference);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   175
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
   176
	printf(STDERR "good BT [%5.2f %5.2f %5.2f] found at ens $ens\n",$CTD_u,$CTD_v,$CTD_w)
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
   177
		if ($DEBUG);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   178
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   179
	if ($opt_k) {
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
   180
		for (my($bin)=$BT_bin_start-1; $bin<$LADCP{N_BINS}; $bin++) {
31
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
   181
			next if ($edit_flags[$ens][$bin] || $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W]==0);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   182
			printf(BTF "%d %d %d %f %f %f %f %f %f %f %f %f %f %f\n",
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   183
				$LADCP{ENSEMBLE}[$ens]->{NUMBER},
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   184
				depthOfBin($ens,$bin),$LADCP{ENSEMBLE}[$ens]->{DEPTH},
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   185
				$LADCP{ENSEMBLE}[$ens]->{PITCH},$LADCP{ENSEMBLE}[$ens]->{ROLL},
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   186
				$CTD_u,$CTD_v,$CTD_w,
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   187
				$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$U],
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   188
				$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$V],
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   189
				$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W],
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   190
				$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$U]-$CTD_u,
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   191
				$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$V]-$CTD_v,
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   192
				$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W]-$CTD_w);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   193
		}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   194
	    print(BTF "nan nan nan nan\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   195
	}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   196
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
   197
	for (my($bin)=$BT_bin_start-1; $bin<$LADCP{N_BINS}; $bin++) {
31
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
   198
		next if ($edit_flags[$ens][$bin] || $LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W]==0);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
   199
		my($dob) = depthOfBin($ens,$bin);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
   200
		next if ($dob > $water_depth);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 22
diff changeset
   201
		my($gi) = int($dob / $GRID_DZ);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   202
		push(@{$BTu_vals[$gi]},$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$U]-$CTD_u);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   203
		push(@{$BTv_vals[$gi]},$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$V]-$CTD_v);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   204
		push(@{$BTw_vals[$gi]},$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W]-$CTD_w);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   205
	}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   206
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   207
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   208
sub getBTprof($$)
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   209
{
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   210
	my($LADCP_start,$LADCP_end) = @_;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   211
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   212
	if ($opt_k) {
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   213
		open(BTF,">BT.profs");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   214
	    print(BTF "#ANTS#FIELDS# {ens} {depth} {CTD_depth} {pitch} {roll} {CTD_u} {CTD_v} {CTD_w} {u} {v} {w} {BT_u} {BT_v} {BT_w}\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   215
	}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   216
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   217
	for (my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) {
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
   218
		next unless ($water_depth-$LADCP{ENSEMBLE}[$ens]->{DEPTH} < $BT_begin_search_above);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   219
		binBTprof($ens);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   220
	}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   221
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   222
	if ($opt_d) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   223
		print(STDERR "\n\t$nBTfound BT ensembles found\n");
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
   224
	    print(STDERR "\t\t$nBTrangeFlag flagged bad because of inconsistent range to seabed\n");
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   225
	    print(STDERR "\t\t$nBTdepthFlag flagged bad because of wrong bottom depth\n");
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
   226
	    print(STDERR "\t\t$nBTvalidVelFlag flagged bad because of lack of valid velocities\n");
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
   227
	    print(STDERR "\t\t$nBTwFlag flagged bad because of incorrect vertical velocities");
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
   228
	    printf(STDERR "\n\t=> %d velocities from %d BT ensembles used",
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
   229
	    				scalar(@BTu_vals),
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 1
diff changeset
   230
						$nBTfound-$nBTrangeFlag-$nBTdepthFlag-$nBTvalidVelFlag-$nBTwFlag);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   231
	}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   232
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   233
	@BTu  = @BTv  = @BTw  = ();
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   234
	@BTu_sig = @BTv_sig = @BTw_sig = ();
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   235
	@BT_nsamp = ();
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   236
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   237
	for (my($gi)=0; $gi<@BTu_vals; $gi++) {								# calc grid means & stddev
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   238
		my($sum_u,$sum_v,$sum_w);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   239
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   240
		$BT_nsamp[$gi] = @{$BTu_vals[$gi]};
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   241
		
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   242
		for (my($vi)=0; $vi<$BT_nsamp[$gi]; $vi++) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   243
			$sum_u += $BTu_vals[$gi][$vi];
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   244
			$sum_v += $BTv_vals[$gi][$vi];
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   245
			$sum_w += $BTw_vals[$gi][$vi];
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   246
		}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   247
		$BTu[$gi] = $BT_nsamp[$gi] ? $sum_u/$BT_nsamp[$gi] : nan;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   248
		$BTv[$gi] = $BT_nsamp[$gi] ? $sum_v/$BT_nsamp[$gi] : nan;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   249
		$BTw[$gi] = $BT_nsamp[$gi] ? $sum_w/$BT_nsamp[$gi] : nan;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   250
	}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   251
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   252
	for (my($gi)=0; $gi<@BTu_vals; $gi++) {								# calc & grid stddevs
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   253
		my($sumsq_u,$sumsq_v,$sumsq_w);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   254
		for (my($vi)=0; $vi<$BT_nsamp[$gi]; $vi++) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   255
			$sumsq_u += ($BTu_vals[$gi][$vi] - $BTu[$gi])**2;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   256
			$sumsq_v += ($BTv_vals[$gi][$vi] - $BTv[$gi])**2;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   257
			$sumsq_w += ($BTw_vals[$gi][$vi] - $BTw[$gi])**2;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   258
		}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   259
		$BTu_sig[$gi] = $BT_nsamp[$gi]>1 ? sqrt($sumsq_u/($BT_nsamp[$gi]-1)) : nan;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   260
		$BTv_sig[$gi] = $BT_nsamp[$gi]>1 ? sqrt($sumsq_v/($BT_nsamp[$gi]-1)) : nan;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   261
		$BTw_sig[$gi] = $BT_nsamp[$gi]>1 ? sqrt($sumsq_w/($BT_nsamp[$gi]-1)) : nan;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   262
	}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   263
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   264
	close(BTF) if ($opt_k);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   265
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   266
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   267
1;