LADCPintsh
author A.M. Thurnherr <athurnherr@yahoo.com>
Sun, 19 Feb 2012 18:17:33 +0000
changeset 6 2cc7f3b110af
parent 5 fa82bdf18b43
child 7 e67ddf9937eb
permissions -rwxr-xr-x
.
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
#!/usr/bin/perl
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     2
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     3
#                    L A D C P I N T S H 
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     4
#                    doc: Thu Oct 14 21:22:50 2010
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
     5
#                    dlm: Wed Jul 27 18:51:49 2011
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     6
#                    (c) 2010 A.M. Thurnherr & E. Firing
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
     7
#                    uE-Info: 221 0 NIL 0 0 72 2 2 4 NIL ofnI
0
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
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    10
$antsSummary = 'integrate LADCP shear';
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    11
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    12
# NOTES:
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    13
#	- the core of this code is a simplified version of avg_sh.m and
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    14
#	  int_sh.m written by Eric Firing
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    15
#	- comments beginning with ## are taken from Eric's code
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    16
#	- cubic velocity interpolation across PPI gap from Eric's code has
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    17
#	  not been implemented (yet?)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    18
#	- low-pass-filtered shear code has not yet been implemented
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    19
#	- currently, shear gaps are assumed to have vanishing shear;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    20
#	  better solutions are possible 
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    21
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    22
# WEIRDNESSES IN Eric's CODE:
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    23
#	- in Eric's [avg_sh.m] the calculation of output shear stddev incorrectly assumes that the 4th column
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    24
#	  in the shear profile is stddev, rather than variance. However, as far as I can tell, this output
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    25
#	  is not used anywhere in Eric's code
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    26
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    27
# HISTORY:
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    28
#	Oct 14, 2010: - created
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    29
#	Oct 20, 2010: - first working version
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    30
#	Oct 23, 2010: - added support for -b)
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    31
#	Oct 24, 2010: - fix spuriously small variances that can occur for BT velocities based on very small
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    32
#					samples (i.e. primarily when chosing a small -r)
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
    33
#	Dec  9, 2010: - allowed for empty BT file
2
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
    34
#	Feb 16, 2011: - BUG: gaps in shear data were not handled correctly in baroclinic solution
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
    35
#	Jul  7, 2011: - added -m
5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
    36
#	Jul 19, 2011: - added shear sigma output for shear inversion
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
    37
#				  - BUG: dc/uc v component was not correctly referenced
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    38
#	Jul 24, 2011: - BUG: BT constraint was erroneously assumed to be available for dc,uc only, if it
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    39
#						 was available for <dc,uc> combo profile
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    40
#	Jul 25, 2011: - BUG: nan in either of ul/dl u_z.sig caused combined u_z.sig to be nan, too
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    41
#	Jul 27, 2011: - removed code related to smoothed shear
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    42
#				  - replaced -r by -n
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    43
#				  - removed shear sigma output
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    44
#				  - replaced ndata by nsamp
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    45
#				  - removed -w (Eric's way of dealing with dc/uc temporal variability)
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    46
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    47
($ANTS) = (`which list` =~ m{^(.*)/[^/]*$});
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    48
require "$ANTS/ants.pl";
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    49
require "$ANTS/libstats.pl";
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    50
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    51
&antsUsage('b:dm:n:s:w:u:',0,
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    52
	'[-d)ebug]',
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
    53
	'[reference with -b)ottom-track <file> [-m)in BT samp[10]]]',
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
    54
	'[-u)plooker <file>]',
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    55
	'[min -n) <shear samp[10]>]',
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    56
	'[output -s)hear-pro <file>]',
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    57
	'[LADCP shear file]');
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: 2
diff changeset
    59
croak("$0: -m requires -b\n")
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
    60
	if defined($opt_m) && !defined($opt_b);
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
    61
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    62
&antsCardOpt(\$opt_n,10);	## minimum number of samples for shear
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
    63
&antsCardOpt(\$opt_m,10);	# minimum number of samples for BT data
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    64
#&antsCardOpt(\$opt_s,20);	## minimum number of samples for smoothed shear
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
    65
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
    66
&antsFileOpt($opt_b);		# BT file
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
    67
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
    68
&antsFileOpt($opt_u);		# UL shear file
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
    69
open(ULF,$opt_u) || croak("$opt_u: $!\n")
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
    70
	if defined($opt_u);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    71
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    72
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    73
# Step 1: Read and Average Shear Data
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    74
#	- depth bins with less than $opt_n values are blanked out
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    75
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    76
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    77
sub wavg_sig(@)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    78
{
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    79
	my($sumSq) = my($n) = 0;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    80
	for (my($i)=0; $i<$#_; $i+=2) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    81
		next unless numberp($_[$i+1]);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    82
		$sumSq += $_[$i] * $_[$i+1]**2;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    83
		$n += $_[$i];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    84
	}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    85
	return ($n>0) ? sqrt($sumSq/$n) : nan;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    86
}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    87
	
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    88
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    89
$depthF = fnr('depth');				# layout of [LADCPproc] output
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    90
$dc_nshF = fnr('dc_nshear');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    91
$dc_uzF  = fnr('dc_u_z');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    92
$dc_uzsF = fnrNoErr('dc_u_z.sig');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    93
$dc_uzsF = fnr('dc_u_z_sig')
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    94
	unless defined($dc_uzsF);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    95
$dc_vzF  = fnr('dc_v_z');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    96
$dc_vzsF = fnrNoErr('dc_v_z.sig');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    97
$dc_vzsF = fnr('dc_v_z_sig')
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    98
	unless defined($dc_vzsF);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    99
$dc_wzF  = fnr('dc_w_z');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   100
$dc_wzsF = fnrNoErr('dc_w_z.sig');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   101
$dc_wzsF = fnr('dc_w_z_sig')
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   102
	unless defined($dc_wzsF);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   103
$uc_nshF = fnr('uc_nshear');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   104
$uc_uzF  = fnr('uc_u_z');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   105
$uc_uzsF = fnrNoErr('uc_u_z.sig');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   106
$uc_uzsF = fnr('uc_u_z_sig')
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   107
	unless defined($uc_uzsF);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   108
$uc_vzF  = fnr('uc_v_z');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   109
$uc_vzsF = fnrNoErr('uc_v_z.sig');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   110
$uc_vzsF = fnr('uc_v_z_sig')
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   111
	unless defined($uc_vzsF);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   112
$uc_wzF  = fnr('uc_w_z');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   113
$uc_wzsF = fnrNoErr('uc_w_z.sig');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   114
$uc_wzsF = fnr('uc_w_z_sig')
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   115
	unless defined($uc_wzsF);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   116
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   117
my(@gaps); my($curGap) = 0;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   118
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   119
for (my($r)=0; &antsIn(); $r++) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   120
	my(@UL_);
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   121
	if (defined($opt_u)) {
5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   122
		@UL_ = &antsFileIn(ULF);							# read UL shear data
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   123
		undef($opt_u) unless (@UL_);						# cheap trick
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   124
	}
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   125
	
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   126
	$depth[$r] = $ants_[0][$depthF];						## depth grid values
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   127
	croak("$opt_u: inconsistent depth (DL: $depth[$r]; UL: $UL_[$depthF])\n")
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   128
		if defined($opt_u) && ($UL_[$depthF] != $depth[$r]);
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   129
		
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   130
	$dc_nsamp = $ants_[0][$dc_nshF];						# number of shear samples
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   131
	$uc_nsamp = $ants_[0][$uc_nshF];
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   132
	if (defined($opt_u)) {
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   133
		$dl_nsamp = $dc_nsamp + $uc_nsamp;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   134
		$ul_nsamp = $UL_[$dc_nshF] + $UL_[$uc_nshF];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   135
		$dc_nsamp += $UL_[$dc_nshF];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   136
		$uc_nsamp += $UL_[$uc_nshF];
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   137
	}
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   138
	$dc_nsamp[$r] = $dc_nsamp;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   139
	$uc_nsamp[$r] = $uc_nsamp;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   140
	$nsamp[$r] = $dc_nsamp + $uc_nsamp;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   141
	if (defined($opt_u)) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   142
		$ul_nsamp[$r] = $ul_nsamp;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   143
		$dl_nsamp[$r] = $dl_nsamp;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   144
	}
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   145
5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   146
	if (defined($opt_u)) {									# dual-head instrument
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   147
		if ($dc_nsamp > 0) {								# downcast shear
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   148
			my($DLf) = $ants_[0][$dc_nshF] / $dc_nsamp;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   149
			my($ULf) =      $UL_[$dc_nshF] / $dc_nsamp;
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   150
			if ($DLf>0 && $Ulf>0) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   151
				$dc_uz[$r] = $DLf*$ants_[0][$dc_uzF] + $ULf*$UL_[$dc_uzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   152
				$dc_vz[$r] = $DLf*$ants_[0][$dc_vzF] + $ULf*$UL_[$dc_vzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   153
	            $dc_wz[$r] = $DLf*$ants_[0][$dc_wzF] + $ULf*$UL_[$dc_wzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   154
	        } elsif ($DLf > 0) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   155
				$dc_uz[$r] = $ants_[0][$dc_uzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   156
				$dc_vz[$r] = $ants_[0][$dc_vzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   157
				$dc_wz[$r] = $ants_[0][$dc_wzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   158
	        } else {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   159
				$dc_uz[$r] = $UL_[$dc_uzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   160
				$dc_vz[$r] = $UL_[$dc_vzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   161
				$dc_wz[$r] = $UL_[$dc_wzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   162
	        }
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   163
		} else {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   164
			$dc_uz[$r] = $dc_vz[$r] = $dc_wz[$r] = nan;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   165
	    }
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   166
		if ($uc_nsamp > 0) {								# upcast shear
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   167
			my($DLf) = $ants_[0][$uc_nshF] / $uc_nsamp;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   168
			my($ULf) =      $UL_[$uc_nshF] / $uc_nsamp;
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   169
			if ($DLf>0 && $Ulf>0) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   170
				$uc_uz[$r] = $DLf*$ants_[0][$uc_uzF] + $ULf*$UL_[$uc_uzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   171
				$uc_vz[$r] = $DLf*$ants_[0][$uc_vzF] + $ULf*$UL_[$uc_vzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   172
				$uc_wz[$r] = $DLf*$ants_[0][$uc_wzF] + $ULf*$UL_[$uc_wzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   173
	        } elsif ($DLf > 0) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   174
				$uc_uz[$r] = $ants_[0][$uc_uzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   175
				$uc_vz[$r] = $ants_[0][$uc_vzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   176
				$uc_wz[$r] = $ants_[0][$uc_wzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   177
	        } else {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   178
				$uc_uz[$r] = $UL_[$uc_uzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   179
				$uc_vz[$r] = $UL_[$uc_vzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   180
				$uc_wz[$r] = $UL_[$uc_wzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   181
	        }
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   182
		} else {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   183
			$uc_uz[$r] = $uc_vz[$r] = $uc_wz[$r] = nan;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   184
	    }
5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   185
	} else {	# downlooker only
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   186
		if ($dc_nsamp > 0) {							# downcast shear
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   187
			$dc_uz[$r] = $ants_[0][$dc_uzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   188
			$dc_vz[$r] = $ants_[0][$dc_vzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   189
			$dc_wz[$r] = $ants_[0][$dc_wzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   190
		} else {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   191
			$dc_uz[$r] = $dc_vz[$r] = $dc_wz[$r] = nan;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   192
	    }
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   193
		if ($uc_nsamp > 0) {							# upcast shear
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   194
			$uc_uz[$r] = $ants_[0][$uc_uzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   195
			$uc_vz[$r] = $ants_[0][$uc_vzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   196
			$uc_wz[$r] = $ants_[0][$uc_wzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   197
		} else {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   198
			$uc_uz[$r] = $uc_vz[$r] = $uc_wz[$r] = nan;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   199
	    }
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   200
    }
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   201
    
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   202
	if ($nsamp[$r] > 0) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   203
		my($dcf) = $dc_nsamp / $nsamp[$r];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   204
		my($ucf) = $uc_nsamp / $nsamp[$r];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   205
		if ($dcf>0 && $ucf>0) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   206
			$uz[$r] = $dcf*$dc_uz[$r] + $ucf*$uc_uz[$r];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   207
			$vz[$r] = $dcf*$dc_vz[$r] + $ucf*$uc_vz[$r];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   208
            $wz[$r] = $dcf*$dc_wz[$r] + $ucf*$uc_wz[$r];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   209
        } elsif ($dcf > 0) {
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   210
			$uz[$r] = $dc_uz[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   211
			$vz[$r] = $dc_vz[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   212
			$wz[$r] = $dc_wz[$r];
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   213
        } else {
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   214
			$uz[$r] = $uc_uz[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   215
			$vz[$r] = $uc_vz[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   216
			$wz[$r] = $uc_wz[$r];
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   217
        }
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   218
	} else {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   219
		$uz[$r] = $vz[$r] = $wz[$r] = nan;
0
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 (numberp($uz[$r]) && $curGap>0) {						# end of gap
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   223
		push(@gaps,$curGap)	unless ($r == $curGap);				# do not report "gap" at beginning of profile
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   224
#		print(STDERR "$curGap-gap at $depth[$r]m\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   225
		$curGap = 0;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   226
    } elsif (!numberp($uz[$r])) {								# currently in gap
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   227
#    	print(STDERR "in gap at $depth[$r]m (nsamp = $nsamp[$r], $dc_nsamp,$uc_nsamp)\n");
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   228
		$curGap++;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   229
    }
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   230
	
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   231
	if ($nsamp[$r] > 0) {
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   232
		if (defined($opt_u)) {
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   233
			$uzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_uzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   234
							           $UL_[$dc_nshF],     $UL_[$dc_uzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   235
							      $ants_[0][$uc_nshF],$ants_[0][$uc_uzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   236
							           $UL_[$uc_nshF],     $UL_[$uc_uzsF]);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   237
			$vzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_vzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   238
									   $UL_[$dc_nshF],     $UL_[$dc_vzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   239
							      $ants_[0][$uc_nshF],$ants_[0][$uc_vzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   240
									   $UL_[$uc_nshF],     $UL_[$uc_vzsF]);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   241
			$wzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_wzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   242
									   $UL_[$dc_nshF],     $UL_[$dc_wzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   243
							      $ants_[0][$uc_nshF],$ants_[0][$uc_wzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   244
	                                   $UL_[$uc_nshF],     $UL_[$uc_wzsF]);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   245
		} else { # DL only
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   246
			$uzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_uzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   247
							      $ants_[0][$uc_nshF],$ants_[0][$uc_uzsF]);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   248
			$vzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_vzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   249
							      $ants_[0][$uc_nshF],$ants_[0][$uc_vzsF]);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   250
			$wzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_wzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   251
	                              $ants_[0][$uc_nshF],$ants_[0][$uc_wzsF]);
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   252
	    }
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   253
	} else {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   254
		$uzsig[$r] = $vzsig[$r] = $wzsig[$r] = nan;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   255
	}
5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   256
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   257
	if ($dc_nsamp > 0) {									# same calc for downcast only
5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   258
		if (defined($opt_u)) {
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   259
			$dc_uzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_uzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   260
							              $UL_[$dc_nshF],     $UL_[$dc_uzsF]);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   261
			$dc_vzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_vzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   262
							              $UL_[$dc_nshF],     $UL_[$dc_vzsF]);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   263
			$dc_wzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_wzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   264
							              $UL_[$dc_nshF],     $UL_[$dc_wzsF]);
5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   265
		} else {
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   266
			$dc_uzsig[$r] = $ants_[0][$dc_uzsF];
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   267
			$dc_vzsig[$r] = $ants_[0][$dc_vzsF];
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   268
			$dc_wzsig[$r] = $ants_[0][$dc_wzsF];
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   269
	    }
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   270
	} else {
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   271
		$uzsig[$r] = $vzsig[$r] = $wzsig[$r] = nan;
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   272
	}
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   273
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   274
	if ($uc_nsamp > 0) {									# same calc for upcast only
5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   275
		if (defined($opt_u)) {
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   276
			$uc_uzsig[$r] = wavg_sig($ants_[0][$uc_nshF],$ants_[0][$uc_uzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   277
							              $UL_[$uc_nshF],     $UL_[$uc_uzsF]);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   278
			$uc_vzsig[$r] = wavg_sig($ants_[0][$uc_nshF],$ants_[0][$uc_vzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   279
							              $UL_[$uc_nshF],     $UL_[$uc_vzsF]);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   280
			$uc_wzsig[$r] = wavg_sig($ants_[0][$uc_nshF],$ants_[0][$uc_wzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   281
							              $UL_[$uc_nshF],     $UL_[$uc_wzsF]);
5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   282
		} else {
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   283
			$uc_uzsig[$r] = $ants_[0][$uc_uzsF];
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   284
			$uc_vzsig[$r] = $ants_[0][$uc_vzsF];
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   285
			$uc_wzsig[$r] = $ants_[0][$uc_wzsF];
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   286
	    }
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   287
	} else {
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   288
		$uzsig[$r] = $vzsig[$r] = $wzsig[$r] = nan;
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   289
	}
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   290
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   291
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   292
if (@gaps) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   293
	&antsAddParams('shear_gaps',"@gaps");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   294
	print(STDERR "shear gaps: @gaps\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   295
} else {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   296
	&antsAddParams('shear_gaps',0);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   297
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   298
	
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   299
#===============================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   300
# Step 2: Low-Pass filter high-quality shear data; not yet implemented
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   301
#===============================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   302
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   303
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   304
# Step 3: Integrate Shear
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   305
#	- z(vel) = z(sh) + DZ/2
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   306
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   307
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   308
my($DZ) = $depth[1] - $depth[0];
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   309
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   310
for (my($r)=my($u)=my($v)=my($w)=my($dc_u)=my($dc_v)=my($dc_w)=my($uc_u)=my($uc_v)=my($uc_w)=0;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   311
	 $r<@depth; $r++) {
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   312
	if ($nsamp[$r] >= $opt_n) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   313
		$u = $u[$r] = $u + $DZ*$uz[$r];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   314
		$v = $v[$r] = $v + $DZ*$vz[$r];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   315
		$w = $w[$r] = $w + $DZ*$wz[$r];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   316
	}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   317
	if ($dc_nsamp[$r] >= $opt_n) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   318
		$dc_u = $dc_u[$r] = $dc_u + $DZ*$dc_uz[$r];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   319
		$dc_v = $dc_v[$r] = $dc_v + $DZ*$dc_vz[$r];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   320
		$dc_w = $dc_w[$r] = $dc_w + $DZ*$dc_wz[$r];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   321
	}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   322
	if ($uc_nsamp[$r] >= $opt_n) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   323
		$uc_u = $uc_u[$r] = $uc_u + $DZ*$uc_uz[$r];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   324
		$uc_v = $uc_v[$r] = $uc_v + $DZ*$uc_vz[$r];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   325
		$uc_w = $uc_w[$r] = $uc_w + $DZ*$uc_wz[$r];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   326
	}
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   327
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   328
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   329
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   330
# Step 4: Reference Velocities
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   331
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   332
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   333
my($refU,$refV,$refW,$dc_refU,$dc_refV,$dc_refW,$uc_refU,$uc_refV,$uc_refW);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   334
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   335
if (defined($opt_b)) {											# reference to bottom-track profile
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   336
	print(STDERR "Loading BT data from $opt_b...\n")
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   337
		if ($opt_d);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   338
	open(BTF,$opt_b) || croak("$opt_b: $!\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   339
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   340
	my(@BTL) = &antsFileLayout(BTF);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   341
	my($BTdF,$BTndF,$BTuF,$BTvF,$BTwF,$BTusF,$BTvsF,$BTwsF);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   342
	for (my($f)=0; $f<@BTL; $f++) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   343
		$BTdF = $f if ($BTL[$f] eq 'depth');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   344
		$BTuF = $f if ($BTL[$f] eq 'u');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   345
		$BTvF = $f if ($BTL[$f] eq 'v');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   346
		$BTwF = $f if ($BTL[$f] eq 'w');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   347
		$BTusF = $f if ($BTL[$f] eq 'u.sig');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   348
		$BTvsF = $f if ($BTL[$f] eq 'v.sig');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   349
		$BTwsF = $f if ($BTL[$f] eq 'w.sig');
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   350
		$BTndF = $f if ($BTL[$f] eq 'nsamp');
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   351
	}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   352
	croak("$opt_b: not a valid BT file\n")
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   353
		unless defined($BTdF) && defined($BTuF) && defined($BTvF) && defined($BTwF) &&
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   354
			   defined($BTusF) && defined($BTvsF) && defined($BTwsF) && defined($BTndF);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   355
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   356
	while (my(@BTr) = &antsFileIn(BTF)) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   357
		my($gi) = int($BTr[$BTdF] / $DZ);
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   358
		next unless ($BTr[$BTndF] >= $opt_m);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   359
		$BT_nsamp[$gi] = $BTr[$BTndF];
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   360
		$BT_u[$gi] = $BTr[$BTuF];
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   361
		$BT_v[$gi] = $BTr[$BTvF];
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   362
		$BT_w[$gi] = $BTr[$BTwF];
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   363
		$BT_u_var[$gi] = $BTr[$BTusF]**2;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   364
		$BT_v_var[$gi] = $BTr[$BTvsF]**2;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   365
		$BT_w_var[$gi] = $BTr[$BTwsF]**2;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   366
	}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   367
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   368
	&fixLowSampStat(\@BT_u_var,@BT_nsamp);					# remove spurious small variances
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   369
	&fixLowSampStat(\@BT_v_var,@BT_nsamp);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   370
	&fixLowSampStat(\@BT_w_var,@BT_nsamp);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   371
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   372
	my($sumU,$sumV,$sumW,$dc_sumU,$dc_sumV,$dc_sumW,		# average integrated-shear velocities
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   373
	   $uc_sumU,$uc_sumV,$uc_sumW);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   374
	my($nSumVel,$dc_nSumVel,$uc_nSumVel);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   375
	my($wSumBTu,$wSumBTv,$wSumBTw);							# weighted sums of BT-ref'd velocities
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   376
	my($dc_wSumBTu,$dc_wSumBTv,$dc_wSumBTw);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   377
	my($uc_wSumBTu,$uc_wSumBTv,$uc_wSumBTw);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   378
	my($sumVarBTu,$sumVarBTv,$sumVarBTw);					# sum of variances of BT-ref'd vels
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   379
	my($dc_sumVarBTu,$dc_sumVarBTv,$dc_sumVarBTw);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   380
	my($uc_sumVarBTu,$uc_sumVarBTv,$uc_sumVarBTw);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   381
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   382
	for (my($r)=0; $r<@depth; $r++) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   383
		if (numberp($BT_u[$r]) && numberp($u[$r])) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   384
			$nSumVel++;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   385
			$sumU += $u[$r]; $sumV += $v[$r]; $sumW += $w[$r];
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   386
			$wSumBTu += $BT_u[$r] / $BT_u_var[$r]; $sumVarBTu += 1/$BT_u_var[$r];
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   387
#			printf(STDERR "v = $BT_v[$r] (w = %.1f)\n",1/$BT_v_var[$r]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   388
			$wSumBTv += $BT_v[$r] / $BT_v_var[$r]; $sumVarBTv += 1/$BT_v_var[$r];
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   389
			$wSumBTw += $BT_w[$r] / $BT_w_var[$r]; $sumVarBTw += 1/$BT_w_var[$r];
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   390
		}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   391
		if (numberp($BT_u[$r]) && numberp($dc_u[$r])) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   392
			$dc_nSumVel++;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   393
			$dc_sumU += $dc_u[$r]; $dc_sumV += $dc_v[$r]; $dc_sumW += $dc_w[$r];
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   394
			$dc_wSumBTu += $BT_u[$r] / $BT_u_var[$r]; $dc_sumVarBTu += 1/$BT_u_var[$r];
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   395
			$dc_wSumBTv += $BT_v[$r] / $BT_v_var[$r]; $dc_sumVarBTv += 1/$BT_v_var[$r];
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   396
			$dc_wSumBTw += $BT_w[$r] / $BT_w_var[$r]; $dc_sumVarBTw += 1/$BT_w_var[$r];
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   397
		}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   398
		if (numberp($BT_u[$r]) && numberp($uc_u[$r])) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   399
			$uc_nSumVel++;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   400
			$uc_sumU += $uc_u[$r]; $uc_sumV += $uc_v[$r]; $uc_sumW += $uc_w[$r];
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   401
			$uc_wSumBTu += $BT_u[$r] / $BT_u_var[$r]; $uc_sumVarBTu += 1/$BT_u_var[$r];
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   402
			$uc_wSumBTv += $BT_v[$r] / $BT_v_var[$r]; $uc_sumVarBTv += 1/$BT_v_var[$r];
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   403
			$uc_wSumBTw += $BT_w[$r] / $BT_w_var[$r]; $uc_sumVarBTw += 1/$BT_w_var[$r];
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   404
		}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   405
	}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   406
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   407
	if ($nSumVel > 0) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   408
		$refU = $sumU/$nSumVel - $wSumBTu/$sumVarBTu;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   409
		$refV = $sumV/$nSumVel - $wSumBTv/$sumVarBTv;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   410
		$refW = $sumW/$nSumVel - $wSumBTw/$sumVarBTw;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   411
	    
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   412
		if ($dc_nSumVel > 0) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   413
			$dc_refU = $dc_sumU/$dc_nSumVel - $dc_wSumBTu/$dc_sumVarBTu;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   414
			$dc_refV = $dc_sumV/$dc_nSumVel - $dc_wSumBTv/$dc_sumVarBTv;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   415
			$dc_refW = $dc_sumW/$dc_nSumVel - $dc_wSumBTw/$dc_sumVarBTw;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   416
		} else {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   417
			&antsInfo("$opt_b: insufficient BT data to constrain dc profile --- baroclinic profile only");
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   418
		}
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   419
	    
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   420
		if ($uc_nSumVel > 0) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   421
			$uc_refU = $uc_sumU/$uc_nSumVel - $uc_wSumBTu/$uc_sumVarBTu;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   422
			$uc_refV = $uc_sumV/$uc_nSumVel - $uc_wSumBTv/$uc_sumVarBTv;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   423
		    $uc_refW = $uc_sumW/$uc_nSumVel - $uc_wSumBTw/$uc_sumVarBTw;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   424
		} else {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   425
			&antsInfo("$opt_b: insufficient BT data to constrain dc profile --- baroclinic profile only");
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   426
		}
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   427
	} else {
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   428
		&antsInfo("$opt_b: no valid BT data --- baroclinic profiles only");
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   429
	}
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   430
}
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   431
5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   432
unless (defined($refU)) {									# no reference velocity => use zero mean
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   433
	my($sumU,$sumV,$sumW,$nSumVel);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   434
	for (my($r)=0; $r<@depth; $r++) {
2
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   435
		if (numberp($u[$r])) {
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   436
			$nSumVel++;
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   437
			$sumU += $u[$r]; $sumV += $v[$r]; $sumW += $w[$r];
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   438
        }
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   439
    }
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   440
	$refU = $sumU / $nSumVel; $refV = $sumV / $nSumVel; $refW = $sumW / $nSumVel;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   441
}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   442
unless (defined($dc_refU)) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   443
	my($dc_sumU,$dc_sumV,$dc_sumW,$dc_nSumVel);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   444
	for (my($r)=0; $r<@depth; $r++) {
2
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   445
        if (numberp($dc_u[$r])) {
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   446
			$dc_nSumVel++;
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   447
			$dc_sumU += $dc_u[$r]; $dc_sumV += $dc_v[$r]; $dc_sumW += $dc_w[$r];
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   448
		}
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   449
	}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   450
	$dc_refU = $dc_sumU / $dc_nSumVel; $dc_refV = $dc_sumV / $dc_nSumVel; $dc_refW = $dc_sumW / $dc_nSumVel;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   451
}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   452
unless (defined($uc_refU)) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   453
	my($uc_sumU,$uc_sumV,$uc_sumW,$uc_nSumVel);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   454
	for (my($r)=0; $r<@depth; $r++) {
2
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   455
        if (numberp($uc_u[$r])) {
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   456
			$uc_nSumVel++;
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   457
			$uc_sumU += $uc_u[$r]; $uc_sumV += $uc_v[$r]; $uc_sumW += $uc_w[$r];
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   458
		}
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   459
	}
2
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   460
	$uc_refU = $uc_sumU / $uc_nSumVel; $uc_refV = $uc_sumV / $uc_nSumVel; $uc_refW = $uc_sumW / $uc_nSumVel;
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   461
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   462
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   463
for (my($r)=0; $r<@depth; $r++) {							# reference velocities
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   464
	$u[$r] -= $refU if defined($u[$r]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   465
	$v[$r] -= $refV if defined($v[$r]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   466
	$w[$r] -= $refW if defined($w[$r]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   467
	$dc_u[$r] -= $dc_refU if defined($dc_u[$r]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   468
	$dc_v[$r] -= $dc_refV if defined($dc_v[$r]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   469
	$dc_w[$r] -= $dc_refW if defined($dc_w[$r]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   470
	$uc_u[$r] -= $uc_refU if defined($uc_u[$r]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   471
	$uc_v[$r] -= $uc_refV if defined($uc_v[$r]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   472
	$uc_w[$r] -= $uc_refW if defined($uc_w[$r]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   473
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   474
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   475
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   476
# Determine X Factor
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   477
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   478
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   479
my($first_w,$last_w);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   480
for (my($r)=0; !defined($first_w) || !defined($last_w); $r++) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   481
	$first_w = $dc_w[$r] unless defined($first_w);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   482
	$last_w  = $uc_w[$r] unless defined($last_w);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   483
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   484
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   485
my($X_Factor) = 100 * abs($last_w-$first_w) / sqrt(@depth / $DZ);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   486
&antsAddParams('X-Factor',$X_Factor);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   487
printf(STDERR "X-Factor = %.1f\n",$X_Factor);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   488
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   489
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   490
# Output Velocity Profile
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   491
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   492
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   493
@antsNewLayout = ('depth','u','v','w','nsamp',
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   494
				  'dc_u','dc_v','dc_w','dc_nsamp',
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   495
				  'uc_u','uc_v','uc_w','uc_nsamp');
5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   496
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   497
for (my($r)=0; $r<@depth; $r++) {
5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   498
	&antsOut($depth[$r]+$DZ/2,
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   499
			 $u[$r],$v[$r],$w[$r],$nsamp[$r],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   500
			 $dc_u[$r],$dc_v[$r],$dc_w[$r],$dc_nsamp[$r],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   501
			 $uc_u[$r],$uc_v[$r],$uc_w[$r],$uc_nsamp[$r]);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   502
}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   503
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   504
#======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   505
# Output Averaged Shear Profile
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   506
#======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   507
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   508
if (defined($opt_s)) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   509
	@antsNewLayout = ('depth','u_z','v_z','w_z','u_z.sig','v_z.sig','w_z.sig','nsamp',
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   510
							  'dc_u_z','dc_v_z','dc_w_z','dc_u_z.sig','dc_v_z.sig','dc_w_z.sig','dc_nsamp',
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   511
							  'uc_u_z','uc_v_z','uc_w_z','uc_u_z.sig','uc_v_z.sig','uc_w_z.sig','uc_nsamp');
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   512
	&antsOut('EOF');
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   513
    close(STDOUT);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   514
	open(STDOUT,">$opt_s") || croak("$opt_s: $!\n");
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   515
	for (my($r)=0; $r<@depth; $r++) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   516
		&antsOut($depth[$r],$uz[$r],$vz[$r],$wz[$r],$uzsig[$r],$vzsig[$r],$wzsig[$r],$nsamp[$r],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   517
			     $dc_uz[$r],$dc_vz[$r],$dc_wz[$r],$dc_uzsig[$r],$dc_vzsig[$r],$dc_wzsig[$r],$dc_nsamp[$r],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   518
			     $uc_uz[$r],$uc_vz[$r],$uc_wz[$r],$uc_uzsig[$r],$uc_vzsig[$r],$uc_wzsig[$r],$uc_nsamp[$r]);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   519
	}
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   520
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   521
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   522
&antsExit();