acoustic_backscatter.pl
author A.M. Thurnherr <athurnherr@yahoo.com>
Sat, 24 Jul 2021 10:35:41 -0400
changeset 56 8f120b9f795a
parent 46 cc6c4309828a
child 57 69e39fcb7f41
permissions -rw-r--r--
V2.0 - lots of bug fixes - major new features: - dropped CTD scans handled correctly (no more apparent clock drifts) - support for data files collected with Nortek Signature instruments - much improved data editing - significant changes: - no minimum limit for eps_VKE - updated for GMT6 - much better data quality information in summary plots
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
     1
#======================================================================
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
     2
#                    A C O U S T I C _ B A C K S C A T T E R . P L 
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
     3
#                    doc: Wed Oct 20 13:02:27 2010
56
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 46
diff changeset
     4
#                    dlm: Thu Jul  1 09:37:40 2021
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
     5
#                    (c) 2010 A.M. Thurnherr
56
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 46
diff changeset
     6
#                    uE-Info: 32 46 NIL 0 0 72 2 2 4 NIL ofnI
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
     7
#======================================================================
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
     8
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
     9
# HISTORY:
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    10
#	Oct 20, 2010: - created
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    11
#	Dec 10, 2010: - BUG: backscatter above sea surface made code bomb
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    12
#						 when run with uplooker data
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    13
#	Dec 30, 2010: - adapted for use with [LADCP_w]
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 0
diff changeset
    14
#	Oct 19, 2011: - added support for $SS_{min,max}_allowed_range
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 0
diff changeset
    15
#				  - BUG: acoustic-backscatter assumed 0 deg C
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 0
diff changeset
    16
#				  - SV now saved in ensemble
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 0
diff changeset
    17
#	Oct 21, 2011: - BUG: made code work for uplooker again
15
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
    18
#	Mar  4, 2014: - added support for missing PITCH/ROLL (TILT)
18
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 15
diff changeset
    19
#	Apr 17, 2014: - BUG: missing ;
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 15
diff changeset
    20
#	Nov  7, 2014: - BUG: calc_binDepths() was called without valid CTD depth
28
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
    21
#				  - added $SS_use_BT, $SS_min_signal, $SS_min_samp
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
    22
#	Apr 20, 2015: - added comments
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
    23
#				  - removed SS_{min,max}_allowed_range from calc_backscatter_profs()
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
    24
#				  - added correct_backscatter() & linterp() from laptop
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    25
#	Apr 21, 2015: - added debug statements
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    26
#	May 14, 2015: - BUG: code did not work for partial-depth casts
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
    27
#	Jun 18, 2015: - removed assertion marked by ##???, which bombed on P16N1#41 DL
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
    28
#	Jan 26, 2016: - added %PARAMs
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
    29
#	Mar 26, 2016: - BUG: nSv was declared local to this scope even though it is used outside
45
6d49c7420a6c stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 42
diff changeset
    30
#	May 18, 2016: - improved logging
46
cc6c4309828a V1.3beta1
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 45
diff changeset
    31
#   May 24, 2016: - calc_binDepths() -> binDepths()
56
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 46
diff changeset
    32
#	Jul  1, 2021: - made %PARAMs more standard
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 46
diff changeset
    33
# HISTORY END
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 46
diff changeset
    34
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    35
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    36
#----------------------------------------------------------------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    37
# Volume Scattering Coefficient, following Deines (IEEE 1999)
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    38
# NOTES:
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    39
#	- instrument specific! (300kHz Workhorse)
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    40
#   - no sound-speed correction applied
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    41
#   - R in bin center, instead of last quarter
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    42
#   - transmit power assumes 33V batteries
28
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
    43
# EMPIRICAL FINDINGS (after applying the empirical correction)
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
    44
#  - Sv(WH300) ~ Sv(WH150)/1.4-34
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
    45
#      - based on DoMORE-1: 004, 005
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
    46
#      - identical instrument setup (0/8/8m)
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
    47
#      - 003, with higher scattering is somewhat different
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    48
#----------------------------------------------------------------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    49
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    50
# NB:
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    51
#	- correction seems to work for a subset of bins (~bins 3-9 for 
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    52
#	  2010 P403 station 46) 
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    53
#	- this may imply that noise level depends on bin
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    54
# 	- far bins are important for seabed detection, i.e. cannot simply
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    55
#	  be discarded at this stage
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    56
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    57
sub Sv($$$$$)
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    58
{
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    59
    my($temp,$PL,$Er,$R,$EA) = @_;
28
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
    60
    my($C)      = -143;                 # RDI WHM300 (from Deines)
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    61
    my($Ldbm)   = 10 * log10($PL);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    62
    my($PdbW)   = 14.0;
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    63
    my($alpha)  = 0.069;
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    64
    my($Kc)     = 0.45;
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    65
    
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    66
    return $C + 10*log10(($temp+273)*$R**2) - $Ldbm - $PdbW
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    67
              + 2*$alpha*$R + $Kc*($EA-$Er);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    68
}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    69
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    70
#----------------------------------------------------------------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    71
# Calculate per-bin backscatter profiles
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    72
#	input: 	first and last valid LADCP ensemble
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    73
#	output:	sSv[$depth][$bin]	sum of volume scattering coefficients
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    74
#			nSv[$depth][$bin]	number of samples in bin
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    75
#----------------------------------------------------------------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    76
42
f7690c7b92e0 V1.2beta6
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 34
diff changeset
    77
# my(@sSv,@nSv);		BAD: nSv is referenced in [LADCP_w_ocean]
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    78
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    79
sub calc_backscatter_profs($$)
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    80
{
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    81
	my($LADCP_start,$LADCP_end) = @_;
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    82
	
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    83
	my(@Er) = (1e99,1e99,1e99,1e99);						# echo intensity reference level
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    84
	for (my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) {
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    85
		$Er[0] = $LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][0]
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    86
			if ($LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][0] < $Er[0]);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    87
		$Er[1] = $LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][1]
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    88
			if ($LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][1] < $Er[1]);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    89
		$Er[2] = $LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][2]
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    90
			if ($LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][2] < $Er[2]);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    91
		$Er[3] = $LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][3]
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    92
			if ($LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$LADCP{N_BINS}-1][3] < $Er[3]);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    93
    }
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    94
	debugmsg("per-beam noise levels = @Er\n");
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    95
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    96
	my($cosBeamAngle) = cos(rad($LADCP{BEAM_ANGLE}));
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
    97
	for (my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) {
18
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 15
diff changeset
    98
		next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH});
46
cc6c4309828a V1.3beta1
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 45
diff changeset
    99
		my(@bd) = binDepths($ens);
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   100
		for (my($bin)=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) {
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   101
			my($depth) = int($bd[$bin]);
15
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 5
diff changeset
   102
			next if ($depth<0 || !defined($LADCP{ENSEMBLE}[$ens]->{TILT}));
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 0
diff changeset
   103
			my($range_to_bin) = abs($bd[$bin] - $LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH})
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   104
									/ cos(rad($LADCP{ENSEMBLE}[$ens]->{TILT}))
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   105
									/ $cosBeamAngle;
5
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 0
diff changeset
   106
			my($temp) = defined($CTD_temp)
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 0
diff changeset
   107
					  ? $CTD{TEMP}[$LADCP{ENSEMBLE}[$ens]->{CTD_SCAN}]
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 0
diff changeset
   108
					  : $LADCP{ENSEMBLE}[$ens]->{TEMPERATURE};
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 0
diff changeset
   109
			$LADCP{ENSEMBLE}[$ens]->{SV}[$bin] =
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 0
diff changeset
   110
				median(
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 0
diff changeset
   111
					Sv($temp,$LADCP{TRANSMITTED_PULSE_LENGTH},$Er[0],$range_to_bin,
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 0
diff changeset
   112
					   $LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$bin][0]
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 0
diff changeset
   113
				    ),
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 0
diff changeset
   114
				    Sv($temp,$LADCP{TRANSMITTED_PULSE_LENGTH},$Er[1],$range_to_bin,
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 0
diff changeset
   115
					   $LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$bin][1]
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 0
diff changeset
   116
					),
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 0
diff changeset
   117
					Sv($temp,$LADCP{TRANSMITTED_PULSE_LENGTH},$Er[2],$range_to_bin,
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 0
diff changeset
   118
					   $LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$bin][2]
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 0
diff changeset
   119
					),
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 0
diff changeset
   120
					Sv($temp,$LADCP{TRANSMITTED_PULSE_LENGTH},$Er[3],$range_to_bin,
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 0
diff changeset
   121
	     			   $LADCP{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$bin][3]
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 0
diff changeset
   122
					)
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 0
diff changeset
   123
				);
509cc9966b68 ======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 0
diff changeset
   124
    		$sSv[$depth][$bin] += $LADCP{ENSEMBLE}[$ens]->{SV}[$bin];
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   125
			$nSv[$depth][$bin]++;
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   126
		}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   127
	}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   128
}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   129
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   130
#----------------------------------------------------------------------
28
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   131
# empirically adjust Sv in far bins for consistency with nearest
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   132
# valid bin
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   133
#	- based on bin-to-bin differences of 100m vertically averaged Sv
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   134
#	  profiles
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   135
#	- algorithm can leave artifacts in the near bins near bottom
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   136
#	  turn-around (DM1#001)
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   137
#----------------------------------------------------------------------
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   138
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   139
sub linterp($$$$$)
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   140
{
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   141
	my($x,$mix,$max,$miy,$may) = @_;
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   142
	return $miy + ($x-$mix)/($max-$mix)*($may-$miy);
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   143
}
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   144
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   145
sub correct_backscatter($$)
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   146
{
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   147
	my($LADCP_start,$LADCP_end) = @_;
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   148
	my($bin) = $LADCP_firstBin-1;
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   149
	my(@refSvProf,@refSvSamp,$depth,$i);
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   150
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 29
diff changeset
   151
	&antsAddParams('Sv_ref_bin',$Sv_ref_bin);
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 29
diff changeset
   152
28
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   153
RETRY:
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   154
	for ($depth=0; $depth<@nSv; $depth++) {						# create reference profile
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   155
		next unless ($nSv[$depth][$Sv_ref_bin-1] > 0);
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   156
		$refSvProf[int($depth/100)] += $sSv[$depth][$Sv_ref_bin-1] / $nSv[$depth][$Sv_ref_bin-1];
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   157
		$refSvSamp[int($depth/100)]++;
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   158
    }
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   159
    $Sv_ref_bin++,goto RETRY
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   160
    	unless (@refSvSamp);
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   161
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   162
	for ($i=0; $i<@refSvSamp; $i++) {
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   163
		next unless ($refSvSamp[$i] > 0);
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   164
		$refSvProf[$i] /= $refSvSamp[$i];
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   165
	}
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   166
	for ($i=0; $i<5; $i++) {									# extrapolate bottom value by 500m
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   167
		push(@refSvProf,$refSvProf[$#refSvProf]);
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   168
		push(@refSvSamp,$refSvSamp[$#refSvSamp]);
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   169
	}
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   170
	for ($i=$#refSvProf-1; $i>=0; $i--) {						# extrapolate upward to surface
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   171
		next if ($refSvSamp[$i] > 0);
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   172
		$refSvProf[$i] = $refSvProf[$i+1];
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   173
		$refSvSamp[$i] = $refSvSamp[$i+1];
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   174
	}
28
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   175
	info("\tusing bin %d as reference\n",$Sv_ref_bin);
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   176
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   177
	my(@dSvProf);												# create profiles for all bins
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   178
	for ($bin=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) {	
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   179
		my(@dSvSamp);									
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   180
		for ($depth=0; $depth<@nSv; $depth++) {					# create Sv-difference profile for current bin
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   181
			next unless ($nSv[$depth][$bin] > 0);
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   182
			$dSvProf[int($depth/100)][$bin] += $sSv[$depth][$bin] / $nSv[$depth][$bin];
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   183
			$dSvSamp[int($depth/100)]++;
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   184
		}
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   185
#		print(STDERR "dSvProf[bin$bin] = ");
28
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   186
		for ($i=0; $i<@dSvSamp; $i++) {
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   187
			next unless ($dSvSamp[$i] > 0);
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   188
			die("assertion failed (refSvSamp[$i] = $refSvSamp[$i])") unless ($refSvSamp[$i] > 0);
28
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   189
			$dSvProf[$i][$bin] = $dSvProf[$i][$bin]/$dSvSamp[$i] - $refSvProf[$i];
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   190
			$dSvProf[$i][$bin] = $dSvProf[$i-1][$bin]
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   191
				if (abs($dSvProf[$i][$bin]) > 10);
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   192
#			printf(STDERR "%.1f ",$dSvProf[$i][$bin]);
28
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   193
		}
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   194
		$i--;													# trim deepest, often anomalous, value
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   195
#		print(STDERR "[delete] ");
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   196
		while ($i <= int(scalar(@nSv)/100)+1) {
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   197
			$dSvProf[$i][$bin] = $dSvProf[$i-1][$bin];			# extrapolate 100m
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   198
#			printf(STDERR "[%.1f] ",$dSvProf[$i][$bin]);
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   199
			$i++;
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   200
		}
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   201
#		print(STDERR "\n");
28
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   202
	}
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   203
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   204
    for (my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) {		# correct Sv data
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   205
		next unless numberp($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH});
46
cc6c4309828a V1.3beta1
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 45
diff changeset
   206
		my(@bd) = binDepths($ens);
28
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   207
		for (my($bin)=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) {
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   208
			next unless numberp($LADCP{ENSEMBLE}[$ens]->{SV}[$bin]);
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   209
			my($depth) = int($bd[$bin]);
29
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   210
			if (numberp($dSvProf[int($depth/100)][$bin]) && numberp($dSvProf[int($depth/100)+1][$bin])) {
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   211
#				print(STDERR "\n$LADCP{ENSEMBLE}[$ens]->{SV}[$bin]? $dSvProf[int($depth/100)][$bin] $dSvProf[int($depth/100)+1][$bin] int($depth/100)+1[$bin]");
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   212
				$LADCP{ENSEMBLE}[$ens]->{SV}[$bin] -= # $dSvProf[int($depth/100)][$bin];
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   213
					linterp($depth,100*int($depth/100),100*int($depth/100)+100,
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   214
							$dSvProf[int($depth/100)][$bin],$dSvProf[int($depth/100)+1][$bin]);
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   215
			} else {
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   216
				$LADCP{ENSEMBLE}[$ens]->{SV}[$bin] = nan;
c1ff35103176 a few days pre WHOI
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 28
diff changeset
   217
			}
28
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   218
		}
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   219
	}
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   220
}
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   221
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   222
#----------------------------------------------------------------------
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   223
# determine location of seabed from backscatter profiles
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   224
#	input:	depth below which seabed can possibly be (e.g. max CTD depth)
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   225
#	output:	median/mad of estimated water depth
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   226
#----------------------------------------------------------------------
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   227
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   228
sub find_backscatter_seabed($)
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   229
{
28
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   230
	my($search_below) = int($_[0]);										# grid index to begin search
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   231
	my(@wdepth,@Sv_rng);												# list of water_depth indices
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   232
56
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 46
diff changeset
   233
	&antsAddParams('SS_signal.min',$SS_min_signal,'SS_samp.min',$SS_min_samp,
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 46
diff changeset
   234
				   'SS_allowed_depth_range.max',$SS_max_allowed_depth_range);
34
e550db661c17 pre-Tampa
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 29
diff changeset
   235
				   
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   236
	for (my($bin)=$LADCP_firstBin-1; $bin<=$LADCP_lastBin-1; $bin++) { 	# find backscatter min/max below $search_below in each bin
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   237
		my($minSv,$maxSv,$depthmaxSv,$lastvalid) = (1e99,-1e99,-1,-1);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   238
		for (my($depth)=$search_below; $depth<@nSv; $depth++) {
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   239
			next unless ($nSv[$depth][$bin] > 0);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   240
			my($Sv) = $sSv[$depth][$bin] / $nSv[$depth][$bin];
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   241
			$lastvalid = $depth;
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   242
			$minSv = $Sv if ($Sv < $minSv);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   243
			$maxSv = $Sv, $depthmaxSv = $depth if ($Sv > $maxSv);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   244
		}
28
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   245
		if ($maxSv-$minSv >= $SS_min_signal) { 							# ignore scatter
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   246
			push(@Sv_rng,round($maxSv-$minSv));
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   247
			push(@wdepth,$depthmaxSv);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   248
		}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   249
	}
27
2053d8de8d6b updated plots & seabed code; GoM data process correctly
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 18
diff changeset
   250
28
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   251
	if (@wdepth) {
45
6d49c7420a6c stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 42
diff changeset
   252
		info("\t%d bins with seabed signatures found (\@Sv_rng: @Sv_rng)\n",scalar(@wdepth));
28
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   253
    } else {
45
6d49c7420a6c stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 42
diff changeset
   254
		info("\tno bins with seabed signatures found\n");
28
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   255
    }
b07b23485336 after folding in EGU flight mods (empirical Sv correction)
A.M. Thurnherr <athurnherr@yahoo.com>
parents: 27
diff changeset
   256
	return (undef,undef) if (scalar(@wdepth) < $SS_min_samp);			# require min number of samples
0
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   257
	
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   258
	my($wd) = median(@wdepth);
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   259
	return ($wd,mad2($wd,@wdepth));
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   260
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   261
}
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   262
3365828b1004 after DIMES UK2
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
diff changeset
   263
1;