LADCPintsh
author A.M. Thurnherr <athurnherr@yahoo.com>
Wed, 13 May 2015 21:30:27 +0000
changeset 35 3d769eee8c4f
parent 33 dd5b67a41791
permissions -rwxr-xr-x
V1.4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
     1
#!/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
35
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
     5
#                    dlm: Wed May 13 19:47:05 2015
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
35
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
     7
#                    uE-Info: 61 30 NIL 0 0 72 0 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';
35
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
    11
$antsMinLibVersion = 6.0;
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    12
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    13
# NOTES:
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    14
#	- the core of this code is a simplified version of avg_sh.m and
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    15
#	  int_sh.m written by Eric Firing
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    16
#	- comments beginning with ## are taken from Eric's code
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    17
#	- cubic velocity interpolation across PPI gap from Eric's code has
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    18
#	  not been implemented (yet?)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    19
#	- low-pass-filtered shear code has not yet been implemented
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    20
#	- currently, shear gaps are assumed to have vanishing shear;
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
    21
#	  better solutions are possible
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
    22
#	- elapsed time is simply copied from shear elapsed time (i.e.
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
    23
#	  it is not interpolated onto the new depth grid)
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    24
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    25
# WEIRDNESSES IN Eric's CODE:
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    26
#	- 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
    27
#	  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
    28
#	  is not used anywhere in Eric's code
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    29
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    30
# HISTORY:
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    31
#	Oct 14, 2010: - created
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    32
#	Oct 20, 2010: - first working version
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    33
#	Oct 23, 2010: - added support for -b)
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    34
#	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
    35
#					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
    36
#	Dec  9, 2010: - allowed for empty BT file
2
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
    37
#	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
    38
#	Jul  7, 2011: - added -m
5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
    39
#	Jul 19, 2011: - added shear sigma output for shear inversion
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
    40
#				  - BUG: dc/uc v component was not correctly referenced
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    41
#	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
    42
#						 was available for <dc,uc> combo profile
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    43
#	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
    44
#	Jul 27, 2011: - removed code related to smoothed shear
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    45
#				  - replaced -r by -n
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    46
#				  - removed shear sigma output
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    47
#				  - replaced ndata by nsamp
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    48
#				  - removed -w (Eric's way of dealing with dc/uc temporal variability)
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
    49
#	Feb 19, 2012: - added processing of elapsed time
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
    50
#				  - adapted to new shear file layout (nsamp instead of nshear)
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
    51
#				  - BUG: uplooker data was not used for downcasts and and only partially for combo data
11
d0af7f7aa23b V1.0beta2
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
    52
#   May 16, 2012: - adapted to ANTSlib V5.0
15
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
    53
#	May 25, 2012: - added code to read LDEO_IX bottom-track data
16
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 15
diff changeset
    54
#	Jun 14, 2012: - noticed that -b now works also with LDEO SADCP files :-); renamed -b option to -r
20
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
    55
#	Jun  5, 2013: - BUG: code bombed when either UC or DC was missing
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
    56
#	Jun 28, 2013: - adapated to new :: convention
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
    57
#				  - make sure LADCP DUL metadata are dealt with correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
    58
#	Jul 12, 2013: - clarified -u usage with better messages
25
91bd907db97f before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
    59
#	Mar 20, 2014: - fiddled while debugging [LADCPproc]
29
f72cd642972c whoosher
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
    60
#	Jun  7, 2014: - improved error messages
35
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 33
diff changeset
    61
#	May 13, 2015: - belatedly adapted to ANTS V6 (library versioning)
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    62
11
d0af7f7aa23b V1.0beta2
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 7
diff changeset
    63
($ANTS) = (`which ANTSlib` =~ m{^(.*)/[^/]*$});
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    64
require "$ANTS/ants.pl";
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    65
require "$ANTS/libstats.pl";
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    66
16
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 15
diff changeset
    67
&antsUsage('dm:n:r:s:w:u:',0,
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    68
	'[-d)ebug]',
16
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 15
diff changeset
    69
	'[-r)eference with <BT or SADCP file> [-m)in <samp[10]>]]',
20
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
    70
	'[secondary -u)plooker <shear file>]',
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    71
	'[min -n) <shear samp[10]>]',
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    72
	'[output -s)hear-pro <file>]',
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    73
	'[LADCP shear file]');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    74
16
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 15
diff changeset
    75
croak("$0: -m meaningless without -r\n")
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 15
diff changeset
    76
	if defined($opt_m) && !defined($opt_r);
3
711dd29cb6dd post 2011_IWISE
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 2
diff changeset
    77
15
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
    78
&antsCardOpt(\$opt_n,10);				# minimum number of samples for shear
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
    79
$minBTsamp = &antsCardOpt($opt_m,10);	# minimum number of samples for BT data
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
    80
16
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 15
diff changeset
    81
&antsFileOpt($opt_r);		# reference velocity file
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
    82
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
    83
&antsFileOpt($opt_u);		# UL shear file
20
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
    84
if (defined($opt_u)) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
    85
	open(ULF,$opt_u) || croak("$opt_u: $!\n");
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
    86
	%UL_P = &antsFileParams(ULF);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
    87
}
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    88
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    89
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    90
# Step 1: Read and Average Shear Data
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    91
#	- 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
    92
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
    93
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    94
sub wavg_sig(@)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    95
{
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    96
	my($sumSq) = my($n) = 0;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    97
	for (my($i)=0; $i<$#_; $i+=2) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    98
		next unless numberp($_[$i+1]);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    99
		$sumSq += $_[$i] * $_[$i+1]**2;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   100
		$n += $_[$i];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   101
	}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   102
	return ($n>0) ? sqrt($sumSq/$n) : nan;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   103
}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   104
	
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   105
20
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   106
#--------------------
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   107
# Handle Metadata
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   108
#--------------------
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   109
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   110
if (%UL_P) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   111
	croak("$0: inconsistent vertical resolution\n")
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   112
		unless ($P{LADCPproc::vertical_resolution} == $UL_P{LADCPproc::vertical_resolution});
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   113
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   114
	unless ($P{LADCPproc::bin_length} == $UL_P{LADCPproc::bin_length}) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   115
		&antsInfo("Warnining: different DL/UL bin lengths; derived spectra cannot be corrected");
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   116
		&antsAddParams('LADCPproc::bin_length','',
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   117
					   'LADCPproc::DL_bin_length',$P{LADCPproc::bin_length},
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   118
					   'LADCPproc::UL_bin_length',$UL_P{LADCPproc::bin_length});
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   119
	}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   120
}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   121
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   122
$depthF = fnrNoErr('depth');									# layout of [LADCPproc] output
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   123
unless (defined($depthF)) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   124
	if (defined($opt_u)) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   125
		croak("No 'depth' field in primary shear file (extraneous -u?)\n");
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   126
	} else {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   127
		croak("No 'depth' field in primary shear file\n");
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   128
	}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   129
}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   130
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   131
$dc_nshF = fnrNoErr('dc_nshear');
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   132
$dc_nshF = fnr('dc_nsamp') unless defined($dc_nshF);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   133
$dc_uzF  = fnr('dc_u_z');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   134
$dc_uzsF = fnrNoErr('dc_u_z.sig');
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   135
$dc_uzsF = fnr('dc_u_z_sig') unless defined($dc_uzsF);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   136
$dc_vzF  = fnr('dc_v_z');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   137
$dc_vzsF = fnrNoErr('dc_v_z.sig');
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   138
$dc_vzsF = fnr('dc_v_z_sig') unless defined($dc_vzsF);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   139
$dc_wzF  = fnr('dc_w_z');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   140
$dc_wzsF = fnrNoErr('dc_w_z.sig');
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   141
$dc_wzsF = fnr('dc_w_z_sig') unless defined($dc_wzsF);
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   142
$dc_elapsedF = fnr('dc_elapsed');
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   143
$uc_nshF = fnrNoErr('uc_nshear');
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   144
$uc_nshF = fnr('uc_nsamp') unless defined($uc_nshF);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   145
$uc_uzF  = fnr('uc_u_z');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   146
$uc_uzsF = fnrNoErr('uc_u_z.sig');
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   147
$uc_uzsF = fnr('uc_u_z_sig') unless defined($uc_uzsF);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   148
$uc_vzF  = fnr('uc_v_z');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   149
$uc_vzsF = fnrNoErr('uc_v_z.sig');
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   150
$uc_vzsF = fnr('uc_v_z_sig') unless defined($uc_vzsF);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   151
$uc_wzF  = fnr('uc_w_z');
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   152
$uc_wzsF = fnrNoErr('uc_w_z.sig');
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   153
$uc_wzsF = fnr('uc_w_z_sig') unless defined($uc_wzsF);
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   154
$uc_elapsedF = fnr('uc_elapsed');
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   155
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   156
my(@gaps); my($curGap) = 0;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   157
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   158
for (my($r)=0; &antsIn(); $r++) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   159
	my(@UL_);
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   160
	if (defined($opt_u)) {
5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   161
		@UL_ = &antsFileIn(ULF);							# read UL shear data
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   162
		undef($opt_u) unless (@UL_);						# cheap trick
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   163
	}
20
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   164
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   165
	$depth[$r] = $ants_[0][$depthF];						## depth grid values
18
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 16
diff changeset
   166
	croak("$opt_u: inconsistent depth record $r (DL: $depth[$r]; UL: $UL_[$depthF])\n")
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   167
		if defined($opt_u) && ($UL_[$depthF] != $depth[$r]);
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   168
		
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   169
	$dc_nsamp = $ants_[0][$dc_nshF];						# number of shear samples
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   170
	$uc_nsamp = $ants_[0][$uc_nshF];
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   171
	if (defined($opt_u)) {
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   172
		$dl_nsamp = $dc_nsamp + $uc_nsamp;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   173
		$dc_nsamp += $UL_[$dc_nshF];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   174
		$uc_nsamp += $UL_[$uc_nshF];
25
91bd907db97f before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   175
		$ul_nsamp = $dc_nsamp + $uc_nsamp;
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   176
	}
25
91bd907db97f before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   177
	
91bd907db97f before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   178
	$dc_nsamp[$r] = $dc_nsamp;								# save for each record
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   179
	$uc_nsamp[$r] = $uc_nsamp;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   180
	$nsamp[$r] = $dc_nsamp + $uc_nsamp;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   181
	if (defined($opt_u)) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   182
		$ul_nsamp[$r] = $ul_nsamp;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   183
		$dl_nsamp[$r] = $dl_nsamp;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   184
	}
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   185
5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   186
	if (defined($opt_u)) {									# dual-head instrument
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   187
		if ($dc_nsamp > 0) {								# downcast shear
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   188
			my($DLf) = $ants_[0][$dc_nshF] / $dc_nsamp;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   189
			my($ULf) =      $UL_[$dc_nshF] / $dc_nsamp;
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   190
			if ($DLf>0 && $ULf>0) {
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   191
				$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
   192
				$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
   193
	            $dc_wz[$r] = $DLf*$ants_[0][$dc_wzF] + $ULf*$UL_[$dc_wzF];
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   194
	            $dc_elapsed[$r] = $DLf*$ants_[0][$dc_elapsedF] + $ULf*$UL_[$dc_elapsedF];
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   195
	        } elsif ($DLf > 0) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   196
				$dc_uz[$r] = $ants_[0][$dc_uzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   197
				$dc_vz[$r] = $ants_[0][$dc_vzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   198
				$dc_wz[$r] = $ants_[0][$dc_wzF];
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   199
				$dc_elapsed[$r] = $ants_[0][$dc_elapsedF];
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   200
	        } else {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   201
				$dc_uz[$r] = $UL_[$dc_uzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   202
				$dc_vz[$r] = $UL_[$dc_vzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   203
				$dc_wz[$r] = $UL_[$dc_wzF];
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   204
				$dc_elapsed[$r] = $UL_[$dc_elapsedF];
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   205
	        }
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   206
		} else {
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   207
			$dc_uz[$r] = $dc_vz[$r] = $dc_wz[$r] = $dc_elapsed[$r] = nan;
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   208
	    }
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   209
		if ($uc_nsamp > 0) {								# upcast shear
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   210
			my($DLf) = $ants_[0][$uc_nshF] / $uc_nsamp;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   211
			my($ULf) =      $UL_[$uc_nshF] / $uc_nsamp;
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   212
			if ($DLf>0 && $Ulf>0) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   213
				$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
   214
				$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
   215
				$uc_wz[$r] = $DLf*$ants_[0][$uc_wzF] + $ULf*$UL_[$uc_wzF];
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   216
				$uc_elapsed[$r] = $DLf*$ants_[0][$uc_elapsedF] + $ULf*$UL_[$uc_elapsedF];
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   217
	        } elsif ($DLf > 0) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   218
				$uc_uz[$r] = $ants_[0][$uc_uzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   219
				$uc_vz[$r] = $ants_[0][$uc_vzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   220
				$uc_wz[$r] = $ants_[0][$uc_wzF];
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   221
				$uc_elapsed[$r] = $ants_[0][$uc_elapsedF];
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   222
	        } else {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   223
				$uc_uz[$r] = $UL_[$uc_uzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   224
				$uc_vz[$r] = $UL_[$uc_vzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   225
				$uc_wz[$r] = $UL_[$uc_wzF];
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   226
				$uc_elapsed[$r] = $UL_[$uc_elapsedF];
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   227
	        }
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   228
		} else {
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   229
			$uc_uz[$r] = $uc_vz[$r] = $uc_wz[$r] = $uc_elapsed[$r] = nan;
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   230
	    }
5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   231
	} else {	# downlooker only
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   232
		if ($dc_nsamp > 0) {							# downcast shear
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   233
			$dc_uz[$r] = $ants_[0][$dc_uzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   234
			$dc_vz[$r] = $ants_[0][$dc_vzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   235
			$dc_wz[$r] = $ants_[0][$dc_wzF];
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   236
			$dc_elapsed[$r] = $ants_[0][$dc_elapsedF];
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   237
		} else {
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   238
			$dc_uz[$r] = $dc_vz[$r] = $dc_wz[$r] = $dc_elapsed[$r] = nan;
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   239
	    }
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   240
		if ($uc_nsamp > 0) {							# upcast shear
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   241
			$uc_uz[$r] = $ants_[0][$uc_uzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   242
			$uc_vz[$r] = $ants_[0][$uc_vzF];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   243
			$uc_wz[$r] = $ants_[0][$uc_wzF];
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   244
			$uc_elapsed[$r] = $ants_[0][$uc_elapsedF];
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   245
		} else {
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   246
			$uc_uz[$r] = $uc_vz[$r] = $uc_wz[$r] = $uc_elapsed[$r] = nan;
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   247
	    }
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   248
    }
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   249
    
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   250
	if ($nsamp[$r] > 0) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   251
		my($dcf) = $dc_nsamp / $nsamp[$r];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   252
		my($ucf) = $uc_nsamp / $nsamp[$r];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   253
		if ($dcf>0 && $ucf>0) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   254
			$uz[$r] = $dcf*$dc_uz[$r] + $ucf*$uc_uz[$r];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   255
			$vz[$r] = $dcf*$dc_vz[$r] + $ucf*$uc_vz[$r];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   256
            $wz[$r] = $dcf*$dc_wz[$r] + $ucf*$uc_wz[$r];
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   257
            $elapsed[$r] = $dcf*$dc_elapsed[$r] + $ucf*$uc_elapsed[$r];
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   258
        } elsif ($dcf > 0) {
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   259
			$uz[$r] = $dc_uz[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   260
			$vz[$r] = $dc_vz[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   261
			$wz[$r] = $dc_wz[$r];
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   262
			$elapsed[$r] = $dc_elapsed[$r];
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   263
        } else {
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   264
			$uz[$r] = $uc_uz[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   265
			$vz[$r] = $uc_vz[$r];
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   266
			$wz[$r] = $uc_wz[$r];
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   267
			$elapsed[$r] = $uc_elapsed[$r];
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   268
        }
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   269
	} else {
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   270
		$uz[$r] = $vz[$r] = $wz[$r] = $elapsed[$r] = nan;
0
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
	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
   274
		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
   275
#		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
   276
		$curGap = 0;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   277
    } elsif (!numberp($uz[$r])) {								# currently in gap
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   278
#    	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
   279
		$curGap++;
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
	
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   282
	if ($nsamp[$r] > 0) {
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   283
		if (defined($opt_u)) {
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   284
			$uzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_uzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   285
							           $UL_[$dc_nshF],     $UL_[$dc_uzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   286
							      $ants_[0][$uc_nshF],$ants_[0][$uc_uzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   287
							           $UL_[$uc_nshF],     $UL_[$uc_uzsF]);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   288
			$vzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_vzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   289
									   $UL_[$dc_nshF],     $UL_[$dc_vzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   290
							      $ants_[0][$uc_nshF],$ants_[0][$uc_vzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   291
									   $UL_[$uc_nshF],     $UL_[$uc_vzsF]);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   292
			$wzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_wzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   293
									   $UL_[$dc_nshF],     $UL_[$dc_wzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   294
							      $ants_[0][$uc_nshF],$ants_[0][$uc_wzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   295
	                                   $UL_[$uc_nshF],     $UL_[$uc_wzsF]);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   296
		} else { # DL only
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   297
			$uzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_uzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   298
							      $ants_[0][$uc_nshF],$ants_[0][$uc_uzsF]);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   299
			$vzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_vzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   300
							      $ants_[0][$uc_nshF],$ants_[0][$uc_vzsF]);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   301
			$wzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_wzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   302
	                              $ants_[0][$uc_nshF],$ants_[0][$uc_wzsF]);
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   303
	    }
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   304
	} else {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   305
		$uzsig[$r] = $vzsig[$r] = $wzsig[$r] = nan;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   306
	}
5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   307
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   308
	if ($dc_nsamp > 0) {									# same calc for downcast only
5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   309
		if (defined($opt_u)) {
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   310
			$dc_uzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_uzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   311
							              $UL_[$dc_nshF],     $UL_[$dc_uzsF]);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   312
			$dc_vzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_vzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   313
							              $UL_[$dc_nshF],     $UL_[$dc_vzsF]);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   314
			$dc_wzsig[$r] = wavg_sig($ants_[0][$dc_nshF],$ants_[0][$dc_wzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   315
							              $UL_[$dc_nshF],     $UL_[$dc_wzsF]);
5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   316
		} else {
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   317
			$dc_uzsig[$r] = $ants_[0][$dc_uzsF];
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   318
			$dc_vzsig[$r] = $ants_[0][$dc_vzsF];
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   319
			$dc_wzsig[$r] = $ants_[0][$dc_wzsF];
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   320
	    }
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   321
	} else {
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   322
		$uzsig[$r] = $vzsig[$r] = $wzsig[$r] = nan;
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   323
	}
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   324
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   325
	if ($uc_nsamp > 0) {									# same calc for upcast only
5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   326
		if (defined($opt_u)) {
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   327
			$uc_uzsig[$r] = wavg_sig($ants_[0][$uc_nshF],$ants_[0][$uc_uzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   328
							              $UL_[$uc_nshF],     $UL_[$uc_uzsF]);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   329
			$uc_vzsig[$r] = wavg_sig($ants_[0][$uc_nshF],$ants_[0][$uc_vzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   330
							              $UL_[$uc_nshF],     $UL_[$uc_vzsF]);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   331
			$uc_wzsig[$r] = wavg_sig($ants_[0][$uc_nshF],$ants_[0][$uc_wzsF],
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   332
							              $UL_[$uc_nshF],     $UL_[$uc_wzsF]);
5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   333
		} else {
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   334
			$uc_uzsig[$r] = $ants_[0][$uc_uzsF];
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   335
			$uc_vzsig[$r] = $ants_[0][$uc_vzsF];
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   336
			$uc_wzsig[$r] = $ants_[0][$uc_wzsF];
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   337
	    }
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   338
	} else {
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   339
		$uzsig[$r] = $vzsig[$r] = $wzsig[$r] = nan;
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   340
	}
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   341
}
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
if (@gaps) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   344
	&antsAddParams('shear_gaps',"@gaps");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   345
	print(STDERR "shear gaps: @gaps\n");
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   346
} else {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   347
	&antsAddParams('shear_gaps',0);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   348
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   349
	
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   350
#===============================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   351
# 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
   352
#===============================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   353
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   354
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   355
# Step 3: Integrate Shear
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   356
#	- z(vel) = z(sh) + DZ/2
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   357
#======================================================================
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
my($DZ) = $depth[1] - $depth[0];
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   360
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   361
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
   362
	 $r<@depth; $r++) {
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   363
	if ($nsamp[$r] >= $opt_n) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   364
		$u = $u[$r] = $u + $DZ*$uz[$r];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   365
		$v = $v[$r] = $v + $DZ*$vz[$r];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   366
		$w = $w[$r] = $w + $DZ*$wz[$r];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   367
	}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   368
	if ($dc_nsamp[$r] >= $opt_n) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   369
		$dc_u = $dc_u[$r] = $dc_u + $DZ*$dc_uz[$r];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   370
		$dc_v = $dc_v[$r] = $dc_v + $DZ*$dc_vz[$r];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   371
		$dc_w = $dc_w[$r] = $dc_w + $DZ*$dc_wz[$r];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   372
	}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   373
	if ($uc_nsamp[$r] >= $opt_n) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   374
		$uc_u = $uc_u[$r] = $uc_u + $DZ*$uc_uz[$r];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   375
		$uc_v = $uc_v[$r] = $uc_v + $DZ*$uc_vz[$r];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   376
		$uc_w = $uc_w[$r] = $uc_w + $DZ*$uc_wz[$r];
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   377
	}
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   378
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   379
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   380
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   381
# Step 4: Reference Velocities
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   382
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   383
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   384
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
   385
25
91bd907db97f before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   386
if (defined($opt_r)) {											# reference using velocity profile
16
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 15
diff changeset
   387
	print(STDERR "Loading reference-velocity data from $opt_r...\n")
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   388
		if ($opt_d);
16
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 15
diff changeset
   389
	open(BTF,$opt_r) || croak("$opt_r: $!\n");
0
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
	my(@BTL) = &antsFileLayout(BTF);
15
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   392
	if (@BTL) {													# valid ANTS file
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   393
		my($BTdF,$BTndF,$BTuF,$BTvF,$BTwF,$BTusF,$BTvsF,$BTwsF);
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   394
		for (my($f)=0; $f<@BTL; $f++) {
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   395
			$BTdF = $f if ($BTL[$f] eq 'depth');
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   396
			$BTuF = $f if ($BTL[$f] eq 'u');
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   397
			$BTvF = $f if ($BTL[$f] eq 'v');
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   398
			$BTwF = $f if ($BTL[$f] eq 'w');
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   399
			$BTusF = $f if ($BTL[$f] eq 'u.sig');
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   400
			$BTvsF = $f if ($BTL[$f] eq 'v.sig');
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   401
			$BTwsF = $f if ($BTL[$f] eq 'w.sig');
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   402
			$BTndF = $f if ($BTL[$f] eq 'nsamp');
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   403
			$BTerrF= $f if ($BTL[$f] eq 'err');
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   404
		}
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   405
15
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   406
		if (defined($BTdF) && defined($BTuF) &&					# from LADCPproc
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   407
		    defined($BTvF) && defined($BTwF) &&
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   408
		    defined($BTusF) && defined($BTvsF) &&
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   409
			defined($BTwsF) && defined($BTndF)) {	
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   410
			while (my(@BTr) = &antsFileIn(BTF)) {
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   411
				my($gi) = int($BTr[$BTdF] / $DZ);
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   412
				next unless ($BTr[$BTndF] >= $minBTsamp);
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   413
				$BT_nsamp[$gi] = $BTr[$BTndF];
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   414
				$BT_u[$gi] = $BTr[$BTuF];
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   415
				$BT_v[$gi] = $BTr[$BTvF];
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   416
				$BT_w[$gi] = $BTr[$BTwF];
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   417
				$BT_u_var[$gi] = $BTr[$BTusF]**2;
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   418
				$BT_v_var[$gi] = $BTr[$BTvsF]**2;
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   419
				$BT_w_var[$gi] = $BTr[$BTwsF]**2;
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   420
			}
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   421
			&fixLowSampStat(\@BT_u_var,@BT_nsamp);				# remove spurious small variances
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   422
			&fixLowSampStat(\@BT_v_var,@BT_nsamp);
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   423
	        &fixLowSampStat(\@BT_w_var,@BT_nsamp);
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   424
        } elsif (defined($BTdF) && defined($BTuF) &&			# LDEO_IX ANTS format
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   425
				 defined($BTvF) && defined($BTerrF)) {
29
f72cd642972c whoosher
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   426
			croak("$0: -m not supported for LDEO_IX output\n")
15
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   427
				if defined($opt_m);
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   428
			while (my(@BTr) = &antsFileIn(BTF)) {
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   429
				my($gi) = int($BTr[$BTdF] / $DZ);
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   430
				$BT_u[$gi] = $BTr[$BTuF];
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   431
				$BT_v[$gi] = $BTr[$BTvF];
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   432
				$BT_u_var[$gi] = $BTr[$BTerrF]**2;
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   433
				$BT_v_var[$gi] = $BTr[$BTerrF]**2;
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   434
#				print(STDERR "$gi $BT_u[$gi] $BT_v[$gi] $BT_u_var[$gi] $BT_v_var[$gi]\n");
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   435
			}
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   436
        } else {
16
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 15
diff changeset
   437
			croak("$opt_r: not a valid reference-velocity file (ANTS format)\n");
15
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   438
		}
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   439
	} else {													# non-ANTS file (LDEO_IX assumed)
29
f72cd642972c whoosher
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 26
diff changeset
   440
		croak("$0: -m not supported for LDEO_IX output\n")
15
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   441
			if defined($opt_m);
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   442
		while (<BTF>) {
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   443
			last if /^Columns\s+=\s+z:u:v:err/;
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   444
		}
16
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 15
diff changeset
   445
		croak("$opt_r: not a valid reference-velocity file (non-ANTS format)\n")
15
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   446
			unless /^Columns\s+=\s+z:u:v:err/;
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   447
		while (<BTF>) {
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   448
			my($depth,$u,$v,$err) = split;
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   449
			croak("$0: cannot handle non-numeric BT data (implementation restriction)\n")
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   450
				unless numberp($depth) && numberp($u) && numberp($v) && numberp($err);
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   451
			my($gi) = int($depth / $DZ);
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   452
			$BT_u[$gi] = $u;
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   453
			$BT_v[$gi] = $v;
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   454
			$BT_u_var[$gi] = $err**2;
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   455
			$BT_v_var[$gi] = $err**2;
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   456
#			print(STDERR "$gi $BT_u[$gi] $BT_v[$gi] $BT_u_var[$gi] $BT_v_var[$gi]\n");
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   457
		}
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   458
    }
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   459
    close(BTF);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   460
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   461
	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
   462
	   $uc_sumU,$uc_sumV,$uc_sumW);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   463
	my($nSumVel,$dc_nSumVel,$uc_nSumVel);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   464
	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
   465
	my($dc_wSumBTu,$dc_wSumBTv,$dc_wSumBTw);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   466
	my($uc_wSumBTu,$uc_wSumBTv,$uc_wSumBTw);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   467
	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
   468
	my($dc_sumVarBTu,$dc_sumVarBTv,$dc_sumVarBTw);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   469
	my($uc_sumVarBTu,$uc_sumVarBTv,$uc_sumVarBTw);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   470
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   471
	for (my($r)=0; $r<@depth; $r++) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   472
		if (numberp($BT_u[$r]) && numberp($u[$r])) {
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   473
			$nSumVel++;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   474
			$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
   475
			$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
   476
			$wSumBTv += $BT_v[$r] / $BT_v_var[$r]; $sumVarBTv += 1/$BT_v_var[$r];
15
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   477
			if (@BT_w) {
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   478
				$wSumBTw += $BT_w[$r] / $BT_w_var[$r]; $sumVarBTw += 1/$BT_w_var[$r];
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   479
			}
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   480
		}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   481
		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
   482
			$dc_nSumVel++;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   483
			$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
   484
			$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
   485
			$dc_wSumBTv += $BT_v[$r] / $BT_v_var[$r]; $dc_sumVarBTv += 1/$BT_v_var[$r];
15
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   486
			if (@BT_w) {
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   487
				$dc_wSumBTw += $BT_w[$r] / $BT_w_var[$r]; $dc_sumVarBTw += 1/$BT_w_var[$r];
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   488
			}
0
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
		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
   491
			$uc_nSumVel++;
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   492
			$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
   493
			$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
   494
			$uc_wSumBTv += $BT_v[$r] / $BT_v_var[$r]; $uc_sumVarBTv += 1/$BT_v_var[$r];
15
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   495
			if (@BT_w) {
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   496
				$uc_wSumBTw += $BT_w[$r] / $BT_w_var[$r]; $uc_sumVarBTw += 1/$BT_w_var[$r];
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   497
			}
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   498
		}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   499
	}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   500
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   501
	if ($nSumVel > 0) {
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   502
		$refU = $sumU/$nSumVel - $wSumBTu/$sumVarBTu;
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   503
		$refV = $sumV/$nSumVel - $wSumBTv/$sumVarBTv;
15
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   504
		$refW = $sumW/$nSumVel - $wSumBTw/$sumVarBTw if (@BT_w);
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   505
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   506
		if ($dc_nSumVel > 0) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   507
			$dc_refU = $dc_sumU/$dc_nSumVel - $dc_wSumBTu/$dc_sumVarBTu;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   508
			$dc_refV = $dc_sumV/$dc_nSumVel - $dc_wSumBTv/$dc_sumVarBTv;
15
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   509
			$dc_refW = $dc_sumW/$dc_nSumVel - $dc_wSumBTw/$dc_sumVarBTw if (@BT_w);
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   510
		} else {
25
91bd907db97f before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   511
			&antsInfo("$opt_r: insufficient reference-velocity data to constrain DC profile --- baroclinic profile only");
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   512
		}
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   513
	    
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   514
		if ($uc_nSumVel > 0) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   515
			$uc_refU = $uc_sumU/$uc_nSumVel - $uc_wSumBTu/$uc_sumVarBTu;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   516
			$uc_refV = $uc_sumV/$uc_nSumVel - $uc_wSumBTv/$uc_sumVarBTv;
15
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   517
		    $uc_refW = $uc_sumW/$uc_nSumVel - $uc_wSumBTw/$uc_sumVarBTw if (@BT_w);
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   518
		} else {
25
91bd907db97f before debugging weird nsamp problem
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 20
diff changeset
   519
			&antsInfo("$opt_r: insufficient reference-velocity data to constrain UC profile --- baroclinic profile only");
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   520
		}
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   521
	} else {
16
ff157f4445ce V1.0 beta7
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 15
diff changeset
   522
		&antsInfo("$opt_r: no valid reference-velocity data --- baroclinic profiles only");
1
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   523
	}
54222c82435f after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 0
diff changeset
   524
}
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   525
5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   526
unless (defined($refU)) {									# no reference velocity => use zero mean
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   527
	my($sumU,$sumV,$sumW,$nSumVel);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   528
	for (my($r)=0; $r<@depth; $r++) {
2
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   529
		if (numberp($u[$r])) {
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   530
			$nSumVel++;
15
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   531
			$sumU += $u[$r]; $sumV += $v[$r]; $sumW += $w[$r] if (@BT_w);
2
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   532
        }
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   533
    }
15
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   534
	$refU = $sumU / $nSumVel; $refV = $sumV / $nSumVel; $refW = $sumW / $nSumVel if (@BT_w);
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   535
}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   536
unless (defined($dc_refU)) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   537
	my($dc_sumU,$dc_sumV,$dc_sumW,$dc_nSumVel);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   538
	for (my($r)=0; $r<@depth; $r++) {
2
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   539
        if (numberp($dc_u[$r])) {
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   540
			$dc_nSumVel++;
15
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   541
			$dc_sumU += $dc_u[$r]; $dc_sumV += $dc_v[$r]; $dc_sumW += $dc_w[$r] if (@BT_w);
2
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   542
		}
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   543
	}
20
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   544
	if ($dc_nSumVel) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   545
		$dc_refU = $dc_sumU / $dc_nSumVel; $dc_refV = $dc_sumV / $dc_nSumVel;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   546
		$dc_refW = $dc_sumW / $dc_nSumVel if (@BT_w);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   547
	}
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   548
}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   549
unless (defined($uc_refU)) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   550
	my($uc_sumU,$uc_sumV,$uc_sumW,$uc_nSumVel);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   551
	for (my($r)=0; $r<@depth; $r++) {
2
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   552
        if (numberp($uc_u[$r])) {
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   553
			$uc_nSumVel++;
15
7896932f0206 V1.0beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 11
diff changeset
   554
			$uc_sumU += $uc_u[$r]; $uc_sumV += $uc_v[$r]; $uc_sumW += $uc_w[$r] if (@BT_w);
2
16726a31a399 pre IWISE
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 1
diff changeset
   555
		}
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   556
	}
20
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   557
	if ($uc_nSumVel) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   558
		$uc_refU = $uc_sumU / $uc_nSumVel; $uc_refV = $uc_sumV / $uc_nSumVel;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   559
		$uc_refW = $uc_sumW / $uc_nSumVel if (@BT_w);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   560
	}
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   561
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   562
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   563
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
   564
	$u[$r] -= $refU if defined($u[$r]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   565
	$v[$r] -= $refV if defined($v[$r]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   566
	$w[$r] -= $refW if defined($w[$r]);
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   567
	$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
   568
	$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
   569
	$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
   570
	$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
   571
	$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
   572
	$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
   573
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   574
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   575
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   576
# Determine X Factor
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   577
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   578
20
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   579
if ($dc_nSumVel && $uc_nSumVel) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   580
	my($first_w,$last_w);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   581
	for (my($r)=0; !defined($first_w) || !defined($last_w); $r++) {
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   582
		$first_w = $dc_w[$r] unless defined($first_w);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   583
		$last_w  = $uc_w[$r] unless defined($last_w);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   584
	}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   585
	
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   586
	my($X_Factor) = 100 * abs($last_w-$first_w) / sqrt(@depth / $DZ);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   587
	&antsAddParams('X-Factor',$X_Factor);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   588
	printf(STDERR "X-Factor = %.1f\n",$X_Factor);
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   589
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   590
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   591
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   592
# Output Velocity Profile
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   593
#======================================================================
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   594
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   595
@antsNewLayout = ('depth','elapsed','u','v','w','nsamp',
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   596
				  'dc_elapsed','dc_u','dc_v','dc_w','dc_nsamp',
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   597
				  'uc_elapsed','uc_u','uc_v','uc_w','uc_nsamp');
5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   598
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   599
for (my($r)=0; $r<@depth; $r++) {
5
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 3
diff changeset
   600
	&antsOut($depth[$r]+$DZ/2,
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   601
			 $elapsed[$r],$u[$r],$v[$r],$w[$r],$nsamp[$r],
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   602
			 $dc_elapsed[$r],$dc_u[$r],$dc_v[$r],$dc_w[$r],$dc_nsamp[$r],
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   603
			 $uc_elapsed[$r],$uc_u[$r],$uc_v[$r],$uc_w[$r],$uc_nsamp[$r]);
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   604
}
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   605
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   606
#======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   607
# Output Averaged Shear Profile
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   608
#======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   609
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   610
if (defined($opt_s)) {
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   611
	@antsNewLayout = ('depth','elapsed','u_z','v_z','w_z','u_z.sig','v_z.sig','w_z.sig','nsamp',
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   612
							  'dc_elapsed','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 <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   613
							  'uc_elapsed','uc_u_z','uc_v_z','uc_w_z','uc_u_z.sig','uc_v_z.sig','uc_w_z.sig','uc_nsamp');
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   614
	&antsOut('EOF');
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   615
    close(STDOUT);
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   616
	open(STDOUT,">$opt_s") || croak("$opt_s: $!\n");
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   617
	for (my($r)=0; $r<@depth; $r++) {
7
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   618
		&antsOut($depth[$r],$elapsed[$r],$uz[$r],$vz[$r],$wz[$r],$uzsig[$r],$vzsig[$r],$wzsig[$r],$nsamp[$r],
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   619
			     $dc_elapsed[$r],$dc_uz[$r],$dc_vz[$r],$dc_wz[$r],$dc_uzsig[$r],$dc_vzsig[$r],$dc_wzsig[$r],$dc_nsamp[$r],
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents: 6
diff changeset
   620
			     $uc_elapsed[$r],$uc_uz[$r],$uc_vz[$r],$uc_wz[$r],$uc_uzsig[$r],$uc_vzsig[$r],$uc_wzsig[$r],$uc_nsamp[$r]);
6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   621
	}
0
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   622
}
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   623
de00d0f32431 initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff changeset
   624
&antsExit();