author | A.M. Thurnherr <athurnherr@yahoo.com> |
Thu, 12 May 2016 10:54:28 -0400 | |
changeset 44 | 515c353a31bd |
parent 15 | dfcb6bef9d42 |
child 45 | 6d49c7420a6c |
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 |
|
15 | 4 |
# dlm: Thu Apr 17 09:02:29 2014 |
0 | 5 |
# (c) 2010 A.M. Thurnherr |
15 | 6 |
# uE-Info: 49 24 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) |
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
17 |
|
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
18 |
# NOTES: |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
19 |
# 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
|
20 |
# simplified soundspeed correction methods: |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
21 |
# 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
|
22 |
# 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
|
23 |
# 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
|
24 |
|
0 | 25 |
sub sscorr_w($$$$) # sound-speed correction for w |
26 |
{ # see RDI Coord. Trans. manual sec. 4.1, ... |
|
27 |
my($wObs,$wCTD,$dADCP,$dBin) = @_; # but there is an error: the ^2 applies to the [] |
|
28 |
my($tanSqBeamAngle) = tan(rad($LADCP{BEAM_ANGLE}))**2; |
|
29 |
||
30 |
$dADCP = int($dADCP); # @sVelProf is binned to 1m |
|
31 |
$dBin = int($dBin); |
|
32 |
||
33 |
while (!numberp($sVelProf[$dADCP])) { $dADCP--; } # skip gaps & bottom of profile |
|
34 |
while (!numberp($sVelProf[$dBin ])) { $dBin--; } |
|
35 |
||
36 |
my($Kn) = sqrt(1 + (1 - $sVelProf[$dBin]/$sVelProf[$dADCP])**2 * $tanSqBeamAngle); |
|
3
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
37 |
### return $wObs - $wCTD; # no correction |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
38 |
### return ($wObs*$sVelProf[$dBin]/1500 - $wCTD); # simplified correction; dADCP instead of dBin similar |
9c021fdea1ff
Before replacing command-line options by default variables.
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
0
diff
changeset
|
39 |
return ($wObs*$sVelProf[$dBin]/1500 - $wCTD) / $Kn; # full correction |
0 | 40 |
} |
41 |
||
42 |
sub calc_binDepths($) # see RDI Coord Trans manual sec. 4.2 |
|
43 |
{ |
|
44 |
my($ens) = @_; |
|
45 |
my(@bindz); |
|
46 |
||
15 | 47 |
# if the following assertion fails, the entire code needs to be searched for |
48 |
# each call of calc_binDepths() needs to be protected by a test |
|
49 |
die("ensemble $ens") unless defined($LADCP{ENSEMBLE}[$ens]->{TILT}); |
|
50 |
||
0 | 51 |
my($tanSqBeamAngle) = tan(rad($LADCP{BEAM_ANGLE}))**2; |
52 |
my($curdz) = 0; # calc avg sndspeed btw transducer & 1st bin |
|
53 |
$curdz-- until numberp($sVelProf[int($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}+$curdz)]); |
|
54 |
my($avgss) = my($ADCPss) = $sVelProf[int($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}+$curdz)]; |
|
55 |
||
56 |
my($sumss) = my($nss) = 0; |
|
57 |
if ($LADCP{ENSEMBLE}[$ens]->{XDUCER_FACING_UP}) { |
|
58 |
while ($curdz >= -$LADCP{DISTANCE_TO_BIN1_CENTER}*cos(rad($LADCP{ENSEMBLE}[$ens]->{TILT}))) { |
|
59 |
if (numberp($sVelProf[int($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}+$curdz)])) { |
|
60 |
$sumss += $sVelProf[int($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}+$curdz)]; $nss++; |
|
61 |
} |
|
62 |
$curdz--; |
|
63 |
} |
|
64 |
} else { |
|
65 |
while ($curdz <= $LADCP{DISTANCE_TO_BIN1_CENTER}*cos(rad($LADCP{ENSEMBLE}[$ens]->{TILT}))) { |
|
66 |
if (numberp($sVelProf[int($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}+$curdz)])) { |
|
67 |
$sumss += $sVelProf[int($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}+$curdz)]; $nss++; |
|
68 |
} |
|
69 |
$curdz++; |
|
70 |
} |
|
71 |
} |
|
72 |
$avgss = $sumss/$nss if ($nss>0); |
|
73 |
||
74 |
my($Kn) = sqrt(1 + (1 - $avgss/$ADCPss)**2 * $tanSqBeamAngle); |
|
75 |
$bindz[0] = $LADCP{ENSEMBLE}[$ens]->{XDUCER_FACING_UP} ? |
|
76 |
- $LADCP{DISTANCE_TO_BIN1_CENTER}*$Kn*$avgss/1500*cos(rad($LADCP{ENSEMBLE}[$ens]->{TILT})) : |
|
77 |
+ $LADCP{DISTANCE_TO_BIN1_CENTER}*$Kn*$avgss/1500*cos(rad($LADCP{ENSEMBLE}[$ens]->{TILT})); |
|
78 |
||
79 |
for (my($bin)=1; $bin<=$LADCP_lastBin-1; $bin++) { |
|
80 |
$sumss = $nss = 0; |
|
81 |
if ($LADCP{ENSEMBLE}[$ens]->{XDUCER_FACING_UP}) { |
|
82 |
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
|
83 |
last unless (int($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}+$curdz) >= 0); |
0 | 84 |
if (numberp($sVelProf[int($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}+$curdz)])) { |
85 |
$sumss += $sVelProf[int($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}+$curdz)]; $nss++; |
|
86 |
} |
|
87 |
$curdz--; |
|
88 |
} |
|
89 |
} else { |
|
90 |
while ($curdz <= $bindz[$bin-1]+$LADCP{BIN_LENGTH}*cos(rad($LADCP{ENSEMBLE}[$ens]->{TILT}))) { |
|
91 |
if (numberp($sVelProf[int($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}+$curdz)])) { |
|
92 |
$sumss += $sVelProf[int($LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH}+$curdz)]; $nss++; |
|
93 |
} |
|
94 |
$curdz++; |
|
95 |
} |
|
96 |
} |
|
97 |
$avgss = $sumss/$nss if ($nss > 0); # otherwise, leave avgss as is |
|
98 |
||
99 |
$Kn = sqrt(1 + (1 - $avgss/$ADCPss)**2 * $tanSqBeamAngle); |
|
100 |
$bindz[$bin] = $LADCP{ENSEMBLE}[$ens]->{XDUCER_FACING_UP} ? |
|
101 |
$bindz[$bin-1] - $LADCP{BIN_LENGTH}*$Kn*$avgss/1500*cos(rad($LADCP{ENSEMBLE}[$ens]->{TILT})) : |
|
102 |
$bindz[$bin-1] + $LADCP{BIN_LENGTH}*$Kn*$avgss/1500*cos(rad($LADCP{ENSEMBLE}[$ens]->{TILT})); |
|
103 |
} |
|
104 |
||
105 |
my(@bindepth); |
|
106 |
for (my($i)=0; $i<@bindz; $i++) { |
|
107 |
$bindepth[$i] = $LADCP{ENSEMBLE}[$ens]->{CTD_DEPTH} + $bindz[$i]; |
|
108 |
} |
|
109 |
return @bindepth; |
|
110 |
} |
|
111 |
||
112 |
1; |