author | A.M. Thurnherr <athurnherr@yahoo.com> |
Wed, 16 May 2012 06:57:47 +0000 | |
changeset 11 | d0af7f7aa23b |
parent 10 | 196a179304ee |
child 12 | 65582c172355 |
permissions | -rwxr-xr-x |
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 P R O C |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
4 |
# doc: Thu Sep 16 20:36:10 2010 |
11 | 5 |
# dlm: Wed May 16 06:54:18 2012 |
8 | 6 |
# (c) 2010 A.M. Thurnherr |
11 | 7 |
# uE-Info: 79 14 NIL 0 0 72 10 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 = 'process LADCP data to get shear, time series'; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
11 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
12 |
# NOTES: |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
13 |
# - the shear-method editing in this code is based on Eric Firing's merge.c |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
14 |
# - as described in [LADCPproc.backscatter], there are three different codes |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
15 |
# for correcting echo amplitudes for attenuation loss & beam spreading |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
16 |
# - comments starting with ## are taken verbatim from the original implementations |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
17 |
# - the basic idea of the time lagging implemented in this code is similar |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
18 |
# to the one implemented in Martin Visbeck's bestlag.m |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
19 |
# - for SeaBird files: |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
20 |
# - CTD elapsed time is estimated from recno * CTD{sampint} |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
21 |
# - first elapsed time is added on output |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
22 |
# - output elapsed time is from CTD to allow yoyo processing without loss of |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
23 |
# time information |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
24 |
# - CTD{elapsed} is undefined for records before instrument is in the water |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
25 |
# - ITS-90 temp field in degC required |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
26 |
# - salin field prequired |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
27 |
# - pressure field in dbar required |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
28 |
# - -i should be set to the number that's added to LADCP_elapsed to make the two |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
29 |
# time series overplot nicely |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
30 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
31 |
# HISTORY: |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
32 |
# Sep 16, 2010: - incepted |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
33 |
# Oct 13, 2010: - first working version |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
34 |
# Oct 14, 2010: - renamed from LADCPshear |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
35 |
# Oct 19, 2010: - added -a)coustic backscatter profiles |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
36 |
# Oct 20, 2010: - added -2)dary CTD sensors |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
37 |
# Oct 23, 2010: - added magnetic-declination correction |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
38 |
# Oct 26, 2010: - added tilt calculation |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
39 |
# Dec 9, 2010: - added support for ASCII CTD files |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
40 |
# Dec 10, 2010: - change -w) default to 120s |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
41 |
# - changed nshear output to 0 from nan when there are no samples |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
42 |
# Dec 27, 2010: - changed sign of -l to accept lag output from [LADCP_w] |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
43 |
# Jan 10, 2011: - -o => -k added new -o |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
44 |
# - added code to fill CTD sound vel gaps |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
45 |
# Jan 22, 2011: - added -g) lat,lon |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
46 |
# - added -c)ompass corr |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
47 |
# Jun 15, 2011: - added mean backscatter profile to default output |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
48 |
# Jul 7, 2011: - added support for $BT_* processing parameters |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
49 |
# - replaced old per-bin acoustic backscatter profile output by |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
50 |
# acoustic backscatter depth-time-series |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
51 |
# - disabled seabed and acoustic backscatter code when not required (e.g. UL) |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
52 |
# - made non-diagnostic output terser |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
53 |
# Jul 11, 2011: - changed default output to .tds and added -p)rofile option |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
54 |
# Jul 14, 2011: - added -u)se D[eines1999][V[isbeck2004]] |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
55 |
# Jul 15, 2011: - changed output bin# to 1-based in -a output |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
56 |
# - added T[hurnherr11] -u)se option |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
57 |
# - added $CTD{first_elapsed} |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
58 |
# Jul 27, 2011: - replaced ndata by nsamp |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
59 |
# Feb 5, 2012: - added profile max depth consistency check |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
60 |
# Feb 19, 2912: - added elapsed time to shear profile output |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
61 |
# - replaced "nshear" output field by "nsamp" |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
62 |
# - BUG: bottom of profiles was incorrect when dc max depth > uc max depth |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
63 |
# - BUG: profile depth consistency check did not work for partial-depth yoyo casts |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
64 |
# Apr 10, 2012: - changed default backscatter correction to Deines (1999) |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
65 |
# - improved and relaxed depth consistency check |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
66 |
# Apr 11, 2012: - BUG: double comma that did not affect the output |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
67 |
# - BUG: code had assumed, but not ensured, that first CTD scan is valid |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
68 |
# Apr 13, 2012: - removed -s argument from dependencies |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
69 |
# Apr 17, 2012: - BAD BUG: magdec code call was bad and did not return correct value. ever. |
10 | 70 |
# Apr 18, 2012: - replaced Sv.n by Sv.nsamp |
11 | 71 |
# May 16, 2012: - adapted to ANTSlib V5.0 |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
72 |
|
11 | 73 |
($ANTS) = (`which ANTSlib` =~ m{^(.*)/[^/]*$}); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
74 |
($PERL_TOOLS) = (`which mkProfile` =~ m{^(.*)/[^/]*$}); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
75 |
($LADCPPROC) = ($0 =~ m{^(.*)/[^/]*$}); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
76 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
77 |
require "$ANTS/ants.pl"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
78 |
require "$ANTS/libEOS83.pl"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
79 |
require "$ANTS/libstats.pl"; |
1 | 80 |
require "$LADCPPROC/LADCPproc.loadCTD"; |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
81 |
require "$LADCPPROC/LADCPproc.bestLag"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
82 |
require "$LADCPPROC/LADCPproc.BT"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
83 |
require "$LADCPPROC/LADCPproc.backscatter"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
84 |
require "$LADCPPROC/LADCPproc.UHcode"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
85 |
require "$PERL_TOOLS/RDI_BB_Read.pl"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
86 |
require "$PERL_TOOLS/RDI_Coords.pl"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
87 |
require "$PERL_TOOLS/RDI_Utils.pl"; |
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 |
$antsParseHeader = 0; |
6 | 90 |
&antsUsage('24a:b:c:df:g:i:kl:n:o:p:s:t:u:w:',2, |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
91 |
'[use -2)dary CTD sensor pair]', |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
92 |
'[require -4)-beam LADCP solutions]', |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
93 |
'[-s)etup <file>] [-g)ps <lat,lon>]', |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
94 |
'[-c)ompass-corr <offset,cos-fac,sin-fac>]', |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
95 |
'[enable -p)PI editing]', |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
96 |
'[-o)utput grid <resolution[5m]>]', |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
97 |
'[-i)nitial LADCP time lag <guestimate>]', |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
98 |
'[-l)ag LADCP <by>] [auto-lag -w)indow <size[120s]>] [-n) <auto-lag windows[20]]', |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
99 |
'[correct echo amplitude -u)sing D[eines99]|V[isbeck04]|T[hurnherr11]|n[ocorr]', |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
100 |
'[-d)iagnostic screen output]', |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
101 |
'output: [shear-p)rofile <file>] [-t)ime series <file>] [-f)lag <file>] [-b)ottom-track <file>]', |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
102 |
' [-a)coustic backscatter <dts-file] [bottom-trac-k) profs]', |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
103 |
'<RDI file> <SeaBird file>'); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
104 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
105 |
$RDI_Coords::minValidVels = 4 if ($opt_4); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
106 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
107 |
&antsFloatOpt($opt_l); |
1 | 108 |
&antsCardOpt(\$opt_w,120); |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
109 |
# old default of -w 30 does not work if there are significant ambiguity-velocity |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
110 |
# problems, as is the case, e.g., with 2010_DIMES_US2 station 142 |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
111 |
# old default of -w 60 did not work for DIMES_UK2 station 4 (DL), possibly again |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
112 |
# related to ambiguity velocity |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
113 |
&antsCardOpt(\$opt_n,20); |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
114 |
#&antsFileOpt($opt_s); # DON'T, AS THIS WILL ADD AN UNWANTED DEPENDCY |
1 | 115 |
&antsFloatOpt($opt_i); |
4 | 116 |
&antsCardOpt(\$opt_o,5); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
117 |
|
6 | 118 |
if (defined($opt_u)) { |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
119 |
croak("$0: cannot decode -u $opt_u\n") |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
120 |
unless ($opt_u =~ /^[dDvVtTn]/); |
6 | 121 |
} else { |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
122 |
$opt_u = 'Deines99'; |
6 | 123 |
} |
124 |
||
2 | 125 |
if (defined($opt_g)) { |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
126 |
($CTD{lat},$CTD{lon}) = split(',',$opt_g); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
127 |
croak("$0: cannot decode -g $opt_g\n") |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
128 |
unless numberp($CTD{lat}) && numberp($CTD{lon}); |
2 | 129 |
} |
130 |
||
131 |
if (defined($opt_c)) { |
|
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
132 |
($CC_offset,$CC_cos_fac,$CC_sin_fac) = split(',',$opt_c); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
133 |
croak("$0: cannot decode -c $opt_c\n") |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
134 |
unless numberp($CC_offset) && numberp($CC_cos_fac) && numberp($CC_sin_fac); |
2 | 135 |
} |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
136 |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
137 |
$LADCP_file = &antsFileArg(); |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
138 |
$CTD_file = &antsFileArg(); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
139 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
140 |
&antsAddParams('LADCP_file',$LADCP_file,'CTD_file',$CTD_file); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
141 |
&antsActivateOut(); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
142 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
143 |
#---------------------------------------------------------------------- |
1 | 144 |
# Step 1: Read LADCP Data |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
145 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
146 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
147 |
print(STDERR "Reading LADCP data ($LADCP_file)..."); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
148 |
readData($LADCP_file,\%LADCP); |
3 | 149 |
printf(STDERR "\n\t%d ensembles",scalar(@{$LADCP{ENSEMBLE}})) if ($opt_d); |
150 |
print(STDERR "\n"); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
151 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
152 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
153 |
# Step 2: Set Processing Parameters |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
154 |
#---------------------------------------------------------------------- |
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 |
print(STDERR "Setting processing parameters...\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
157 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
158 |
printf(STDERR "\tloading $LADCPPROC/LADCPproc.defaults...\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
159 |
require "$LADCPPROC/LADCPproc.defaults"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
160 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
161 |
if (defined($opt_s)) { |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
162 |
print(STDERR "\tloading $opt_s...\n"); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
163 |
require $opt_s; |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
164 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
165 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
166 |
if ($LADCP{BLANKING_DISTANCE} == 0) { |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
167 |
print(STDERR "\t\tBLANKING_DISTANCE == 0 => excluding all data from bin 1\n") |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
168 |
if ($opt_d); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
169 |
$wbin_start = 2 unless ($wbin_start > 2); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
170 |
$ubin_start = 2 unless ($ubin_start > 2); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
171 |
$shbin_start = 2 unless ($shbin_start > 2); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
172 |
$BT_bin_start = 2 unless ($BT_bin_start > 2); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
173 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
174 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
175 |
&antsAddParams('ADCP_orientation', |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
176 |
$LADCP{ENSEMBLE}[0]->{XDUCER_FACING_UP} ? 'uplooker' : 'downlooker'); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
177 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
178 |
$SHEAR_PREGRID_DZ = 20; |
4 | 179 |
$GRID_DZ = $opt_o; |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
180 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
181 |
#---------------------------------------------------------------------- |
1 | 182 |
# Step 3: Read CTD data |
183 |
#---------------------------------------------------------------------- |
|
184 |
||
185 |
print(STDERR "Reading CTD data ($CTD_file)..."); |
|
186 |
readCTD($CTD_file,\%CTD); |
|
3 | 187 |
printf(STDERR "\n\t%d scans",scalar(@{$CTD{press}})) if ($opt_d); |
188 |
print(STDERR "\n"); |
|
1 | 189 |
|
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
190 |
my($year) = substr($LADCP{ENSEMBLE}[0]->{DATE},6,4); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
191 |
my($month) = substr($LADCP{ENSEMBLE}[0]->{DATE},0,2); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
192 |
my($day ) = substr($LADCP{ENSEMBLE}[0]->{DATE},3,2); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
193 |
my($magdec,$maginc,$h_strength,$v_strength) = split('\s+',`magdec $CTD{lon} $CTD{lat} $year $month $day`); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
194 |
|
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
195 |
croak("$0: unknown magnetic declination\n") |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
196 |
unless defined($magdec); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
197 |
|
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
198 |
&antsAddParams('magnetic_declination',$magdec); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
199 |
|
1 | 200 |
#---------------------------------------------------------------------- |
201 |
# Step 4: Pre-Process CTD & LADCP Data |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
202 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
203 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
204 |
printf(STDERR "Pre-processing data..."); |
3 | 205 |
printf(STDERR "\n\tCTD...") if ($opt_d); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
206 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
207 |
#------------------------ |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
208 |
# clean CTD pressure data |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
209 |
#------------------------ |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
210 |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
211 |
my($pSpikes) = 0; |
1 | 212 |
for (my($r)=1; $r<@{$CTD{press}}; $r++) { |
213 |
$pSpikes++,$CTD{press}[$r]=nan |
|
214 |
if (abs($CTD{press}[$r]-$CTD{press}[$r-1])/$CTD{sampint} > 2); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
215 |
} |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
216 |
print(STDERR "\n\t\t$pSpikes CTD pressure spikes removed") |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
217 |
if ($pSpikes>0 && $opt_d); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
218 |
|
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
219 |
#----------------------------------- |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
220 |
# trim "preamble" without valid data |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
221 |
#----------------------------------- |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
222 |
|
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
223 |
my($r) = 0; |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
224 |
until (numberp($CTD{press}[$r]) && numberp($CTD{temp}[$r]) && numberp($CTD{salin}[$r])) { $r++ } |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
225 |
splice(@{$CTD{press}},0,$r); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
226 |
splice(@{$CTD{temp}},0,$r); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
227 |
splice(@{$CTD{salin}},0,$r); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
228 |
print(STDERR "\n\t\t$r leading CTD scans without valid data removed") |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
229 |
if ($r>0 && $opt_d); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
230 |
|
7 | 231 |
#-------------------------------------------------- |
232 |
# calculate w and find deepest & shallowest records |
|
233 |
#-------------------------------------------------- |
|
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
234 |
|
1 | 235 |
$CTD{maxpress} = -9e99; |
7 | 236 |
$CTD{minpress} = 9e99; |
1 | 237 |
for (my($r)=1; $r<@{$CTD{press}}-1; $r++) { |
238 |
$CTD{w}[$r] = 0.99*($CTD{press}[$r+1] - $CTD{press}[$r-1]) / (2*$CTD{sampint}); |
|
239 |
if ($CTD{press}[$r] > $CTD{maxpress}) { |
|
240 |
$CTD{maxpress} = $CTD{press}[$r]; |
|
241 |
$CTD{atbottom} = $r; |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
242 |
} |
7 | 243 |
if ($CTD{press}[$r] < $CTD{minpress}) { |
244 |
$CTD{minpress} = $CTD{press}[$r]; |
|
245 |
$CTD{attop} = $r; |
|
246 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
247 |
} |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
248 |
printf(STDERR "\n\t\tmin/max pressure [%d/%ddbar] at scans#%d/%d", |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
249 |
$CTD{minpress},$CTD{maxpress},$CTD{attop},$CTD{atbottom}) |
1 | 250 |
if $opt_d; |
251 |
||
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
252 |
#---------------------------------------------------------------------- |
1 | 253 |
# Step 4b: Pre-Process LADCP Data |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
254 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
255 |
|
3 | 256 |
print(STDERR "\n\tLADCP...") if ($opt_d); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
257 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
258 |
#------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
259 |
# transform to earth coordinates if required |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
260 |
#------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
261 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
262 |
$U = 0; # velocity indices |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
263 |
$V = 1; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
264 |
$W = 2; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
265 |
$E = 3; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
266 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
267 |
$LADCP{HEADING_BIAS} = -$magdec; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
268 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
269 |
if ($LADCP{BEAM_COORDINATES}) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
270 |
print(STDERR "\n\t\ttransforming beam to Earth coordinates...") |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
271 |
if ($opt_d); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
272 |
for (my($ens)=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
273 |
$LADCP{ENSEMBLE}[$ens]->{TILT} = &angle_from_vertical($LADCP{ENSEMBLE}[$ens]->{PITCH},$LADCP{ENSEMBLE}[$ens]->{ROLL}); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
274 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
275 |
@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]} = |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
276 |
velInstrumentToEarth(\%LADCP,$ens,velBeamToInstrument(\%LADCP,@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]})); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
277 |
@{$LADCP{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$bin]} = # fake it to fool ref_lr_w |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
278 |
(0,0,0,defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W]) ? 100 : 0); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
279 |
} |
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 |
$LADCP{BEAM_COORDINATES} = 0; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
282 |
$LADCP{EARTH_COORDINATES} = 1; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
283 |
unless ($opt_4) { |
1 | 284 |
print(STDERR "\n\t\t\t3-beam solutions: $RDI_Coords::threeBeam_1 $RDI_Coords::threeBeam_2 $RDI_Coords::threeBeam_3 $RDI_Coords::threeBeam_4\n") |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
285 |
if ($opt_d); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
286 |
&antsAddParams('3_beam_solutions',"$RDI_Coords::threeBeam_1 $RDI_Coords::threeBeam_2 $RDI_Coords::threeBeam_3 $RDI_Coords::threeBeam_4"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
287 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
288 |
} elsif ($LADCP{EARTH_COORDINATES}) { |
2 | 289 |
if ($opt_d) { |
290 |
if ($opt_c) { |
|
291 |
printf(STDERR "\n\t\tcalculating tilt and correcting for compass error and magnetic declination of %.1f deg...\n",$magdec); |
|
292 |
} else { |
|
293 |
printf(STDERR "\n\t\tcalculating tilt and correcting for magnetic declination of %.1f deg...\n",$magdec); |
|
294 |
} |
|
295 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
296 |
for (my($ens)=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
297 |
$LADCP{ENSEMBLE}[$ens]->{TILT} = &angle_from_vertical($LADCP{ENSEMBLE}[$ens]->{PITCH},$LADCP{ENSEMBLE}[$ens]->{ROLL}); |
2 | 298 |
my($hdg) = rad($LADCP{ENSEMBLE}[$ens]->{HEADING}); |
299 |
$LADCP{HEADING_BIAS} = ($CC_offset + $CC_cos_fac*cos($hdg) + $CC_sin_fac*sin($hdg)) - $magdec |
|
300 |
if ($opt_c); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
301 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
302 |
@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]} = |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
303 |
velApplyHdgBias(\%LADCP,$ens,@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]}); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
304 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
305 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
306 |
} else { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
307 |
croak("$0: can only handle beam or earth coordinates\n") |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
308 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
309 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
310 |
#------------------------------------------------------ |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
311 |
# construct a depth-vs-time "profile" from the raw data |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
312 |
#------------------------------------------------------ |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
313 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
314 |
print(STDERR "\t\tconstructing profile time series...") |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
315 |
if ($opt_d); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
316 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
317 |
($LADCP_start,$LADCP_end,$LADCP_bottom,$w_gap_time,$zErr,$maxz) = |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
318 |
mk_prof(\%LADCP,0,undef,1,6,70,0.1,9999); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
319 |
croak("\n$LADCP_file: no good ensembles found\n") |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
320 |
unless defined($LADCP_start); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
321 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
322 |
if ($opt_d) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
323 |
printf(STDERR "\n\t\t\tStart of cast : %s (#%5d) at %6.1fm\n", |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
324 |
$LADCP{ENSEMBLE}[$LADCP_start]->{TIME}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
325 |
$LADCP{ENSEMBLE}[$LADCP_start]->{NUMBER}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
326 |
$LADCP{ENSEMBLE}[$LADCP_start]->{DEPTH}); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
327 |
printf(STDERR "\t\t\tBottom of cast : %s (#%5d) at %6.1fm\n", |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
328 |
$LADCP{ENSEMBLE}[$LADCP_bottom]->{TIME}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
329 |
$LADCP{ENSEMBLE}[$LADCP_bottom]->{NUMBER}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
330 |
$LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH}); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
331 |
printf(STDERR "\t\t\tEnd of cast : %s (#%5d) at %6.1fm", |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
332 |
$LADCP{ENSEMBLE}[$LADCP_end]->{TIME}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
333 |
$LADCP{ENSEMBLE}[$LADCP_end]->{NUMBER}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
334 |
$LADCP{ENSEMBLE}[$LADCP_end]->{DEPTH}); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
335 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
336 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
337 |
print(STDERR "\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
338 |
|
8 | 339 |
my($LADCP_prof_range) = $LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH} - |
340 |
min($LADCP{ENSEMBLE}[$LADCP_start]->{DEPTH},$LADCP{ENSEMBLE}[$LADCP_end]->{DEPTH}); |
|
7 | 341 |
croak(sprintf("$0: LADCP profile depth range (%dm) inconsistent with max CTD pressure range (%ddbar)\n", |
8 | 342 |
$LADCP_prof_range,$CTD{maxpress}-$CTD{minpress})) |
343 |
if (abs($LADCP_prof_range-($CTD{maxpress}-$CTD{minpress}))/(0.99*($CTD{maxpress}-$CTD{minpress})) > 0.2); |
|
6 | 344 |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
345 |
#---------------------------------------------------------------------- |
1 | 346 |
# Step 5: Add CTD to LADCP Data & correct velocities for sound speed |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
347 |
# - {DEPTH} field is overwritten! |
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 |
print(STDERR "Matching CTD to LADCP time series..."); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
351 |
|
1 | 352 |
$opt_l = defined($opt_l) ? -$opt_l : &lagLADCP2CTD(); |
0
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 |
print(STDERR "Associating CTD data with LADCP ensembles..."); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
355 |
|
3 | 356 |
for (my($min_depth)=9e99,my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) { |
357 |
my($lastSvel); |
|
1 | 358 |
my($r) = int(($LADCP{ENSEMBLE}[$ens]->{ELAPSED_TIME} - $opt_l) / $CTD{sampint}); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
359 |
if ($r < 0 && $ens == $LADCP_start) { |
1 | 360 |
$r = int(($LADCP{ENSEMBLE}[++$ens]->{ELAPSED_TIME} - $opt_l) / $CTD{sampint}) |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
361 |
while ($r < 0); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
362 |
printf(STDERR "\n\tCTD data begin with instrument already in water => skipping %ds of LADCP data", |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
363 |
$LADCP{ENSEMBLE}[$ens]->{ELAPSED_TIME}-$LADCP{ENSEMBLE}[$LADCP_start]->{ELAPSED_TIME}); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
364 |
$LADCP_start = $ens; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
365 |
} |
1 | 366 |
if ($r > $#{$CTD{press}}) { |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
367 |
printf(STDERR "\n\tCTD data end while instrument is still in water => truncating %ds of LADCP data", |
3 | 368 |
$LADCP{ENSEMBLE}[$LADCP_end]->{ELAPSED_TIME}-$LADCP{ENSEMBLE}[$ens]->{ELAPSED_TIME}) |
369 |
if ($opt_d); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
370 |
$LADCP_end = $ens - 1; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
371 |
last; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
372 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
373 |
my($dr); |
1 | 374 |
for ($dr=0; !numberp($CTD{press}[$r+$dr]); $dr--) {} |
375 |
$LADCP{ENSEMBLE}[$ens]->{DEPTH} = depth($CTD{press}[$r+$dr],$CTD{lat}); |
|
3 | 376 |
if ($LADCP{ENSEMBLE}[$ens]->{DEPTH} < $min_depth) { |
377 |
$min_depth = $LADCP{ENSEMBLE}[$ens]->{DEPTH}; |
|
378 |
$LADCP_top = $ens; |
|
379 |
} |
|
1 | 380 |
$LADCP{ENSEMBLE}[$ens]->{CTD_W} = $CTD{w}[$r]; |
381 |
$LADCP{ENSEMBLE}[$ens]->{CTD_TEMP} = $CTD{temp}[$r]; |
|
382 |
$LADCP{ENSEMBLE}[$ens]->{CTD_SVEL} = sVel($CTD{salin}[$r],$CTD{temp}[$r],$CTD{press}[$r+$dr]); |
|
383 |
if (numberp($LADCP{ENSEMBLE}[$ens]->{CTD_SVEL})) { |
|
384 |
$lastSvel = $LADCP{ENSEMBLE}[$ens]->{CTD_SVEL}; |
|
385 |
} else { |
|
386 |
$LADCP{ENSEMBLE}[$ens]->{CTD_SVEL} = $lastSvel; |
|
387 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
388 |
my($sscorr) = $LADCP{ENSEMBLE}[$ens]->{CTD_SVEL} / $LADCP{ENSEMBLE}[$ens]->{SPEED_OF_SOUND}; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
389 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
390 |
next unless defined($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
391 |
$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$U] *= $sscorr; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
392 |
$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$V] *= $sscorr; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
393 |
$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W] *= $sscorr; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
394 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
395 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
396 |
|
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
397 |
&antsAddParams('top_depth',round($LADCP{ENSEMBLE}[$LADCP_top]->{DEPTH}), |
3 | 398 |
'bottom_depth',round($LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH}), |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
399 |
'start_date',$LADCP{ENSEMBLE}[$LADCP_start]->{DATE}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
400 |
'start_time',$LADCP{ENSEMBLE}[$LADCP_start]->{TIME}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
401 |
'bottom_date',$LADCP{ENSEMBLE}[$LADCP_bottom]->{DATE}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
402 |
'bottom_time',$LADCP{ENSEMBLE}[$LADCP_bottom]->{TIME}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
403 |
'end_date',$LADCP{ENSEMBLE}[$LADCP_end]->{DATE}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
404 |
'end_time',$LADCP{ENSEMBLE}[$LADCP_end]->{TIME}); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
405 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
406 |
print(STDERR "\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
407 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
408 |
#---------------------------------------------------------------------- |
1 | 409 |
# Step 6: Calculate Acoustic Backscatter Profile |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
410 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
411 |
|
3 | 412 |
print(STDERR "Calculating acoustic backscatter profiles..."); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
413 |
mk_backscatter_profs($LADCP_start,$LADCP_end); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
414 |
print(STDERR "\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
415 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
416 |
#---------------------------------------------------------------------- |
1 | 417 |
# Step 7: Find Seabed |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
418 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
419 |
|
3 | 420 |
if ($LADCP{ENSEMBLE}[$LADCP_start]->{XDUCER_FACING_DOWN}) { |
421 |
||
422 |
print(STDERR "Finding seabed..."); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
423 |
|
3 | 424 |
print(STDERR "\n\tin acoustic backscatter profiles...") if ($opt_d); |
425 |
($water_depth,$sig_water_depth) = |
|
426 |
find_backscatter_seabed($LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH}); |
|
427 |
||
428 |
$min_hab = $water_depth - $LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH}; |
|
429 |
printf(STDERR "\n\twater depth = %d(+-%.1f)m",$water_depth,$sig_water_depth); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
430 |
printf(STDERR "\n\tclosest approach = %dmab",$min_hab); |
3 | 431 |
|
432 |
print(STDERR "\n\tin RDI BT data...") if ($opt_d); |
|
433 |
($BT_water_depth,$sig_BT_water_depth) = |
|
434 |
find_seabed(\%LADCP,$LADCP_bottom,$LADCP{BEAM_COORDINATES}); |
|
435 |
||
436 |
if (defined($BT_water_depth)) { |
|
437 |
$min_hab = $BT_water_depth - $LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH}; |
|
438 |
printf(STDERR "\n\twater depth = %d(+-%.1f)m",$BT_water_depth,$sig_BT_water_depth); |
|
439 |
printf(STDERR "\n\tclosest approach = %dmab",$min_hab); |
|
440 |
# $water_depth = $BT_water_depth; # assume BT data are better |
|
441 |
# $sig_water_depth = $sig_BT_water_depth; # (at least they are higher vertical resolution) |
|
442 |
} |
|
443 |
||
444 |
unless (defined($water_depth)) { |
|
445 |
print(STDERR "\n\tno seabed found\n"); |
|
446 |
print(STDERR "\n\tunknown water depth => PPI editing disabled\n") |
|
447 |
if ($opt_d); |
|
448 |
$clip_margin = 0; |
|
449 |
} |
|
450 |
||
451 |
print(STDERR "\n"); |
|
452 |
||
453 |
} else { # UPLOOKER |
|
454 |
$water_depth = $sig_water_depth = $min_hab = nan; |
|
455 |
print(STDERR "Uplooker data => PPI editing disabled\n") |
|
456 |
if ($opt_d); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
457 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
458 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
459 |
#---------------------------------------------------------------------- |
6 | 460 |
# Step 8: Edit Data & also produce depth-time-series output vial callback |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
461 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
462 |
|
4 | 463 |
print(STDERR "Calculating shear profiles & producing time-depth-series (.tds) output..."); |
464 |
||
465 |
#-------------------------------------------------------------------------------- |
|
466 |
# callback routine to output .tds data, called once each for down-/upcasts after |
|
467 |
# shear has been gridded. Note that only the nominal (bin center) depth is known |
|
468 |
# for each sample in this version. |
|
469 |
||
470 |
sub outTDseries($) |
|
471 |
{ |
|
472 |
my($downcast) = @_; # also use local @[uvw]sh_vals[][] |
|
473 |
||
474 |
if ($downcast) { |
|
475 |
my($mingi); |
|
476 |
for ($mingi=0; $mingi<@ush_vals; $mingi++) { |
|
477 |
last if @{$ush_vals[$mingi]}; |
|
478 |
} |
|
6 | 479 |
&antsAddParams('min_ens',$LADCP_start,'min_elapsed',$LADCP{ENSEMBLE}[$LADCP_start]->{ELAPSED_TIME}+$CTD{first_elapsed}-$opt_l, |
480 |
'max_ens',$LADCP_end,'max_elapsed',$LADCP{ENSEMBLE}[$LADCP_end]->{ELAPSED_TIME}+$CTD{first_elapsed}-$opt_l, |
|
481 |
'min_depth',depthOfGI($mingi),'max_depth',depthOfGI($#ens_vals)); |
|
4 | 482 |
for (my($gi)=0; $gi<@ush_vals; $gi++) { |
6 | 483 |
for (my($i)=0; $i<@{$ush_vals[$gi]}; $i++){ |
484 |
&antsOut($ens_vals[$gi][$i],$LADCP{ENSEMBLE}[$ens_vals[$gi][$i]]->{ELAPSED_TIME}+$CTD{first_elapsed}-$opt_l, |
|
4 | 485 |
$downcast,depthOfGI($gi),$ush_vals[$gi][$i],$vsh_vals[$gi][$i],$wsh_vals[$gi][$i]); |
486 |
} |
|
487 |
} |
|
488 |
} else { |
|
489 |
for (my($gi)=$#ush_vals; $gi>=0; $gi--) { |
|
490 |
for (my($i)=0; $i<@{$ush_vals[$gi]}; $i++) { |
|
6 | 491 |
&antsOut($ens_vals[$gi][$i],$LADCP{ENSEMBLE}[$ens_vals[$gi][$i]]->{ELAPSED_TIME}+$CTD{first_elapsed}-$opt_l, |
4 | 492 |
$downcast,depthOfGI($gi),$ush_vals[$gi][$i],$vsh_vals[$gi][$i],$wsh_vals[$gi][$i]); |
493 |
} |
|
494 |
} |
|
495 |
} |
|
496 |
} # sub outDSseries |
|
497 |
||
498 |
#-------------------------------------------------------------------------------- |
|
499 |
||
500 |
@antsNewLayout = ('ens','elapsed','downcast','depth','u_z','v_z','w_z'); |
|
501 |
$commonParams = $antsCurParams; |
|
502 |
||
503 |
&antsAddParams('ubin_start',$ubin_start,'ubin_end',$ubin_end, # record processing params |
|
504 |
'wbin_start',$wbin_start,'wbin_end',$wbin_end, |
|
505 |
'shbin_start',$shbin_start,'shbin_end',$shbin_end, |
|
506 |
'w_ref_bin',$w_ref_bin,'w_dif',$w_dif, |
|
507 |
'wake_hd_dif',$wake_hd_dif,'wake_ang_min',$wake_ang_min, |
|
508 |
'min_wake_w',$min_wake_w,'n_wake_bins',$n_wake_bins, |
|
509 |
'e_max',$e_max,'min_cor',$min_cor, |
|
510 |
'max_shdev',$max_shdev,'max_shdev_sum',$max_shdev_sum, |
|
511 |
'water_depth',round($water_depth),'water_depth.sig',round($sig_water_depth), |
|
512 |
'min_hab',round($min_hab),'PPI_editing_enabled',$PPI_editing_enabled, |
|
513 |
'clip_margin',$clip_margin,'first_clip_bin',$first_clip_bin, |
|
514 |
'Svbin_start',$Svbin_start,'Svbin_end',$Svbin_end, |
|
515 |
'BT_bin_start',$BT_bin_start,'BT_bin_search_above',$BT_bin_search_above, |
|
516 |
'BT_max_bin_spread',$BT_max_bin_spread,'BT_max_w_difference',$BT_max_w_difference, |
|
517 |
); |
|
518 |
if (defined($BT_min_depth)) { |
|
519 |
&antsAddParams('BT_min_depth',$BT_min_depth,'BT_max_depth',$BT_max_depth); |
|
520 |
} else { |
|
521 |
&antsAddParams('BT_max_depth_error',$BT_max_depth_error); |
|
522 |
} |
|
523 |
$fullParams = $antsCurParams; |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
524 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
525 |
$LADCP_start = 1 if ($LADCP_start == 0); # ensure that there is previous ensemble |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
526 |
|
3 | 527 |
print(STDERR "\n\tdowncast...") if ($opt_d); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
528 |
edit_velocity($LADCP_start,$LADCP_bottom); # downcast |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
529 |
calc_shear($LADCP_start,$LADCP_bottom,$SHEAR_PREGRID_DZ,0); # pre-grid shear @SHEAR_PREGRID_DZm resolution |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
530 |
calc_shear($LADCP_start,$LADCP_bottom,$GRID_DZ,1); # calculate final gridded shear profile |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
531 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
532 |
@dc_sh_n = @sh_n; # save downcast results |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
533 |
@dc_ush_mu = @ush_mu; @dc_ush_sig = @ush_sig; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
534 |
@dc_vsh_mu = @vsh_mu; @dc_vsh_sig = @vsh_sig; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
535 |
@dc_wsh_mu = @wsh_mu; @dc_wsh_sig = @wsh_sig; |
7 | 536 |
@dc_esh_mu = @esh_mu; |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
537 |
|
3 | 538 |
print(STDERR "\n\tupcast...") if ($opt_d); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
539 |
edit_velocity($LADCP_end,$LADCP_bottom); # upcast |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
540 |
calc_shear($LADCP_end,$LADCP_bottom,$SHEAR_PREGRID_DZ,0); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
541 |
calc_shear($LADCP_end,$LADCP_bottom,$GRID_DZ,1); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
542 |
|
1 | 543 |
@uc_sh_n = @sh_n; # save upcast results |
544 |
@uc_ush_mu = @ush_mu; @uc_ush_sig = @ush_sig; |
|
545 |
@uc_vsh_mu = @vsh_mu; @uc_vsh_sig = @vsh_sig; |
|
546 |
@uc_wsh_mu = @wsh_mu; @uc_wsh_sig = @wsh_sig; |
|
7 | 547 |
@uc_esh_mu = @esh_mu; |
1 | 548 |
|
3 | 549 |
print(STDERR "\n\tcombined...") if ($opt_d); |
7 | 550 |
my($nsh) = (@dc_ush_mu > @uc_ush_mu) ? scalar(@dc_ush_mu) : scalar(@uc_ush_mu); |
551 |
for (my($gi)=0; $gi<$nsh; $gi++) { |
|
552 |
if (($gi<@dc_ush_mu&&$dc_sh_n[$gi]>0) && ($gi<@uc_ush_mu&&$uc_sh_n[$gi]>0)) { |
|
1 | 553 |
$sh_n[$gi] = $dc_sh_n[$gi] + $uc_sh_n[$gi]; |
554 |
$ush_mu[$gi] = ($dc_sh_n[$gi]*$dc_ush_mu[$gi] + $uc_sh_n[$gi]*$uc_ush_mu[$gi]) / $sh_n[$gi]; |
|
555 |
$vsh_mu[$gi] = ($dc_sh_n[$gi]*$dc_vsh_mu[$gi] + $uc_sh_n[$gi]*$uc_vsh_mu[$gi]) / $sh_n[$gi]; |
|
556 |
$wsh_mu[$gi] = ($dc_sh_n[$gi]*$dc_wsh_mu[$gi] + $uc_sh_n[$gi]*$uc_wsh_mu[$gi]) / $sh_n[$gi]; |
|
7 | 557 |
$esh_mu[$gi] = ($dc_sh_n[$gi]*$dc_esh_mu[$gi] + $uc_sh_n[$gi]*$uc_esh_mu[$gi]) / $sh_n[$gi]; |
1 | 558 |
$ush_sig[$gi] = sqrt(($dc_sh_n[$gi]*$dc_ush_sig[$gi]**2 + $uc_sh_n[$gi]*$uc_ush_sig[$gi]**2) / $sh_n[$gi]); |
559 |
$vsh_sig[$gi] = sqrt(($dc_sh_n[$gi]*$dc_vsh_sig[$gi]**2 + $uc_sh_n[$gi]*$uc_vsh_sig[$gi]**2) / $sh_n[$gi]); |
|
560 |
$wsh_sig[$gi] = sqrt(($dc_sh_n[$gi]*$dc_wsh_sig[$gi]**2 + $uc_sh_n[$gi]*$uc_wsh_sig[$gi]**2) / $sh_n[$gi]); |
|
7 | 561 |
} elsif ($gi < @dc_ush_mu && $dc_sh_n[$gi] > 0) { |
1 | 562 |
$sh_n[$gi] = $dc_sh_n[$gi]; |
7 | 563 |
$ush_mu[$gi] = $dc_ush_mu[$gi]; $vsh_mu[$gi] = $dc_vsh_mu[$gi]; $wsh_mu[$gi] = $dc_wsh_mu[$gi]; $esh_mu[$gi] = $dc_esh_mu[$gi]; |
564 |
$ush_sig[$gi] = $dc_ush_sig[$gi]; $vsh_sig[$gi] = $dc_vsh_sig[$gi]; $wsh_sig[$gi] = $dc_wsh_sig[$gi]; |
|
565 |
} elsif ($gi < @uc_ush_mu && $uc_sh_n[$gi] > 0) { |
|
1 | 566 |
$sh_n[$gi] = $uc_sh_n[$gi]; |
7 | 567 |
$ush_mu[$gi] = $uc_ush_mu[$gi]; $vsh_mu[$gi] = $uc_vsh_mu[$gi]; $wsh_mu[$gi] = $uc_wsh_mu[$gi]; $esh_mu[$gi] = $uc_esh_mu[$gi]; |
568 |
$ush_sig[$gi] = $uc_ush_sig[$gi]; $vsh_sig[$gi] = $uc_vsh_sig[$gi]; $wsh_sig[$gi] = $uc_wsh_sig[$gi]; |
|
1 | 569 |
} else { |
570 |
$sh_n[$gi] = 0; |
|
7 | 571 |
$ush_mu[$gi] = $vsh_mu[$gi] = $wsh_mu[$gi] = $esh_mu[$gi] = nan; |
1 | 572 |
$ush_sig[$gi] = $vsh_sig[$gi] = $wsh_sig[$gi] = nan; |
573 |
} |
|
574 |
} |
|
575 |
||
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
576 |
print(STDERR "\n"); |
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 |
#---------------------------------------------------------------------- |
1 | 579 |
# Step 9: Get bottom track profile |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
580 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
581 |
|
3 | 582 |
if ($LADCP{ENSEMBLE}[$LADCP_start]->{XDUCER_FACING_DOWN}) { |
583 |
print(STDERR "Getting BT profile..."); |
|
584 |
getBTprof($LADCP_start,$LADCP_end); |
|
585 |
print(STDERR "\n"); |
|
586 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
587 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
588 |
#---------------------------------------------------------------------- |
4 | 589 |
# Step 10: Write Output Profiles if requested |
0
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 |
|
4 | 592 |
if (defined($opt_p)) { |
593 |
||
594 |
print(STDERR "Writing shear profiles..."); |
|
595 |
||
7 | 596 |
@antsNewLayout = ('depth','dc_elapsed','dc_nsamp','dc_u_z','dc_u_z.sig','dc_v_z','dc_v_z.sig','dc_w_z','dc_w_z.sig', |
597 |
'uc_elapsed','uc_nsamp','uc_u_z','uc_u_z.sig','uc_v_z','uc_v_z.sig','uc_w_z','uc_w_z.sig', |
|
10 | 598 |
'elapsed','nsamp','u_z','u_z.sig','v_z','v_z.sig','w_z','w_z.sig','Sv','Sv.nsamp'); |
4 | 599 |
|
600 |
&antsOut('EOF'); |
|
601 |
close(STDOUT); |
|
602 |
open(STDOUT,">$opt_p") || croak("$opt_p: $!\n"); |
|
603 |
||
604 |
$antsCurParams = $fullParams; |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
605 |
|
7 | 606 |
for (my($gi)=0; $gi<$nsh; $gi++) { |
4 | 607 |
&antsOut(depthOfGI($gi), # depth in center of bin |
7 | 608 |
$dc_esh_mu[$gi], # downcast |
609 |
numberp($dc_sh_n[$gi])?$dc_sh_n[$gi]:0, |
|
4 | 610 |
$dc_ush_mu[$gi],$dc_ush_sig[$gi], |
611 |
$dc_vsh_mu[$gi],$dc_vsh_sig[$gi], |
|
612 |
$dc_wsh_mu[$gi],$dc_wsh_sig[$gi], |
|
7 | 613 |
$uc_esh_mu[$gi], # upcast |
614 |
numberp($uc_sh_n[$gi])?$uc_sh_n[$gi]:0, |
|
4 | 615 |
$uc_ush_mu[$gi],$uc_ush_sig[$gi], |
616 |
$uc_vsh_mu[$gi],$uc_vsh_sig[$gi], |
|
617 |
$uc_wsh_mu[$gi],$uc_wsh_sig[$gi], |
|
7 | 618 |
$esh_mu[$gi],$sh_n[$gi], # combined |
4 | 619 |
$ush_mu[$gi],$ush_sig[$gi], |
620 |
$vsh_mu[$gi],$vsh_sig[$gi], |
|
621 |
$wsh_mu[$gi],$wsh_sig[$gi], |
|
622 |
$nSv_prof[$gi]?$sSv_prof[$gi]/$nSv_prof[$gi]:nan, |
|
623 |
$nSv_prof[$gi], |
|
624 |
); |
|
625 |
} |
|
626 |
||
627 |
print(STDERR "\n"); |
|
628 |
} # if -p |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
629 |
|
3 | 630 |
#--------------------------------------- |
631 |
# Acoustic backscatter depth-time-series |
|
632 |
#--------------------------------------- |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
633 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
634 |
if (defined($opt_a)) { |
3 | 635 |
print(STDERR "Writing acoustic backscatter depth-time-series to <$opt_a>..."); |
636 |
||
637 |
||
638 |
@antsNewLayout = ('ens','elapsed','CTD_depth','depth','bin','downcast', |
|
639 |
'Sv_beam1','Sv_beam2','Sv_beam3','Sv_beam4','Sv.median'); |
|
640 |
&antsOut('EOF'); |
|
641 |
close(STDOUT); |
|
642 |
open(STDOUT,">$opt_a") || croak("$opt_a: $!\n"); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
643 |
|
3 | 644 |
$antsCurParams = $commonParams; |
6 | 645 |
&antsAddParams('min_elapsed',$LADCP{ENSEMBLE}[$LADCP_start]->{ELAPSED_TIME}+$CTD{first_elapsed}-$opt_l, |
646 |
'max_elapsed',$LADCP{ENSEMBLE}[$LADCP_end]->{ELAPSED_TIME}+$CTD{first_elapsed}-$opt_l, |
|
3 | 647 |
'min_depth',$LADCP{ENSEMBLE}[$LADCP_top]->{XDUCER_FACING_UP} ? |
648 |
&depthOfBin($LADCP_top,$LADCP{N_BINS}-1) : $LADCP{ENSEMBLE}[$LADCP_top]->{DEPTH}, |
|
649 |
'max_depth',$LADCP{ENSEMBLE}[$LADCP_bottom]->{XDUCER_FACING_UP} ? |
|
650 |
$LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH} : &depthOfBin($LADCP_bottom,$LADCP{N_BINS}-1) |
|
651 |
); |
|
652 |
||
653 |
for (my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) { |
|
654 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) { |
|
655 |
&antsOut($LADCP{ENSEMBLE}[$ens]->{NUMBER}, |
|
6 | 656 |
$LADCP{ENSEMBLE}[$ens]->{ELAPSED_TIME}+$CTD{first_elapsed}-$opt_l, |
3 | 657 |
$LADCP{ENSEMBLE}[$ens]->{DEPTH}, |
6 | 658 |
&depthOfBin($ens,$bin),$bin+1, |
3 | 659 |
($ens <= $LADCP_bottom) ? 1 : 0, |
660 |
@{$LADCP{ENSEMBLE}[$ens]->{SV}[$bin]}, |
|
661 |
median(@{$LADCP{ENSEMBLE}[$ens]->{SV}[$bin]}) |
|
662 |
); |
|
663 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
664 |
} |
3 | 665 |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
666 |
print(STDERR "\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
667 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
668 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
669 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
670 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
671 |
if (defined($opt_t)) { |
3 | 672 |
print(STDERR "Writing time series to <$opt_t>..."); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
673 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
674 |
@antsNewLayout = ('ens','elapsed','depth','CTD_w','LADCP_w'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
675 |
&antsOut('EOF'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
676 |
$antsCurParams = $commonParams; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
677 |
close(STDOUT); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
678 |
open(STDOUT,">$opt_t") || croak("$opt_t: $!\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
679 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
680 |
for (my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
681 |
&antsOut($LADCP{ENSEMBLE}[$ens]->{NUMBER}, |
6 | 682 |
$LADCP{ENSEMBLE}[$ens]->{ELAPSED_TIME}+$CTD{first_elapsed}-$opt_l, |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
683 |
$LADCP{ENSEMBLE}[$ens]->{DEPTH}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
684 |
$LADCP{ENSEMBLE}[$ens]->{CTD_W}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
685 |
$LADCP{ENSEMBLE}[$ens]->{W}); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
686 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
687 |
print(STDERR "\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
688 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
689 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
690 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
691 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
692 |
if (defined($opt_b)) { |
3 | 693 |
print(STDERR "Writing bottom-track data to <$opt_b>..."); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
694 |
|
6 | 695 |
@antsNewLayout = ('depth','u','v','w','u.sig','v.sig','w.sig','nsamp'); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
696 |
&antsOut('EOF'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
697 |
$antsCurParams = $commonParams; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
698 |
close(STDOUT); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
699 |
open(STDOUT,">$opt_b") || croak("$opt_b: $!\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
700 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
701 |
my($skipped); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
702 |
for (my($gi)=0; $gi<@BT_nsamp; $gi++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
703 |
$skipped = 1 if ($BT_nsamp[$gi] > 0); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
704 |
next unless ($skipped); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
705 |
&antsOut(depthOfGI($gi),$BTu[$gi],$BTv[$gi],$BTw[$gi],$BTu_sig[$gi],$BTv_sig[$gi],$BTw_sig[$gi],$BT_nsamp[$gi]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
706 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
707 |
print(STDERR "\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
708 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
709 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
710 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
711 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
712 |
if (defined($opt_f)) { |
3 | 713 |
print(STDERR "Writing data flags to <$opt_f>..."); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
714 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
715 |
@antsNewLayout = ('ens'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
716 |
for (my($i)=1; $i<=$LADCP{N_BINS}; $i++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
717 |
$antsNewLayout[$i] = "bin$i"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
718 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
719 |
&antsOut('EOF'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
720 |
$antsCurParams = $commonParams; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
721 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
722 |
close(STDOUT); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
723 |
open(STDOUT,">$opt_f") || croak("$opt_f: $!\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
724 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
725 |
&antsPrintHeaders(STDOUT,@antsNewLayout); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
726 |
for (my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
727 |
printf('%4d ',$LADCP{ENSEMBLE}[$ens]->{NUMBER}); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
728 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
729 |
printf("%02x ",$edit_flags[$ens][$bin]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
730 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
731 |
print($opt_R); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
732 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
733 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
734 |
print(STDERR "\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
735 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
736 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
737 |
&antsExit(); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
738 |