author | A.M. Thurnherr <athurnherr@yahoo.com> |
Thu, 19 May 2016 09:38:56 -0400 | |
changeset 45 | 6d49c7420a6c |
parent 15 | dfcb6bef9d42 |
child 46 | cc6c4309828a |
permissions | -rw-r--r-- |
0 | 1 |
#====================================================================== |
2 |
# S V E L _ C O R R E C T I O N S . P L |
|
3 |
# doc: Thu Dec 30 01:35:18 2010 |
|
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
15
diff
changeset
|
4 |
# dlm: Thu May 19 00:51:30 2016 |
0 | 5 |
# (c) 2010 A.M. Thurnherr |
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
15
diff
changeset
|
6 |
# uE-Info: 19 65 NIL 0 0 72 0 2 4 NIL ofnI |
0 | 7 |
#====================================================================== |
8 |
||
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
9 |
# HISTORY: |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
10 |
# Dec 30, 2010: - created |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
11 |
# Oct 5, 2011: - sscorr_w temporarily disabled |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
12 |
# - re-enabled |
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
13 |
# Oct 26, 2011: - BUG? in calc_binDepth() on very shallow station 38 in |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
14 |
# 2010 Gom Spill data set the uplooker code did not stop |
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
15 |
# at the surface, requiring additon of another test |
15 | 16 |
# Mar 4, 2014: - added support for missing TILT (PITCH/ROLL) |
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
15
diff
changeset
|
17 |
# May 12, 2016: - removed unused lines of code |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
15
diff
changeset
|
18 |
# May 18, 2016: - removed assumption of 1500m/s soundspeed setting |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
15
diff
changeset
|
19 |
# - made sscorr_w return nan on undef'd input vel |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
20 |
|
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
21 |
# NOTES: |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
22 |
# In an effort to track down the scale bias, NBP0901 stn 160 was reprocessed with various |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
23 |
# simplified soundspeed correction methods: |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
24 |
# 1) no sscorr: bias is depth dependent and disappears btw 2500 and 3000m |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
25 |
# 2) simplified (dBin/dADCP): very similar to full correction, esp. when dBin is used |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
26 |
# 3) hacked correction (1450m/s vs 1500m/s assumed soundspeed) => bias largely disappears |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
27 |
|
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
15
diff
changeset
|
28 |
sub sscorr_w($$$$$) # sound-speed correction for w |
0 | 29 |
{ # see RDI Coord. Trans. manual sec. 4.1, ... |
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
15
diff
changeset
|
30 |
my($wObs,$wCTD,$ssADCP,$dADCP,$dBin) = @_; # but there is an error: the ^2 applies to the [] |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
15
diff
changeset
|
31 |
return nan unless numberp($wObs); |
0 | 32 |
my($tanSqBeamAngle) = tan(rad($LADCP{BEAM_ANGLE}))**2; |
33 |
||
34 |
$dADCP = int($dADCP); # @sVelProf is binned to 1m |
|
35 |
$dBin = int($dBin); |
|
36 |
||
37 |
while (!numberp($sVelProf[$dADCP])) { $dADCP--; } # skip gaps & bottom of profile |
|
38 |
while (!numberp($sVelProf[$dBin ])) { $dBin--; } |
|
39 |
||
40 |
my($Kn) = sqrt(1 + (1 - $sVelProf[$dBin]/$sVelProf[$dADCP])**2 * $tanSqBeamAngle); |
|
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
15
diff
changeset
|
41 |
return ($wObs*$sVelProf[$dBin]/$ssADCP - $wCTD) / $Kn; # full correction |
0 | 42 |
} |
43 |
||
44 |
sub calc_binDepths($) # see RDI Coord Trans manual sec. 4.2 |
|
45 |
{ |
|
46 |
my($ens) = @_; |
|
47 |
my(@bindz); |
|
48 |
||
15 | 49 |
# if the following assertion fails, the entire code needs to be searched for |
50 |
# each call of calc_binDepths() needs to be protected by a test |
|
51 |
die("ensemble $ens") unless defined($LADCP{ENSEMBLE}[$ens]->{TILT}); |
|
52 |
||
0 | 53 |
my($tanSqBeamAngle) = tan(rad($LADCP{BEAM_ANGLE}))**2; |
54 |
my($curdz) = 0; # calc avg sndspeed btw transducer & 1st bin |
|
55 |
$curdz-- until numberp($sVelProf[int($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}+$curdz)]); |
|
56 |
my($avgss) = my($ADCPss) = $sVelProf[int($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}+$curdz)]; |
|
57 |
||
58 |
my($sumss) = my($nss) = 0; |
|
59 |
if ($LADCP{ENSEMBLE}[$ens]->{XDUCER_FACING_UP}) { |
|
60 |
while ($curdz >= -$LADCP{DISTANCE_TO_BIN1_CENTER}*cos(rad($LADCP{ENSEMBLE}[$ens]->{TILT}))) { |
|
61 |
if (numberp($sVelProf[int($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}+$curdz)])) { |
|
62 |
$sumss += $sVelProf[int($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}+$curdz)]; $nss++; |
|
63 |
} |
|
64 |
$curdz--; |
|
65 |
} |
|
66 |
} else { |
|
67 |
while ($curdz <= $LADCP{DISTANCE_TO_BIN1_CENTER}*cos(rad($LADCP{ENSEMBLE}[$ens]->{TILT}))) { |
|
68 |
if (numberp($sVelProf[int($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}+$curdz)])) { |
|
69 |
$sumss += $sVelProf[int($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}+$curdz)]; $nss++; |
|
70 |
} |
|
71 |
$curdz++; |
|
72 |
} |
|
73 |
} |
|
74 |
$avgss = $sumss/$nss if ($nss>0); |
|
75 |
||
76 |
my($Kn) = sqrt(1 + (1 - $avgss/$ADCPss)**2 * $tanSqBeamAngle); |
|
77 |
$bindz[0] = $LADCP{ENSEMBLE}[$ens]->{XDUCER_FACING_UP} ? |
|
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
15
diff
changeset
|
78 |
- $LADCP{DISTANCE_TO_BIN1_CENTER}*$Kn*$avgss/$LADCP{ENSEMBLE}[$ens]->{SPEED_OF_SOUND}*cos(rad($LADCP{ENSEMBLE}[$ens]->{TILT})) : |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
15
diff
changeset
|
79 |
+ $LADCP{DISTANCE_TO_BIN1_CENTER}*$Kn*$avgss/$LADCP{ENSEMBLE}[$ens]->{SPEED_OF_SOUND}*cos(rad($LADCP{ENSEMBLE}[$ens]->{TILT})); |
0 | 80 |
|
81 |
for (my($bin)=1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
82 |
$sumss = $nss = 0; |
|
83 |
if ($LADCP{ENSEMBLE}[$ens]->{XDUCER_FACING_UP}) { |
|
84 |
while ($curdz >= $bindz[$bin-1]-$LADCP{BIN_LENGTH}*cos(rad($LADCP{ENSEMBLE}[$ens]->{TILT}))) { |
|
5
509cc9966b68
======================================================================
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
3
diff
changeset
|
85 |
last unless (int($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}+$curdz) >= 0); |
0 | 86 |
if (numberp($sVelProf[int($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}+$curdz)])) { |
87 |
$sumss += $sVelProf[int($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}+$curdz)]; $nss++; |
|
88 |
} |
|
89 |
$curdz--; |
|
90 |
} |
|
91 |
} else { |
|
92 |
while ($curdz <= $bindz[$bin-1]+$LADCP{BIN_LENGTH}*cos(rad($LADCP{ENSEMBLE}[$ens]->{TILT}))) { |
|
93 |
if (numberp($sVelProf[int($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}+$curdz)])) { |
|
94 |
$sumss += $sVelProf[int($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}+$curdz)]; $nss++; |
|
95 |
} |
|
96 |
$curdz++; |
|
97 |
} |
|
98 |
} |
|
99 |
$avgss = $sumss/$nss if ($nss > 0); # otherwise, leave avgss as is |
|
100 |
||
101 |
$Kn = sqrt(1 + (1 - $avgss/$ADCPss)**2 * $tanSqBeamAngle); |
|
102 |
$bindz[$bin] = $LADCP{ENSEMBLE}[$ens]->{XDUCER_FACING_UP} ? |
|
45
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
15
diff
changeset
|
103 |
$bindz[$bin-1] - $LADCP{BIN_LENGTH}*$Kn*$avgss/$LADCP{ENSEMBLE}[$ens]->{SPEED_OF_SOUND}*cos(rad($LADCP{ENSEMBLE}[$ens]->{TILT})) : |
6d49c7420a6c
stable V1.3beta, just before implementing bin interpolation
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
15
diff
changeset
|
104 |
$bindz[$bin-1] + $LADCP{BIN_LENGTH}*$Kn*$avgss/$LADCP{ENSEMBLE}[$ens]->{SPEED_OF_SOUND}*cos(rad($LADCP{ENSEMBLE}[$ens]->{TILT})); |
0 | 105 |
} |
106 |
||
107 |
my(@bindepth); |
|
108 |
for (my($i)=0; $i<@bindz; $i++) { |
|
109 |
$bindepth[$i] = $LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH} + $bindz[$i]; |
|
110 |
} |
|
111 |
return @bindepth; |
|
112 |
} |
|
113 |
||
114 |
1; |