author | A.M. Thurnherr <athurnherr@yahoo.com> |
Fri, 12 Jul 2013 12:23:25 +0000 | |
changeset 20 | 7caeef8595b0 |
parent 19 | 12aaf0962ee6 |
child 22 | f6635c0384b7 |
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 |
20 | 5 |
# dlm: Tue Jun 25 14:28:32 2013 |
8 | 6 |
# (c) 2010 A.M. Thurnherr |
20 | 7 |
# uE-Info: 81 54 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 |
# NOTES: |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
11 |
# - 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
|
12 |
# - 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
|
13 |
# 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
|
14 |
# - 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
|
15 |
# - 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
|
16 |
# 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
|
17 |
# - for SeaBird files: |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
18 |
# - 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
|
19 |
# - first elapsed time is added on output |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
20 |
# - 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
|
21 |
# time information |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
22 |
# - 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
|
23 |
# - ITS-90 temp field in degC required |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
24 |
# - salin field prequired |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
25 |
# - pressure field in dbar required |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
26 |
# - -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
|
27 |
# time series overplot nicely |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
28 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
29 |
# HISTORY: |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
30 |
# Sep 16, 2010: - incepted |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
31 |
# Oct 13, 2010: - first working version |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
32 |
# Oct 14, 2010: - renamed from LADCPshear |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
33 |
# Oct 19, 2010: - added -a)coustic backscatter profiles |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
34 |
# Oct 20, 2010: - added -2)dary CTD sensors |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
35 |
# Oct 23, 2010: - added magnetic-declination correction |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
36 |
# Oct 26, 2010: - added tilt calculation |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
37 |
# 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
|
38 |
# Dec 10, 2010: - change -w) default to 120s |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
39 |
# - 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
|
40 |
# 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
|
41 |
# Jan 10, 2011: - -o => -k added new -o |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
42 |
# - added code to fill CTD sound vel gaps |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
43 |
# Jan 22, 2011: - added -g) lat,lon |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
44 |
# - added -c)ompass corr |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
45 |
# 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
|
46 |
# 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
|
47 |
# - 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
|
48 |
# acoustic backscatter depth-time-series |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
49 |
# - 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
|
50 |
# - made non-diagnostic output terser |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
51 |
# 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
|
52 |
# 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
|
53 |
# 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
|
54 |
# - added T[hurnherr11] -u)se option |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
55 |
# - added $CTD{first_elapsed} |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
56 |
# Jul 27, 2011: - replaced ndata by nsamp |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
57 |
# 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
|
58 |
# 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
|
59 |
# - replaced "nshear" output field by "nsamp" |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
60 |
# - 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
|
61 |
# - 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
|
62 |
# 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
|
63 |
# - improved and relaxed depth consistency check |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
64 |
# 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
|
65 |
# - 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
|
66 |
# Apr 13, 2012: - removed -s argument from dependencies |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
67 |
# Apr 17, 2012: - BAD BUG: magdec code call was bad and did not return correct value. ever. |
10 | 68 |
# Apr 18, 2012: - replaced Sv.n by Sv.nsamp |
11 | 69 |
# May 16, 2012: - adapted to ANTSlib V5.0 |
12 | 70 |
# - added support for -r)DI BT data |
13 | 71 |
# - added $LADCP{MEAN_DT} from vertical-velocity code |
72 |
# May 17, 2012: - significantly relaxed profile-range consistency check (from 20% to 50%) |
|
73 |
# which is required for Dan Torres' shallow casts |
|
74 |
# - added version info |
|
16 | 75 |
# May 18, 2012: - reduced "implausibly short cast" threshold to 5 min because of Dan's shallow casts |
76 |
# Jun 13, 2012: - added CTD_depth to tds output |
|
18 | 77 |
# Oct 28, 2012: - added -z |
19 | 78 |
# Mar 16, 2013: - BUG: usage message had a -p)PI flag |
20 | 79 |
# Jun 5, 2013: - added $bad_beam support |
80 |
# Jun 25, 2013: - added %PARAMS used for spectral correction |
|
81 |
# - adapted to new ::-PARAM convention |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
82 |
|
11 | 83 |
($ANTS) = (`which ANTSlib` =~ m{^(.*)/[^/]*$}); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
84 |
($PERL_TOOLS) = (`which mkProfile` =~ m{^(.*)/[^/]*$}); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
85 |
($LADCPPROC) = ($0 =~ m{^(.*)/[^/]*$}); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
86 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
87 |
require "$ANTS/ants.pl"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
88 |
require "$ANTS/libEOS83.pl"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
89 |
require "$ANTS/libstats.pl"; |
13 | 90 |
require "$LADCPPROC/LADCPproc.version"; |
1 | 91 |
require "$LADCPPROC/LADCPproc.loadCTD"; |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
92 |
require "$LADCPPROC/LADCPproc.bestLag"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
93 |
require "$LADCPPROC/LADCPproc.BT"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
94 |
require "$LADCPPROC/LADCPproc.backscatter"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
95 |
require "$LADCPPROC/LADCPproc.UHcode"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
96 |
require "$PERL_TOOLS/RDI_BB_Read.pl"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
97 |
require "$PERL_TOOLS/RDI_Coords.pl"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
98 |
require "$PERL_TOOLS/RDI_Utils.pl"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
99 |
|
19 | 100 |
$ANTSLIBS = $LADCPPROC; # for -L libraries |
101 |
||
13 | 102 |
$antsSummary = "$version -- process LADCP data to get shear, time series"; |
103 |
||
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
104 |
$antsParseHeader = 0; |
18 | 105 |
&antsUsage('24a:b:c:df:g:i:kl:n:o:p:rs:t:u:w:z',2, |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
106 |
'[use -2)dary CTD sensor pair]', |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
107 |
'[require -4)-beam LADCP solutions]', |
12 | 108 |
'[use -r)DI bottom-track data]', |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
109 |
'[-s)etup <file>] [-g)ps <lat,lon>]', |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
110 |
'[-c)ompass-corr <offset,cos-fac,sin-fac>]', |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
111 |
'[-o)utput grid <resolution[5m]>]', |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
112 |
'[-i)nitial LADCP time lag <guestimate>]', |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
113 |
'[-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
|
114 |
'[correct echo amplitude -u)sing D[eines99]|V[isbeck04]|T[hurnherr11]|n[ocorr]', |
18 | 115 |
'[-d)iagnostic screen output] [-z)oom through problems]', |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
116 |
'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
|
117 |
' [-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
|
118 |
'<RDI file> <SeaBird file>'); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
119 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
120 |
$RDI_Coords::minValidVels = 4 if ($opt_4); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
121 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
122 |
&antsFloatOpt($opt_l); |
1 | 123 |
&antsCardOpt(\$opt_w,120); |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
124 |
# 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
|
125 |
# 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
|
126 |
# 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
|
127 |
# related to ambiguity velocity |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
128 |
&antsCardOpt(\$opt_n,20); |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
129 |
#&antsFileOpt($opt_s); # DON'T, AS THIS WILL ADD AN UNWANTED DEPENDCY |
1 | 130 |
&antsFloatOpt($opt_i); |
4 | 131 |
&antsCardOpt(\$opt_o,5); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
132 |
|
6 | 133 |
if (defined($opt_u)) { |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
134 |
croak("$0: cannot decode -u $opt_u\n") |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
135 |
unless ($opt_u =~ /^[dDvVtTn]/); |
6 | 136 |
} else { |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
137 |
$opt_u = 'Deines99'; |
6 | 138 |
} |
139 |
||
2 | 140 |
if (defined($opt_g)) { |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
141 |
($CTD{lat},$CTD{lon}) = split(',',$opt_g); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
142 |
croak("$0: cannot decode -g $opt_g\n") |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
143 |
unless numberp($CTD{lat}) && numberp($CTD{lon}); |
2 | 144 |
} |
145 |
||
146 |
if (defined($opt_c)) { |
|
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
147 |
($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
|
148 |
croak("$0: cannot decode -c $opt_c\n") |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
149 |
unless numberp($CC_offset) && numberp($CC_cos_fac) && numberp($CC_sin_fac); |
2 | 150 |
} |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
151 |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
152 |
$LADCP_file = &antsFileArg(); |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
153 |
$CTD_file = &antsFileArg(); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
154 |
|
20 | 155 |
&antsAddParams('LADCPproc::LADCP_file',$LADCP_file,'LADCPproc::CTD_file',$CTD_file); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
156 |
&antsActivateOut(); |
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 |
#---------------------------------------------------------------------- |
1 | 159 |
# Step 1: Read LADCP Data |
0
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 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
162 |
print(STDERR "Reading LADCP data ($LADCP_file)..."); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
163 |
readData($LADCP_file,\%LADCP); |
3 | 164 |
printf(STDERR "\n\t%d ensembles",scalar(@{$LADCP{ENSEMBLE}})) if ($opt_d); |
165 |
print(STDERR "\n"); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
166 |
|
20 | 167 |
&antsAddParams('LADCPproc::bin_length',$LADCP{BIN_LENGTH}); |
168 |
||
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
169 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
170 |
# Step 2: Set Processing Parameters |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
171 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
172 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
173 |
print(STDERR "Setting processing parameters...\n"); |
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 |
printf(STDERR "\tloading $LADCPPROC/LADCPproc.defaults...\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
176 |
require "$LADCPPROC/LADCPproc.defaults"; |
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 |
if (defined($opt_s)) { |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
179 |
print(STDERR "\tloading $opt_s...\n"); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
180 |
require $opt_s; |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
181 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
182 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
183 |
if ($LADCP{BLANKING_DISTANCE} == 0) { |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
184 |
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
|
185 |
if ($opt_d); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
186 |
$wbin_start = 2 unless ($wbin_start > 2); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
187 |
$ubin_start = 2 unless ($ubin_start > 2); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
188 |
$shbin_start = 2 unless ($shbin_start > 2); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
189 |
$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
|
190 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
191 |
|
20 | 192 |
&antsAddParams('LADCPproc::instrument_orientation', |
193 |
$LADCP{ENSEMBLE}[0]->{XDUCER_FACING_UP} ? 'UL' : 'DL'); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
194 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
195 |
$SHEAR_PREGRID_DZ = 20; |
4 | 196 |
$GRID_DZ = $opt_o; |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
197 |
|
20 | 198 |
&antsAddParams('LADCPproc::vertical_resolution',$GRID_DZ); |
199 |
||
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
200 |
#---------------------------------------------------------------------- |
1 | 201 |
# Step 3: Read CTD data |
202 |
#---------------------------------------------------------------------- |
|
203 |
||
204 |
print(STDERR "Reading CTD data ($CTD_file)..."); |
|
205 |
readCTD($CTD_file,\%CTD); |
|
3 | 206 |
printf(STDERR "\n\t%d scans",scalar(@{$CTD{press}})) if ($opt_d); |
207 |
print(STDERR "\n"); |
|
1 | 208 |
|
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
209 |
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
|
210 |
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
|
211 |
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
|
212 |
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
|
213 |
|
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
214 |
croak("$0: unknown magnetic declination\n") |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
215 |
unless defined($magdec); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
216 |
|
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
217 |
&antsAddParams('magnetic_declination',$magdec); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
218 |
|
1 | 219 |
#---------------------------------------------------------------------- |
220 |
# Step 4: Pre-Process CTD & LADCP Data |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
221 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
222 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
223 |
printf(STDERR "Pre-processing data..."); |
3 | 224 |
printf(STDERR "\n\tCTD...") if ($opt_d); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
225 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
226 |
#------------------------ |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
227 |
# clean CTD pressure data |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
228 |
#------------------------ |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
229 |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
230 |
my($pSpikes) = 0; |
1 | 231 |
for (my($r)=1; $r<@{$CTD{press}}; $r++) { |
232 |
$pSpikes++,$CTD{press}[$r]=nan |
|
233 |
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
|
234 |
} |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
235 |
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
|
236 |
if ($pSpikes>0 && $opt_d); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
237 |
|
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
238 |
#----------------------------------- |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
239 |
# trim "preamble" without valid data |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
240 |
#----------------------------------- |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
241 |
|
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
242 |
my($r) = 0; |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
243 |
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
|
244 |
splice(@{$CTD{press}},0,$r); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
245 |
splice(@{$CTD{temp}},0,$r); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
246 |
splice(@{$CTD{salin}},0,$r); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
247 |
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
|
248 |
if ($r>0 && $opt_d); |
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
249 |
|
7 | 250 |
#-------------------------------------------------- |
251 |
# calculate w and find deepest & shallowest records |
|
252 |
#-------------------------------------------------- |
|
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
253 |
|
1 | 254 |
$CTD{maxpress} = -9e99; |
7 | 255 |
$CTD{minpress} = 9e99; |
1 | 256 |
for (my($r)=1; $r<@{$CTD{press}}-1; $r++) { |
257 |
$CTD{w}[$r] = 0.99*($CTD{press}[$r+1] - $CTD{press}[$r-1]) / (2*$CTD{sampint}); |
|
258 |
if ($CTD{press}[$r] > $CTD{maxpress}) { |
|
259 |
$CTD{maxpress} = $CTD{press}[$r]; |
|
260 |
$CTD{atbottom} = $r; |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
261 |
} |
7 | 262 |
if ($CTD{press}[$r] < $CTD{minpress}) { |
263 |
$CTD{minpress} = $CTD{press}[$r]; |
|
264 |
$CTD{attop} = $r; |
|
265 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
266 |
} |
9
48b2d27aaebf
after fixing bad magdec bug
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
8
diff
changeset
|
267 |
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
|
268 |
$CTD{minpress},$CTD{maxpress},$CTD{attop},$CTD{atbottom}) |
1 | 269 |
if $opt_d; |
270 |
||
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
271 |
#---------------------------------------------------------------------- |
1 | 272 |
# Step 4b: Pre-Process LADCP Data |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
273 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
274 |
|
3 | 275 |
print(STDERR "\n\tLADCP...") if ($opt_d); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
276 |
|
19 | 277 |
#------------------------------------------------- |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
278 |
# transform to earth coordinates if required |
20 | 279 |
# - discard data from a particular beam if requested |
19 | 280 |
# - save beam_vels for later (e.g. wake) editing |
281 |
#------------------------------------------------- |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
282 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
283 |
$U = 0; # velocity indices |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
284 |
$V = 1; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
285 |
$W = 2; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
286 |
$E = 3; |
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 |
$LADCP{HEADING_BIAS} = -$magdec; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
289 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
290 |
if ($LADCP{BEAM_COORDINATES}) { |
20 | 291 |
if ($opt_d) { |
292 |
print(STDERR "\n\t\ttransforming beam to Earth coordinates..."); |
|
293 |
print(STDERR "\n\t\t\tdiscarding data from beam $bad_beam...") |
|
294 |
if ($bad_beam); |
|
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}); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
298 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) { |
20 | 299 |
if ($bad_beam) { |
300 |
undef($LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$bad_beam-1]); |
|
301 |
undef($LADCP{ENSEMBLE}[$ens]->{BT_VELOCITY}[$bin][$bad_beam-1]); |
|
302 |
} |
|
19 | 303 |
@{$LADCP{ENSEMBLE}[$ens]->{BEAM_VEL}[$bin]} = @{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]}; |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
304 |
@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]} = |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
305 |
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
|
306 |
@{$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
|
307 |
(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
|
308 |
} |
12 | 309 |
@{$LADCP{ENSEMBLE}[$ens]->{BT_VELOCITY}} = |
310 |
velInstrumentToEarth(\%LADCP,$ens,velBeamToInstrument(\%LADCP,@{$LADCP{ENSEMBLE}[$ens]->{BT_VELOCITY}})); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
311 |
} |
12 | 312 |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
313 |
$LADCP{BEAM_COORDINATES} = 0; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
314 |
$LADCP{EARTH_COORDINATES} = 1; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
315 |
unless ($opt_4) { |
1 | 316 |
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
|
317 |
if ($opt_d); |
20 | 318 |
&antsAddParams('LADCPproc::3_beam_solutions',"$RDI_Coords::threeBeam_1 $RDI_Coords::threeBeam_2 $RDI_Coords::threeBeam_3 $RDI_Coords::threeBeam_4"); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
319 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
320 |
} elsif ($LADCP{EARTH_COORDINATES}) { |
2 | 321 |
if ($opt_d) { |
322 |
if ($opt_c) { |
|
323 |
printf(STDERR "\n\t\tcalculating tilt and correcting for compass error and magnetic declination of %.1f deg...\n",$magdec); |
|
324 |
} else { |
|
325 |
printf(STDERR "\n\t\tcalculating tilt and correcting for magnetic declination of %.1f deg...\n",$magdec); |
|
326 |
} |
|
327 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
328 |
for (my($ens)=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
329 |
$LADCP{ENSEMBLE}[$ens]->{TILT} = &angle_from_vertical($LADCP{ENSEMBLE}[$ens]->{PITCH},$LADCP{ENSEMBLE}[$ens]->{ROLL}); |
2 | 330 |
my($hdg) = rad($LADCP{ENSEMBLE}[$ens]->{HEADING}); |
331 |
$LADCP{HEADING_BIAS} = ($CC_offset + $CC_cos_fac*cos($hdg) + $CC_sin_fac*sin($hdg)) - $magdec |
|
332 |
if ($opt_c); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
333 |
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
|
334 |
@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]} = |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
335 |
velApplyHdgBias(\%LADCP,$ens,@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]}); |
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 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
338 |
} else { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
339 |
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
|
340 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
341 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
342 |
#------------------------------------------------------ |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
343 |
# 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
|
344 |
#------------------------------------------------------ |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
345 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
346 |
print(STDERR "\t\tconstructing profile time series...") |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
347 |
if ($opt_d); |
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 |
($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
|
350 |
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
|
351 |
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
|
352 |
unless defined($LADCP_start); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
353 |
|
13 | 354 |
my($cast_duration) = $LADCP{ENSEMBLE}[$LADCP_end]->{UNIX_TIME} - |
355 |
$LADCP{ENSEMBLE}[$LADCP_start]->{UNIX_TIME}; |
|
356 |
croak("$0: implausibly short cast ($cast_duration seconds)\n") |
|
14 | 357 |
unless ($cast_duration > 300); |
13 | 358 |
$LADCP{MEAN_DT} = $cast_duration / ($LADCP_end-$LADCP_start-1); |
359 |
||
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
360 |
if ($opt_d) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
361 |
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
|
362 |
$LADCP{ENSEMBLE}[$LADCP_start]->{TIME}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
363 |
$LADCP{ENSEMBLE}[$LADCP_start]->{NUMBER}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
364 |
$LADCP{ENSEMBLE}[$LADCP_start]->{DEPTH}); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
365 |
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
|
366 |
$LADCP{ENSEMBLE}[$LADCP_bottom]->{TIME}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
367 |
$LADCP{ENSEMBLE}[$LADCP_bottom]->{NUMBER}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
368 |
$LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH}); |
13 | 369 |
printf(STDERR "\t\t\tEnd of cast : %s (#%5d) at %6.1fm\n", |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
370 |
$LADCP{ENSEMBLE}[$LADCP_end]->{TIME}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
371 |
$LADCP{ENSEMBLE}[$LADCP_end]->{NUMBER}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
372 |
$LADCP{ENSEMBLE}[$LADCP_end]->{DEPTH}); |
13 | 373 |
printf(STDERR "\t\t\tAvg ping interval: %.1fs",$LADCP{MEAN_DT}); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
374 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
375 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
376 |
print(STDERR "\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
377 |
|
8 | 378 |
my($LADCP_prof_range) = $LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH} - |
379 |
min($LADCP{ENSEMBLE}[$LADCP_start]->{DEPTH},$LADCP{ENSEMBLE}[$LADCP_end]->{DEPTH}); |
|
13 | 380 |
my($CTD_prof_range) = $CTD{maxpress} - $CTD{minpress}; |
18 | 381 |
croak(sprintf("$0: LADCP profile depth range (%dm) inconsistent with max CTD pressure range (%ddbar) [-z to disable]\n", |
13 | 382 |
$LADCP_prof_range,$CTD_prof_range)) |
18 | 383 |
if (!$opt_z && abs($LADCP_prof_range-0.99*$CTD_prof_range) > |
384 |
max(0.2*0.99*$CTD_prof_range,abs($LADCP{ENSEMBLE}[$LADCP_end]->{DEPTH}),50)); |
|
6 | 385 |
|
19 | 386 |
#---------------------------------------------------------------- |
387 |
# call edit function |
|
388 |
# - e.g. for wake editing |
|
389 |
# - this is done here, because during step 5 the velocities are |
|
390 |
# sound-speed corrected, i.e. |
|
391 |
#---------------------------------------------------------------- |
|
392 |
||
393 |
&edit_LADCP_vels() |
|
394 |
if (exists(&edit_LADCP_vels)); |
|
395 |
||
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
396 |
#---------------------------------------------------------------------- |
1 | 397 |
# 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
|
398 |
# - {DEPTH} field is overwritten! |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
399 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
400 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
401 |
print(STDERR "Matching CTD to LADCP time series..."); |
17 | 402 |
print(STDERR "\n") if defined($opt_l); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
403 |
|
1 | 404 |
$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
|
405 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
406 |
print(STDERR "Associating CTD data with LADCP ensembles..."); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
407 |
|
3 | 408 |
for (my($min_depth)=9e99,my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) { |
409 |
my($lastSvel); |
|
1 | 410 |
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
|
411 |
if ($r < 0 && $ens == $LADCP_start) { |
1 | 412 |
$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
|
413 |
while ($r < 0); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
414 |
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
|
415 |
$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
|
416 |
$LADCP_start = $ens; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
417 |
} |
1 | 418 |
if ($r > $#{$CTD{press}}) { |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
419 |
printf(STDERR "\n\tCTD data end while instrument is still in water => truncating %ds of LADCP data", |
3 | 420 |
$LADCP{ENSEMBLE}[$LADCP_end]->{ELAPSED_TIME}-$LADCP{ENSEMBLE}[$ens]->{ELAPSED_TIME}) |
421 |
if ($opt_d); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
422 |
$LADCP_end = $ens - 1; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
423 |
last; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
424 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
425 |
my($dr); |
1 | 426 |
for ($dr=0; !numberp($CTD{press}[$r+$dr]); $dr--) {} |
427 |
$LADCP{ENSEMBLE}[$ens]->{DEPTH} = depth($CTD{press}[$r+$dr],$CTD{lat}); |
|
3 | 428 |
if ($LADCP{ENSEMBLE}[$ens]->{DEPTH} < $min_depth) { |
429 |
$min_depth = $LADCP{ENSEMBLE}[$ens]->{DEPTH}; |
|
430 |
$LADCP_top = $ens; |
|
431 |
} |
|
1 | 432 |
$LADCP{ENSEMBLE}[$ens]->{CTD_W} = $CTD{w}[$r]; |
433 |
$LADCP{ENSEMBLE}[$ens]->{CTD_TEMP} = $CTD{temp}[$r]; |
|
434 |
$LADCP{ENSEMBLE}[$ens]->{CTD_SVEL} = sVel($CTD{salin}[$r],$CTD{temp}[$r],$CTD{press}[$r+$dr]); |
|
435 |
if (numberp($LADCP{ENSEMBLE}[$ens]->{CTD_SVEL})) { |
|
436 |
$lastSvel = $LADCP{ENSEMBLE}[$ens]->{CTD_SVEL}; |
|
437 |
} else { |
|
438 |
$LADCP{ENSEMBLE}[$ens]->{CTD_SVEL} = $lastSvel; |
|
439 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
440 |
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
|
441 |
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
|
442 |
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
|
443 |
$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$U] *= $sscorr; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
444 |
$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$V] *= $sscorr; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
445 |
$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W] *= $sscorr; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
446 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
447 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
448 |
|
20 | 449 |
&antsAddParams('LADCPproc::min_depth',round($LADCP{ENSEMBLE}[$LADCP_top]->{DEPTH}), |
450 |
'LADCPproc::max_depth',round($LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH}), |
|
451 |
'LADCPproc::start_date',$LADCP{ENSEMBLE}[$LADCP_start]->{DATE}, |
|
452 |
'LADCPproc::start_time',$LADCP{ENSEMBLE}[$LADCP_start]->{TIME}, |
|
453 |
'LADCPproc::bottom_date',$LADCP{ENSEMBLE}[$LADCP_bottom]->{DATE}, |
|
454 |
'LADCPproc::bottom_time',$LADCP{ENSEMBLE}[$LADCP_bottom]->{TIME}, |
|
455 |
'LADCPproc::end_date',$LADCP{ENSEMBLE}[$LADCP_end]->{DATE}, |
|
456 |
'LADCPproc::end_time',$LADCP{ENSEMBLE}[$LADCP_end]->{TIME}); |
|
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 |
print(STDERR "\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
459 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
460 |
#---------------------------------------------------------------------- |
1 | 461 |
# Step 6: Calculate Acoustic Backscatter Profile |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
462 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
463 |
|
3 | 464 |
print(STDERR "Calculating acoustic backscatter profiles..."); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
465 |
mk_backscatter_profs($LADCP_start,$LADCP_end); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
466 |
print(STDERR "\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
467 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
468 |
#---------------------------------------------------------------------- |
1 | 469 |
# Step 7: Find Seabed |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
470 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
471 |
|
3 | 472 |
if ($LADCP{ENSEMBLE}[$LADCP_start]->{XDUCER_FACING_DOWN}) { |
473 |
||
474 |
print(STDERR "Finding seabed..."); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
475 |
|
3 | 476 |
print(STDERR "\n\tin acoustic backscatter profiles...") if ($opt_d); |
477 |
($water_depth,$sig_water_depth) = |
|
478 |
find_backscatter_seabed($LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH}); |
|
12 | 479 |
printf(STDERR "\n\t\twater depth = %d(+-%.1f)m",$water_depth,$sig_water_depth) |
480 |
if ($opt_d); |
|
3 | 481 |
|
482 |
print(STDERR "\n\tin RDI BT data...") if ($opt_d); |
|
483 |
($BT_water_depth,$sig_BT_water_depth) = |
|
484 |
find_seabed(\%LADCP,$LADCP_bottom,$LADCP{BEAM_COORDINATES}); |
|
485 |
if (defined($BT_water_depth)) { |
|
12 | 486 |
printf(STDERR "\n\t\twater depth = %d(+-%.1f)m",$BT_water_depth,$sig_BT_water_depth) |
487 |
if ($opt_d); |
|
488 |
} else { |
|
489 |
printf(STDERR "\n\t\tno seabed found") if ($opt_d); |
|
3 | 490 |
} |
491 |
||
12 | 492 |
if ($opt_r) { # use RDI BT data |
493 |
$water_depth = $BT_water_depth; |
|
494 |
$sig_water_depth = $sig_BT_water_depth; |
|
495 |
} |
|
496 |
$min_hab = $water_depth - $LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH}; |
|
497 |
||
498 |
if (defined($water_depth)) { |
|
499 |
printf(STDERR "\n\twater depth = %d(+-%.1f)m",$water_depth,$sig_water_depth); |
|
500 |
printf(STDERR "\n\tclosest approach = %dmab",$min_hab); |
|
501 |
} else { |
|
3 | 502 |
print(STDERR "\n\tno seabed found\n"); |
503 |
print(STDERR "\n\tunknown water depth => PPI editing disabled\n") |
|
504 |
if ($opt_d); |
|
505 |
$clip_margin = 0; |
|
506 |
} |
|
507 |
||
508 |
print(STDERR "\n"); |
|
509 |
||
510 |
} else { # UPLOOKER |
|
511 |
$water_depth = $sig_water_depth = $min_hab = nan; |
|
512 |
print(STDERR "Uplooker data => PPI editing disabled\n") |
|
513 |
if ($opt_d); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
514 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
515 |
|
19 | 516 |
#----------------------------------------------------------------------- |
517 |
# Step 8: Edit Data & also produce depth-time-series output via callback |
|
518 |
#----------------------------------------------------------------------- |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
519 |
|
4 | 520 |
print(STDERR "Calculating shear profiles & producing time-depth-series (.tds) output..."); |
521 |
||
16 | 522 |
@antsNewLayout = ('ens','elapsed','CTD_depth','downcast','depth','u_z','v_z','w_z'); |
523 |
||
4 | 524 |
#-------------------------------------------------------------------------------- |
525 |
# callback routine to output .tds data, called once each for down-/upcasts after |
|
526 |
# shear has been gridded. Note that only the nominal (bin center) depth is known |
|
16 | 527 |
# for each sample at this stage of processing. |
528 |
#------------------------------------------------------------------------------- |
|
4 | 529 |
|
530 |
sub outTDseries($) |
|
531 |
{ |
|
16 | 532 |
my($downcast) = @_; # also use local [uvw]sh_vals[][] |
4 | 533 |
|
534 |
if ($downcast) { |
|
535 |
my($mingi); |
|
536 |
for ($mingi=0; $mingi<@ush_vals; $mingi++) { |
|
537 |
last if @{$ush_vals[$mingi]}; |
|
538 |
} |
|
20 | 539 |
&antsAddParams('LADCPproc::min_ens',$LADCP_start,'LADCPproc::min_elapsed',$LADCP{ENSEMBLE}[$LADCP_start]->{ELAPSED_TIME}+$CTD{first_elapsed}-$opt_l, |
540 |
'LADCPproc::max_ens',$LADCP_end,'LADCPproc::max_elapsed',$LADCP{ENSEMBLE}[$LADCP_end]->{ELAPSED_TIME}+$CTD{first_elapsed}-$opt_l, |
|
541 |
'LADCPproc::min_depth',depthOfGI($mingi),'LADCPproc::max_depth',depthOfGI($#ens_vals)); |
|
4 | 542 |
for (my($gi)=0; $gi<@ush_vals; $gi++) { |
6 | 543 |
for (my($i)=0; $i<@{$ush_vals[$gi]}; $i++){ |
16 | 544 |
&antsOut($ens_vals[$gi][$i], |
545 |
$LADCP{ENSEMBLE}[$ens_vals[$gi][$i]]->{ELAPSED_TIME}+$CTD{first_elapsed}-$opt_l, |
|
546 |
$LADCP{ENSEMBLE}[$ens_vals[$gi][$i]]->{DEPTH},$downcast, |
|
547 |
depthOfGI($gi),$ush_vals[$gi][$i],$vsh_vals[$gi][$i],$wsh_vals[$gi][$i]); |
|
4 | 548 |
} |
549 |
} |
|
550 |
} else { |
|
551 |
for (my($gi)=$#ush_vals; $gi>=0; $gi--) { |
|
552 |
for (my($i)=0; $i<@{$ush_vals[$gi]}; $i++) { |
|
16 | 553 |
&antsOut($ens_vals[$gi][$i], |
554 |
$LADCP{ENSEMBLE}[$ens_vals[$gi][$i]]->{ELAPSED_TIME}+$CTD{first_elapsed}-$opt_l, |
|
555 |
$LADCP{ENSEMBLE}[$ens_vals[$gi][$i]]->{DEPTH},$downcast, |
|
556 |
depthOfGI($gi),$ush_vals[$gi][$i],$vsh_vals[$gi][$i],$wsh_vals[$gi][$i]); |
|
4 | 557 |
} |
558 |
} |
|
559 |
} |
|
560 |
} # sub outDSseries |
|
561 |
||
562 |
#-------------------------------------------------------------------------------- |
|
16 | 563 |
# end of callback routine |
564 |
#-------------------------------------------------------------------------------- |
|
4 | 565 |
|
16 | 566 |
|
567 |
$commonParams = $antsCurParams; # PARAMs added up to now are common to all output files |
|
4 | 568 |
|
20 | 569 |
&antsAddParams('LADCPproc::ubin_start',$ubin_start,'LADCPproc::ubin_end',$ubin_end, # record processing params |
570 |
'LADCPproc::wbin_start',$wbin_start,'LADCPproc::wbin_end',$wbin_end, |
|
571 |
'LADCPproc::shbin_start',$shbin_start,'LADCPproc::shbin_end',$shbin_end, |
|
572 |
'LADCPproc::w_ref_bin',$w_ref_bin,'LADCPproc::w_dif',$w_dif, |
|
573 |
'LADCPproc::wake_hd_dif',$wake_hd_dif,'LADCPproc::wake_ang_min',$wake_ang_min, |
|
574 |
'LADCPproc::min_wake_w',$min_wake_w,'LADCPproc::n_wake_bins',$n_wake_bins, |
|
575 |
'LADCPproc::e_max',$e_max,'LADCPproc::min_cor',$min_cor, |
|
576 |
'LADCPproc::max_shdev',$max_shdev,'LADCPproc::max_shdev_sum',$max_shdev_sum, |
|
577 |
'LADCPproc::water_depth',round($water_depth),'LADCPproc::water_depth.sig',round($sig_water_depth), |
|
578 |
'LADCPproc::min_hab',round($min_hab),'LADCPproc::PPI_editing_enabled',$PPI_editing_enabled, |
|
579 |
'LADCPproc::clip_margin',$clip_margin,'LADCPproc::first_clip_bin',$first_clip_bin, |
|
580 |
'LADCPproc::Svbin_start',$Svbin_start,'LADCPproc::Svbin_end',$Svbin_end, |
|
581 |
'LADCPproc::BT_bin_start',$BT_bin_start,'LADCPproc::BT_bin_search_above',$BT_bin_search_above, |
|
582 |
'LADCPproc::BT_max_bin_spread',$BT_max_bin_spread,'LADCPproc::BT_max_w_difference',$BT_max_w_difference, |
|
4 | 583 |
); |
584 |
if (defined($BT_min_depth)) { |
|
20 | 585 |
&antsAddParams('LADCPproc::BT_min_depth',$BT_min_depth,'LADCPproc::BT_max_depth',$BT_max_depth); |
4 | 586 |
} else { |
20 | 587 |
&antsAddParams('LADCPproc::BT_max_depth_error',$BT_max_depth_error); |
4 | 588 |
} |
589 |
$fullParams = $antsCurParams; |
|
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 |
$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
|
592 |
|
3 | 593 |
print(STDERR "\n\tdowncast...") if ($opt_d); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
594 |
edit_velocity($LADCP_start,$LADCP_bottom); # downcast |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
595 |
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
|
596 |
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
|
597 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
598 |
@dc_sh_n = @sh_n; # save downcast results |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
599 |
@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
|
600 |
@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
|
601 |
@dc_wsh_mu = @wsh_mu; @dc_wsh_sig = @wsh_sig; |
7 | 602 |
@dc_esh_mu = @esh_mu; |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
603 |
|
3 | 604 |
print(STDERR "\n\tupcast...") if ($opt_d); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
605 |
edit_velocity($LADCP_end,$LADCP_bottom); # upcast |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
606 |
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
|
607 |
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
|
608 |
|
1 | 609 |
@uc_sh_n = @sh_n; # save upcast results |
610 |
@uc_ush_mu = @ush_mu; @uc_ush_sig = @ush_sig; |
|
611 |
@uc_vsh_mu = @vsh_mu; @uc_vsh_sig = @vsh_sig; |
|
612 |
@uc_wsh_mu = @wsh_mu; @uc_wsh_sig = @wsh_sig; |
|
7 | 613 |
@uc_esh_mu = @esh_mu; |
1 | 614 |
|
3 | 615 |
print(STDERR "\n\tcombined...") if ($opt_d); |
7 | 616 |
my($nsh) = (@dc_ush_mu > @uc_ush_mu) ? scalar(@dc_ush_mu) : scalar(@uc_ush_mu); |
617 |
for (my($gi)=0; $gi<$nsh; $gi++) { |
|
618 |
if (($gi<@dc_ush_mu&&$dc_sh_n[$gi]>0) && ($gi<@uc_ush_mu&&$uc_sh_n[$gi]>0)) { |
|
1 | 619 |
$sh_n[$gi] = $dc_sh_n[$gi] + $uc_sh_n[$gi]; |
620 |
$ush_mu[$gi] = ($dc_sh_n[$gi]*$dc_ush_mu[$gi] + $uc_sh_n[$gi]*$uc_ush_mu[$gi]) / $sh_n[$gi]; |
|
621 |
$vsh_mu[$gi] = ($dc_sh_n[$gi]*$dc_vsh_mu[$gi] + $uc_sh_n[$gi]*$uc_vsh_mu[$gi]) / $sh_n[$gi]; |
|
622 |
$wsh_mu[$gi] = ($dc_sh_n[$gi]*$dc_wsh_mu[$gi] + $uc_sh_n[$gi]*$uc_wsh_mu[$gi]) / $sh_n[$gi]; |
|
7 | 623 |
$esh_mu[$gi] = ($dc_sh_n[$gi]*$dc_esh_mu[$gi] + $uc_sh_n[$gi]*$uc_esh_mu[$gi]) / $sh_n[$gi]; |
1 | 624 |
$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]); |
625 |
$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]); |
|
626 |
$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 | 627 |
} elsif ($gi < @dc_ush_mu && $dc_sh_n[$gi] > 0) { |
1 | 628 |
$sh_n[$gi] = $dc_sh_n[$gi]; |
7 | 629 |
$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]; |
630 |
$ush_sig[$gi] = $dc_ush_sig[$gi]; $vsh_sig[$gi] = $dc_vsh_sig[$gi]; $wsh_sig[$gi] = $dc_wsh_sig[$gi]; |
|
631 |
} elsif ($gi < @uc_ush_mu && $uc_sh_n[$gi] > 0) { |
|
1 | 632 |
$sh_n[$gi] = $uc_sh_n[$gi]; |
7 | 633 |
$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]; |
634 |
$ush_sig[$gi] = $uc_ush_sig[$gi]; $vsh_sig[$gi] = $uc_vsh_sig[$gi]; $wsh_sig[$gi] = $uc_wsh_sig[$gi]; |
|
1 | 635 |
} else { |
636 |
$sh_n[$gi] = 0; |
|
7 | 637 |
$ush_mu[$gi] = $vsh_mu[$gi] = $wsh_mu[$gi] = $esh_mu[$gi] = nan; |
1 | 638 |
$ush_sig[$gi] = $vsh_sig[$gi] = $wsh_sig[$gi] = nan; |
639 |
} |
|
640 |
} |
|
641 |
||
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
642 |
print(STDERR "\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
643 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
644 |
#---------------------------------------------------------------------- |
1 | 645 |
# Step 9: Get bottom track profile |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
646 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
647 |
|
3 | 648 |
if ($LADCP{ENSEMBLE}[$LADCP_start]->{XDUCER_FACING_DOWN}) { |
649 |
print(STDERR "Getting BT profile..."); |
|
650 |
getBTprof($LADCP_start,$LADCP_end); |
|
651 |
print(STDERR "\n"); |
|
652 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
653 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
654 |
#---------------------------------------------------------------------- |
4 | 655 |
# Step 10: Write Output Profiles if requested |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
656 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
657 |
|
4 | 658 |
if (defined($opt_p)) { |
659 |
||
660 |
print(STDERR "Writing shear profiles..."); |
|
661 |
||
7 | 662 |
@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', |
663 |
'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 | 664 |
'elapsed','nsamp','u_z','u_z.sig','v_z','v_z.sig','w_z','w_z.sig','Sv','Sv.nsamp'); |
4 | 665 |
|
666 |
&antsOut('EOF'); |
|
667 |
close(STDOUT); |
|
668 |
open(STDOUT,">$opt_p") || croak("$opt_p: $!\n"); |
|
669 |
||
670 |
$antsCurParams = $fullParams; |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
671 |
|
7 | 672 |
for (my($gi)=0; $gi<$nsh; $gi++) { |
4 | 673 |
&antsOut(depthOfGI($gi), # depth in center of bin |
7 | 674 |
$dc_esh_mu[$gi], # downcast |
675 |
numberp($dc_sh_n[$gi])?$dc_sh_n[$gi]:0, |
|
4 | 676 |
$dc_ush_mu[$gi],$dc_ush_sig[$gi], |
677 |
$dc_vsh_mu[$gi],$dc_vsh_sig[$gi], |
|
678 |
$dc_wsh_mu[$gi],$dc_wsh_sig[$gi], |
|
7 | 679 |
$uc_esh_mu[$gi], # upcast |
680 |
numberp($uc_sh_n[$gi])?$uc_sh_n[$gi]:0, |
|
4 | 681 |
$uc_ush_mu[$gi],$uc_ush_sig[$gi], |
682 |
$uc_vsh_mu[$gi],$uc_vsh_sig[$gi], |
|
683 |
$uc_wsh_mu[$gi],$uc_wsh_sig[$gi], |
|
7 | 684 |
$esh_mu[$gi],$sh_n[$gi], # combined |
4 | 685 |
$ush_mu[$gi],$ush_sig[$gi], |
686 |
$vsh_mu[$gi],$vsh_sig[$gi], |
|
687 |
$wsh_mu[$gi],$wsh_sig[$gi], |
|
688 |
$nSv_prof[$gi]?$sSv_prof[$gi]/$nSv_prof[$gi]:nan, |
|
689 |
$nSv_prof[$gi], |
|
690 |
); |
|
691 |
} |
|
692 |
||
693 |
print(STDERR "\n"); |
|
694 |
} # if -p |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
695 |
|
3 | 696 |
#--------------------------------------- |
697 |
# Acoustic backscatter depth-time-series |
|
698 |
#--------------------------------------- |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
699 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
700 |
if (defined($opt_a)) { |
3 | 701 |
print(STDERR "Writing acoustic backscatter depth-time-series to <$opt_a>..."); |
702 |
||
703 |
||
704 |
@antsNewLayout = ('ens','elapsed','CTD_depth','depth','bin','downcast', |
|
705 |
'Sv_beam1','Sv_beam2','Sv_beam3','Sv_beam4','Sv.median'); |
|
706 |
&antsOut('EOF'); |
|
707 |
close(STDOUT); |
|
708 |
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
|
709 |
|
3 | 710 |
$antsCurParams = $commonParams; |
20 | 711 |
&antsAddParams('LADCPproc::min_elapsed',$LADCP{ENSEMBLE}[$LADCP_start]->{ELAPSED_TIME}+$CTD{first_elapsed}-$opt_l, |
712 |
'LADCPproc::max_elapsed',$LADCP{ENSEMBLE}[$LADCP_end]->{ELAPSED_TIME}+$CTD{first_elapsed}-$opt_l, |
|
713 |
'LADCPproc::min_depth',$LADCP{ENSEMBLE}[$LADCP_top]->{XDUCER_FACING_UP} ? |
|
3 | 714 |
&depthOfBin($LADCP_top,$LADCP{N_BINS}-1) : $LADCP{ENSEMBLE}[$LADCP_top]->{DEPTH}, |
20 | 715 |
'LADCPproc::max_depth',$LADCP{ENSEMBLE}[$LADCP_bottom]->{XDUCER_FACING_UP} ? |
3 | 716 |
$LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH} : &depthOfBin($LADCP_bottom,$LADCP{N_BINS}-1) |
717 |
); |
|
718 |
||
719 |
for (my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) { |
|
720 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) { |
|
721 |
&antsOut($LADCP{ENSEMBLE}[$ens]->{NUMBER}, |
|
6 | 722 |
$LADCP{ENSEMBLE}[$ens]->{ELAPSED_TIME}+$CTD{first_elapsed}-$opt_l, |
3 | 723 |
$LADCP{ENSEMBLE}[$ens]->{DEPTH}, |
6 | 724 |
&depthOfBin($ens,$bin),$bin+1, |
3 | 725 |
($ens <= $LADCP_bottom) ? 1 : 0, |
726 |
@{$LADCP{ENSEMBLE}[$ens]->{SV}[$bin]}, |
|
727 |
median(@{$LADCP{ENSEMBLE}[$ens]->{SV}[$bin]}) |
|
728 |
); |
|
729 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
730 |
} |
3 | 731 |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
732 |
print(STDERR "\n"); |
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 |
|
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 |
if (defined($opt_t)) { |
3 | 738 |
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
|
739 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
740 |
@antsNewLayout = ('ens','elapsed','depth','CTD_w','LADCP_w'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
741 |
&antsOut('EOF'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
742 |
$antsCurParams = $commonParams; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
743 |
close(STDOUT); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
744 |
open(STDOUT,">$opt_t") || croak("$opt_t: $!\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
745 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
746 |
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
|
747 |
&antsOut($LADCP{ENSEMBLE}[$ens]->{NUMBER}, |
6 | 748 |
$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
|
749 |
$LADCP{ENSEMBLE}[$ens]->{DEPTH}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
750 |
$LADCP{ENSEMBLE}[$ens]->{CTD_W}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
751 |
$LADCP{ENSEMBLE}[$ens]->{W}); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
752 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
753 |
print(STDERR "\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
754 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
755 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
756 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
757 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
758 |
if (defined($opt_b)) { |
3 | 759 |
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
|
760 |
|
6 | 761 |
@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
|
762 |
&antsOut('EOF'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
763 |
$antsCurParams = $commonParams; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
764 |
close(STDOUT); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
765 |
open(STDOUT,">$opt_b") || croak("$opt_b: $!\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
766 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
767 |
my($skipped); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
768 |
for (my($gi)=0; $gi<@BT_nsamp; $gi++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
769 |
$skipped = 1 if ($BT_nsamp[$gi] > 0); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
770 |
next unless ($skipped); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
771 |
&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
|
772 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
773 |
print(STDERR "\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
774 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
775 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
776 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
777 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
778 |
if (defined($opt_f)) { |
3 | 779 |
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
|
780 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
781 |
@antsNewLayout = ('ens'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
782 |
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
|
783 |
$antsNewLayout[$i] = "bin$i"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
784 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
785 |
&antsOut('EOF'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
786 |
$antsCurParams = $commonParams; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
787 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
788 |
close(STDOUT); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
789 |
open(STDOUT,">$opt_f") || croak("$opt_f: $!\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
790 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
791 |
&antsPrintHeaders(STDOUT,@antsNewLayout); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
792 |
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
|
793 |
printf('%4d ',$LADCP{ENSEMBLE}[$ens]->{NUMBER}); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
794 |
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
|
795 |
printf("%02x ",$edit_flags[$ens][$bin]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
796 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
797 |
print($opt_R); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
798 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
799 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
800 |
print(STDERR "\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
801 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
802 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
803 |
&antsExit(); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
804 |