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