LADCPintsh
author A.M. Thurnherr <ant@ldeo.columbia.edu>
Sat, 09 Jul 2011 15:14:10 -0400
changeset 3 711dd29cb6dd
parent 2 16726a31a399
child 5 fa82bdf18b43
permissions -rwxr-xr-x
post 2011_IWISE
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
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
     5
#                    dlm: Thu Jul  7 06:30:50 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
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
     7
#                    uE-Info: 32 28 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:
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    13
#	- THE CORE OF THIS CODE IS A SIMPLE TRANSCRIPTION OF AVG_SH.M AND INT_SH.M WRITTEN BY ERIC FIRING
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    14
#	- comments beginning with ## are taken from Eric's code
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    15
#	- cubic velocity interpolation across PPI gap from Eric's code has not been implemented (yet?)
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    16
#	- Eric's ndata criteria had to be scaled by 5/8 due to the different gridding used; I decided,
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    17
#	  conservatively, to scale only the -s criterion (n1 in Eric's code)
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    18
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    19
# WEIRDNESSES:
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    20
#	- 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
    21
#	  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
    22
#	  is not used anywhere in Eric's code
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    23
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    24
# HISTORY:
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    25
#	Oct 14, 2010: - created
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    26
#	Oct 20, 2010: - first working version
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    27
#	Oct 23, 2010: - added support for -b)
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    28
#	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
    29
#					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
    30
#	Dec  9, 2010: - allowed for empty BT file
2
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
    31
#	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
    32
#	Jul  7, 2011: - added -m
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
($ANTS) = (`which list` =~ m{^(.*)/[^/]*$});
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    35
require "$ANTS/ants.pl";
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    36
require "$ANTS/libstats.pl";
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    37
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
    38
&antsUsage('b:dm:r:s:w:u:',0,
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    39
	'[-d)ebug]',
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
    40
	'[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
    41
	'[-u)plooker <file>]',
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    42
	'[min -r)aw <shear samp[10]>] [min -s)moothed <shear samp[20]>]',
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    43
	'[-w)eighted avg <below[1200]>]',
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    44
	'[LADCP shear file]');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    45
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
    46
croak("$0: -m requires -b\n")
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
    47
	if defined($opt_m) && !defined($opt_b);
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
    48
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    49
&antsCardOpt(\$opt_r,10);	## minimum number of samples for shear
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
    50
&antsCardOpt(\$opt_m,10);	# minimum number of samples for BT data
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    51
&antsCardOpt(\$opt_s,20);	## minimum number of samples for smoothed shear
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    52
&antsCardOpt(\$opt_w,1200);	## probably 1200 for midlatitude-equatorial, 2400 for high lat
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
    53
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
    54
&antsFileOpt($opt_b);		# BT file
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
    55
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
    56
&antsFileOpt($opt_u);		# UL shear file
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
    57
open(ULF,$opt_u) || croak("$opt_u: $!\n")
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
    58
	if defined($opt_u);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    59
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    60
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    61
# Step 1: Read and Average Shear Data
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    62
#	- depth bins with less than $opt_r values are blanked out
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    63
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    64
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    65
$depthF = fnr('depth');				# layout of [LADCPproc] output
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    66
$dc_nshF = fnr('dc_nshear');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    67
$dc_uzF  = fnr('dc_u_z');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    68
$dc_uzsF = fnrNoErr('dc_u_z.sig');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    69
$dc_uzsF = fnr('dc_u_z_sig')
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    70
	unless defined($dc_uzsF);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    71
$dc_vzF  = fnr('dc_v_z');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    72
$dc_vzsF = fnrNoErr('dc_v_z.sig');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    73
$dc_vzsF = fnr('dc_v_z_sig')
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    74
	unless defined($dc_vzsF);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    75
$dc_wzF  = fnr('dc_w_z');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    76
$dc_wzsF = fnrNoErr('dc_w_z.sig');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    77
$dc_wzsF = fnr('dc_w_z_sig')
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    78
	unless defined($dc_wzsF);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    79
$uc_nshF = fnr('uc_nshear');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    80
$uc_uzF  = fnr('uc_u_z');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    81
$uc_uzsF = fnrNoErr('uc_u_z.sig');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    82
$uc_uzsF = fnr('uc_u_z_sig')
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    83
	unless defined($uc_uzsF);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    84
$uc_vzF  = fnr('uc_v_z');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    85
$uc_vzsF = fnrNoErr('uc_v_z.sig');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    86
$uc_vzsF = fnr('uc_v_z_sig')
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    87
	unless defined($uc_vzsF);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    88
$uc_wzF  = fnr('uc_w_z');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    89
$uc_wzsF = fnrNoErr('uc_w_z.sig');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    90
$uc_wzsF = fnr('uc_w_z_sig')
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    91
	unless defined($uc_wzsF);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    92
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    93
my(@gaps); my($curGap) = 0;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    94
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
    95
for (my($r)=0; &antsIn(); $r++) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
    96
	my(@UL_);
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
    97
	if (defined($opt_u)) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
    98
		@UL_ = &antsFileIn(ULF);						# read UL shear data
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
    99
		undef($opt_u) unless (@UL_);					# cheap trick
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   100
	}
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   101
	
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   102
	$depth[$r] = $ants_[0][$depthF];						## depth grid values
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   103
	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
   104
		if defined($opt_u) && ($UL_[$depthF] != $depth[$r]);
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   105
		
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   106
	$dc_ndata = $ants_[0][$dc_nshF];						# number of shear samples
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   107
	$uc_ndata = $ants_[0][$uc_nshF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   108
	if (defined($opt_u)) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   109
		$dc_ndata += $UL_[$dc_nshF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   110
		$uc_ndata += $UL_[$uc_nshF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   111
	}
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   112
	$ndata[$r] = $dc_ndata + $uc_ndata;
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   113
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   114
	if (defined($opt_u)) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   115
		if ($dc_ndata > 0) {								# downcast shear
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   116
			my($DLf) = $ants_[0][$dc_nshF] / $dc_ndata;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   117
			my($ULf) =      $UL_[$dc_nshF] / $dc_ndata;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   118
			if ($DLf>0 && $Ulf>0) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   119
				$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
   120
				$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
   121
	            $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
   122
	        } elsif ($DLf > 0) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   123
				$dc_uz[$r] = $ants_[0][$dc_uzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   124
				$dc_vz[$r] = $ants_[0][$dc_vzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   125
				$dc_wz[$r] = $ants_[0][$dc_wzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   126
	        } else {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   127
				$dc_uz[$r] = $UL_[$dc_uzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   128
				$dc_vz[$r] = $UL_[$dc_vzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   129
				$dc_wz[$r] = $UL_[$dc_wzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   130
	        }
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   131
		} else {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   132
			$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
   133
	    }
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   134
		if ($uc_ndata > 0) {								# upcast shear
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   135
			my($DLf) = $ants_[0][$uc_nshF] / $uc_ndata;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   136
			my($ULf) =      $UL_[$uc_nshF] / $uc_ndata;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   137
			if ($DLf>0 && $Ulf>0) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   138
				$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
   139
				$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
   140
				$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
   141
	        } elsif ($DLf > 0) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   142
				$uc_uz[$r] = $ants_[0][$uc_uzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   143
				$uc_vz[$r] = $ants_[0][$uc_vzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   144
				$uc_wz[$r] = $ants_[0][$uc_wzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   145
	        } else {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   146
				$uc_uz[$r] = $UL_[$uc_uzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   147
				$uc_vz[$r] = $UL_[$uc_vzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   148
				$uc_wz[$r] = $UL_[$uc_wzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   149
	        }
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   150
		} else {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   151
			$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
   152
	    }
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   153
	} else {
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   154
		if ($dc_ndata >= $opt_r) {							# downcast shear
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] = $dc_vz[$r] = $dc_wz[$r] = nan;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   160
	    }
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   161
		if ($uc_ndata >= $opt_r) {							# upcast shear
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   162
			$uc_uz[$r] = $ants_[0][$uc_uzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   163
			$uc_vz[$r] = $ants_[0][$uc_vzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   164
			$uc_wz[$r] = $ants_[0][$uc_wzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   165
		} else {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   166
			$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
   167
	    }
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   168
    }
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   169
    
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   170
	if ($depth[$r] < $opt_w) {			## use average of up and down casts at top of profile
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   171
		if ($dc_ndata>0 && $uc_ndata>0 && $ndata[$r]>=$opt_r) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   172
			$uz[$r] = $dc_uz[$r]/2 + $uc_uz[$r]/2;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   173
			$vz[$r] = $dc_vz[$r]/2 + $uc_vz[$r]/2;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   174
			$wz[$r] = $dc_wz[$r]/2 + $uc_wz[$r]/2;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   175
		} elsif ($dc_ndata >= $opt_r) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   176
			$uz[$r] = $dc_uz[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   177
			$vz[$r] = $dc_vz[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   178
			$wz[$r] = $dc_wz[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   179
		} elsif ($uc_ndata >= $opt_r) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   180
			$uz[$r] = $uc_uz[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   181
			$vz[$r] = $uc_vz[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   182
			$wz[$r] = $uc_wz[$r];
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   183
		} else {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   184
			$uz[$r] = $vz[$r] = $wz[$r] = nan;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   185
		}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   186
	} else {							## use weighted average of up and down cast data at bottom of profile
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   187
		if ($ndata[$r] >= $opt_r) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   188
			my($dcf) = $dc_ndata / $ndata[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   189
			my($ucf) = $uc_ndata / $ndata[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   190
			if ($dcf>0 && $ucf>0) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   191
				$uz[$r] = $dcf*$dc_uz[$r] + $ucf*$uc_uz[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   192
				$vz[$r] = $dcf*$dc_vz[$r] + $ucf*$uc_vz[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   193
	            $wz[$r] = $dcf*$dc_wz[$r] + $ucf*$uc_wz[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   194
	        } elsif ($dcf > 0) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   195
				$uz[$r] = $dc_uz[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   196
				$vz[$r] = $dc_vz[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   197
				$wz[$r] = $dc_wz[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   198
	        } else {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   199
				$uz[$r] = $uc_uz[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   200
				$vz[$r] = $uc_vz[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   201
				$wz[$r] = $uc_wz[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   202
	        }
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   203
		} else {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   204
			$uz[$r] = $vz[$r] = $wz[$r] = nan;
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
	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
   209
		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
   210
#		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
   211
		$curGap = 0;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   212
    } elsif (!numberp($uz[$r])) {								# currently in gap
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   213
#    	print(STDERR "in gap at $depth[$r]m (ndata = $ndata[$r], $dc_ndata,$uc_ndata)\n");
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   214
		$curGap++;
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
	if ($ndata[$r] >= $opt_r) {									## back to sum of squares
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   218
		if (defined($opt_u)) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   219
			$uzsig[$r] = sqrt(($ants_[0][$dc_nshF] * $ants_[0][$dc_uzsF]**2 +
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   220
							        $UL_[$dc_nshF] *      $UL_[$dc_uzsF]**2 +
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   221
							   $ants_[0][$uc_nshF] * $ants_[0][$uc_uzsF]**2 +
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   222
							        $UL_[$uc_nshF] *      $UL_[$uc_uzsF]**2) / $ndata[$r]);
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   223
			$vzsig[$r] = sqrt(($ants_[0][$dc_nshF] * $ants_[0][$dc_vzsF]**2 +
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   224
							        $UL_[$dc_nshF] *      $UL_[$dc_vzsF]**2   +
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   225
							   $ants_[0][$uc_nshF] * $ants_[0][$uc_vzsF]**2 +
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   226
							        $UL_[$uc_nshF] *      $UL_[$uc_vzsF]**2) / $ndata[$r]);
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   227
			$wzsig[$r] = sqrt(($ants_[0][$dc_nshF] * $ants_[0][$dc_wzsF]**2 +
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   228
							        $UL_[$dc_nshF] *      $UL_[$dc_wzsF]**2   +
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   229
							   $ants_[0][$uc_nshF] * $ants_[0][$uc_wzsF]**2 +
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   230
							        $UL_[$uc_nshF] *      $UL_[$uc_wzsF]**2) / $ndata[$r]);
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   231
		} else {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   232
			$uzsig[$r] = sqrt(($ants_[0][$dc_nshF] * $ants_[0][$dc_uzsF]**2 +
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   233
							   $ants_[0][$uc_nshF] * $ants_[0][$uc_uzsF]**2) / $ndata[$r]);
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   234
			$vzsig[$r] = sqrt(($ants_[0][$dc_nshF] * $ants_[0][$dc_vzsF]**2 +
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   235
							   $ants_[0][$uc_nshF] * $ants_[0][$uc_vzsF]**2) / $ndata[$r]);
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   236
			$wzsig[$r] = sqrt(($ants_[0][$dc_nshF] * $ants_[0][$dc_wzsF]**2 +
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   237
	                           $ants_[0][$uc_nshF] * $ants_[0][$uc_wzsF]**2) / $ndata[$r]);
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   238
	    }
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   239
	} else {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   240
		$uzsig[$r] = $vzsig[$r] = $wzsig[$r] = nan;
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
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   243
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   244
if (@gaps) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   245
	&antsAddParams('shear_gaps',"@gaps");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   246
	print(STDERR "shear gaps: @gaps\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   247
} else {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   248
	&antsAddParams('shear_gaps',0);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   249
}
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
# 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
   253
#===============================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   254
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   255
for (my($r)=0; $r<@depth; $r++) {					# create high-quality shear profile
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   256
	if ($ndata[$r] >= $opt_s) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   257
		$hq_uz[$r] = $uz[$r]; $hq_vz[$r] = $vz[$r]; $hq_wz[$r] = $wz[$r];
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   258
	} else {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   259
		$hq_uz[$r] = $hq_vz[$r] = $hq_wz[$r] = nan;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   260
	}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   261
}
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
#@antsNewLayout = ('depth','u_z','hq_u_z','v_z','hq_v_z','w_z','hq_w_z');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   264
#for (my($r)=0; $r<@depth; $r++) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   265
#	&antsOut($depth[$r],$uz[$r],$hq_uz[$r],$vz[$r],$hq_vz[$r],$wz[$r],$hq_wz[$r]);
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
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   268
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   269
# Step 3: Integrate Shear
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   270
#	- z(vel) = z(sh) + DZ/2
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   271
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   272
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   273
my($DZ) = $depth[1] - $depth[0];
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   274
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   275
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
   276
	 $r<@depth; $r++) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   277
	$u = $u[$r] = $u + $DZ*$uz[$r] if numberp($uz[$r]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   278
	$v = $v[$r] = $v + $DZ*$vz[$r] if numberp($vz[$r]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   279
	$w = $w[$r] = $w + $DZ*$wz[$r] if numberp($wz[$r]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   280
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   281
	$dc_u = $dc_u[$r] = $dc_u + $DZ*$dc_uz[$r] if numberp($dc_uz[$r]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   282
	$dc_v = $dc_v[$r] = $dc_v + $DZ*$dc_vz[$r] if numberp($dc_vz[$r]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   283
	$dc_w = $dc_w[$r] = $dc_w + $DZ*$dc_wz[$r] if numberp($dc_wz[$r]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   284
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   285
	$uc_u = $uc_u[$r] = $uc_u + $DZ*$uc_uz[$r] if numberp($uc_uz[$r]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   286
	$uc_v = $uc_v[$r] = $uc_v + $DZ*$uc_vz[$r] if numberp($uc_vz[$r]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   287
	$uc_w = $uc_w[$r] = $uc_w + $DZ*$uc_wz[$r] if numberp($uc_wz[$r]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   288
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   289
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
# Step 4: Reference Velocities
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   292
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   293
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   294
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
   295
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   296
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
   297
	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
   298
		if ($opt_d);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   299
	open(BTF,$opt_b) || croak("$opt_b: $!\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   300
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   301
	my(@BTL) = &antsFileLayout(BTF);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   302
	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
   303
	for (my($f)=0; $f<@BTL; $f++) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   304
		$BTdF = $f if ($BTL[$f] eq 'depth');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   305
		$BTuF = $f if ($BTL[$f] eq 'u');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   306
		$BTvF = $f if ($BTL[$f] eq 'v');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   307
		$BTwF = $f if ($BTL[$f] eq 'w');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   308
		$BTusF = $f if ($BTL[$f] eq 'u.sig');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   309
		$BTvsF = $f if ($BTL[$f] eq 'v.sig');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   310
		$BTwsF = $f if ($BTL[$f] eq 'w.sig');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   311
		$BTndF = $f if ($BTL[$f] eq 'ndata');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   312
	}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   313
	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
   314
		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
   315
			   defined($BTusF) && defined($BTvsF) && defined($BTwsF) && defined($BTndF);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   316
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   317
	while (my(@BTr) = &antsFileIn(BTF)) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   318
		my($gi) = int($BTr[$BTdF] / $DZ);
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
   319
		next unless ($BTr[$BTndF] >= $opt_m);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   320
		$BT_nsamp[$gi] = $BTr[$BTndF];
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   321
		$BT_u[$gi] = $BTr[$BTuF];
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   322
		$BT_v[$gi] = $BTr[$BTvF];
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   323
		$BT_w[$gi] = $BTr[$BTwF];
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   324
		$BT_u_var[$gi] = $BTr[$BTusF]**2;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   325
		$BT_v_var[$gi] = $BTr[$BTvsF]**2;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   326
		$BT_w_var[$gi] = $BTr[$BTwsF]**2;
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
	&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
   330
	&fixLowSampStat(\@BT_v_var,@BT_nsamp);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   331
	&fixLowSampStat(\@BT_w_var,@BT_nsamp);
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($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
   334
	   $uc_sumU,$uc_sumV,$uc_sumW);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   335
	my($nSumVel,$dc_nSumVel,$uc_nSumVel);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   336
	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
   337
	my($dc_wSumBTu,$dc_wSumBTv,$dc_wSumBTw);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   338
	my($uc_wSumBTu,$uc_wSumBTv,$uc_wSumBTw);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   339
	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
   340
	my($dc_sumVarBTu,$dc_sumVarBTv,$dc_sumVarBTw);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   341
	my($uc_sumVarBTu,$uc_sumVarBTv,$uc_sumVarBTw);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   342
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   343
	for (my($r)=0; $r<@depth; $r++) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   344
		if (numberp($BT_u[$r]) && numberp($u[$r])) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   345
			$nSumVel++;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   346
			$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
   347
			$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
   348
#			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
   349
			$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
   350
			$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
   351
		}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   352
		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
   353
			$dc_nSumVel++;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   354
			$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
   355
			$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
   356
			$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
   357
			$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
   358
		}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   359
		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
   360
			$uc_nSumVel++;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   361
			$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
   362
			$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
   363
			$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
   364
			$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
   365
		}
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
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   368
	if ($nSumVel > 0) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   369
		$refU = $sumU/$nSumVel - $wSumBTu/$sumVarBTu;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   370
		$refV = $sumV/$nSumVel - $wSumBTv/$sumVarBTv;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   371
		$refW = $sumW/$nSumVel - $wSumBTw/$sumVarBTw;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   372
	    
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   373
		$dc_refU = $dc_sumU/$dc_nSumVel - $dc_wSumBTu/$dc_sumVarBTu;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   374
		$dc_refV = $dc_sUmV/$dc_nSumVel - $dc_wSumBTv/$dc_sumVarBTv;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   375
		$dc_refW = $dc_sumW/$dc_nSumVel - $dc_wSumBTw/$dc_sumVarBTw;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   376
	    
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   377
		$uc_refU = $uc_sumU/$uc_nSumVel - $uc_wSumBTu/$uc_sumVarBTu;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   378
		$uc_refV = $uc_sUmV/$uc_nSumVel - $uc_wSumBTv/$uc_sumVarBTv;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   379
	    $uc_refW = $uc_sumW/$uc_nSumVel - $uc_wSumBTw/$uc_sumVarBTw;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   380
	} else {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   381
		&antsInfo("$opt_b: no valid BT data --- calculating baroclinic solution only");
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   382
	}
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   383
}
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   384
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   385
unless (defined($refU)) {
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   386
	my($sumU,$sumV,$sumW,$dc_sumU,$dc_sumV,$dc_sumW,$uc_sumU,$uc_sumV,$uc_sumW);
2
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   387
	my($nSumVel,$dc_nSumVel,$uc_nSumVel);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   388
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   389
	for (my($r)=0; $r<@depth; $r++) {
2
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   390
		if (numberp($u[$r])) {
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   391
			$nSumVel++;
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   392
			$sumU += $u[$r]; $sumV += $v[$r]; $sumW += $w[$r];
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   393
        }
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   394
        if (numberp($dc_u[$r])) {
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   395
			$dc_nSumVel++;
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   396
			$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
   397
		}
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   398
        if (numberp($uc_u[$r])) {
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   399
			$uc_nSumVel++;
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   400
			$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
   401
		}
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   402
	}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   403
	
2
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   404
	$refU = $sumU / $nSumVel; $refV = $sumV / $nSumVel; $refW = $sumW / $nSumVel;
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   405
	$dc_refU = $dc_sumU / $dc_nSumVel; $dc_refV = $dc_sumV / $dc_nSumVel; $dc_refW = $dc_sumW / $dc_nSumVel;
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   406
	$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
   407
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   408
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   409
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
   410
	$u[$r] -= $refU if defined($u[$r]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   411
	$v[$r] -= $refV if defined($v[$r]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   412
	$w[$r] -= $refW if defined($w[$r]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   413
	$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
   414
	$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
   415
	$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
   416
	$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
   417
	$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
   418
	$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
   419
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   420
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   421
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   422
# Determine X Factor
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   423
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   424
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   425
my($first_w,$last_w);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   426
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
   427
	$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
   428
	$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
   429
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   430
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   431
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
   432
&antsAddParams('X-Factor',$X_Factor);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   433
printf(STDERR "X-Factor = %.1f\n",$X_Factor);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   434
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   435
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   436
# Output Velocity Profile
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   437
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   438
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   439
@antsNewLayout = ('depth','u','v','w','dc_u','dc_v','dc_w','uc_u','uc_v','uc_w');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   440
for (my($r)=0; $r<@depth; $r++) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   441
	&antsOut($depth[$r]+$DZ/2,$u[$r],$v[$r],$w[$r],
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   442
							  $dc_u[$r],$dc_v[$r],$dc_w[$r],
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   443
							  $uc_u[$r],$uc_v[$r],$uc_w[$r]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   444
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   445
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   446
&antsExit();