author | A.M. Thurnherr <ant@ldeo.columbia.edu> |
Sat, 09 Jul 2011 15:14:10 -0400 | |
changeset 3 | 711dd29cb6dd |
parent 2 | 16726a31a399 |
child 4 | 0d31245172fa |
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 |
3 | 5 |
# dlm: Fri Jul 8 03:33:21 2011 |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
6 |
# (c) 2010 A.M. Thurnherr & E. Firing |
3 | 7 |
# uE-Info: 491 0 NIL 0 0 72 2 2 4 NIL ofnI |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
8 |
#====================================================================== |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
9 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
10 |
$antsSummary = 'process LADCP data to get shear, time series'; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
11 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
12 |
# NOTES: |
1 | 13 |
# - this code is based on merge.c written by Eric Firing |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
14 |
# - comments starting with ## are taken from Eric's code |
1 | 15 |
# - for SeaBird files, CTD elapsed time is estimated from recno * CTD{sampint} |
16 |
# - CTD{elapsed} is undefined for records before instrument is in the water |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
17 |
# - ITS-90 temp field in degC required |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
18 |
# - salin field prequired |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
19 |
# - pressure field in dbar required |
1 | 20 |
# - -i should be set to the number that's added to LADCP_elapsed to make the two |
21 |
# time series overplot nicely |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
22 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
23 |
# HISTORY: |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
24 |
# Sep 16, 2010: - incepted |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
25 |
# Oct 13, 2010: - first working version |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
26 |
# Oct 14, 2010: - renamed from LADCPshear |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
27 |
# Oct 19, 2010: - added -a)coustic backscatter profiles |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
28 |
# Oct 20, 2010: - added -2)dary CTD sensors |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
29 |
# Oct 23, 2010: - added magnetic-declination correction |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
30 |
# Oct 26, 2010: - added tilt calculation |
1 | 31 |
# Dec 9, 2010: - added support for ASCII CTD files |
32 |
# Dec 10, 2010: - change -w) default to 120s |
|
33 |
# - changed nshear output to 0 from nan when there are no samples |
|
34 |
# Dec 27, 2010: - changed sign of -l to accept lag output from [LADCP_w] |
|
2 | 35 |
# Jan 10, 2011: - -o => -k added new -o |
1 | 36 |
# - added code to fill CTD sound vel gaps |
2 | 37 |
# Jan 22, 2011: - added -g) lat,lon |
38 |
# - added -c)ompass corr |
|
39 |
# Jun 15, 2011: - added mean backscatter profile to default output |
|
3 | 40 |
# Jul 7, 2011: - added support for $BT_* processing parameters |
41 |
# - replaced old per-bin acoustic backscatter profile output by |
|
42 |
# acoustic backscatter depth-time-series |
|
43 |
# - disabled seabed and acoustic backscatter code when not required (e.g. UL) |
|
44 |
# - made non-diagnostic output terser |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
45 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
46 |
($ANTS) = (`which list` =~ m{^(.*)/[^/]*$}); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
47 |
($PERL_TOOLS) = (`which mkProfile` =~ m{^(.*)/[^/]*$}); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
48 |
($LADCPPROC) = ($0 =~ m{^(.*)/[^/]*$}); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
49 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
50 |
require "$ANTS/ants.pl"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
51 |
require "$ANTS/libEOS83.pl"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
52 |
require "$ANTS/libstats.pl"; |
1 | 53 |
require "$LADCPPROC/LADCPproc.loadCTD"; |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
54 |
require "$LADCPPROC/LADCPproc.bestLag"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
55 |
require "$LADCPPROC/LADCPproc.BT"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
56 |
require "$LADCPPROC/LADCPproc.backscatter"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
57 |
require "$LADCPPROC/LADCPproc.UHcode"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
58 |
require "$PERL_TOOLS/RDI_BB_Read.pl"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
59 |
require "$PERL_TOOLS/RDI_Coords.pl"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
60 |
require "$PERL_TOOLS/RDI_Utils.pl"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
61 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
62 |
$antsParseHeader = 0; |
3 | 63 |
&antsUsage('24a:b:c:df:g:i:kl:n:o:ps:t:w:',2, |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
64 |
'[use -2)dary CTD sensor pair]', |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
65 |
'[require -4)-beam LADCP solutions]', |
2 | 66 |
'[-s)etup <file>] [-g)ps <lat,lon>]', |
67 |
'[-c)ompass-corr <offset,cos-fac,sin-fac>]', |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
68 |
'[enable -p)PI editing]', |
1 | 69 |
'[-o)utput grid <resolution[5m]>]', |
70 |
'[-i)nitial LADCP time lag <guestimate>]', |
|
71 |
'[-l)ag LADCP <by>] [auto-lag -w)indow <size[120s]>] [-n) <auto-lag windows[20]]', |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
72 |
'[-d)iagnostic output]', |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
73 |
'output: [-t)ime series <file>] [-f)lag <file>] [-b)ottom-track <file>]', |
3 | 74 |
' [-a)coustic backscatter <depth-time-series file] [bottom-trac-k) profs]', |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
75 |
'<RDI file> <SeaBird file>'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
76 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
77 |
$RDI_Coords::minValidVels = 4 if ($opt_4); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
78 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
79 |
&antsFloatOpt($opt_l); |
1 | 80 |
&antsCardOpt(\$opt_w,120); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
81 |
# old default of -w 30 does not work if there are significant ambiguity-velocity |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
82 |
# problems, as is the case, e.g., with 2010_DIMES_US2 station 142 |
1 | 83 |
# old default of -w 60 did not work for DIMES_UK2 station 4 (DL), possibly again |
84 |
# related to ambiguity velocity |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
85 |
&antsCardOpt(\$opt_n,20); |
1 | 86 |
&antsFileOpt($opt_s); |
87 |
&antsFloatOpt($opt_i); |
|
88 |
&antsCardOpt($opt_o); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
89 |
|
2 | 90 |
if (defined($opt_g)) { |
91 |
($CTD{lat},$CTD{lon}) = split(',',$opt_g); |
|
92 |
croak("$0: cannot decode -g $opt_g\n") |
|
93 |
unless numberp($CTD{lat}) && numberp($CTD{lon}); |
|
94 |
} |
|
95 |
||
96 |
if (defined($opt_c)) { |
|
97 |
($CC_offset,$CC_cos_fac,$CC_sin_fac) = split(',',$opt_c); |
|
98 |
croak("$0: cannot decode -c $opt_c\n") |
|
99 |
unless numberp($CC_offset) && numberp($CC_cos_fac) && numberp($CC_sin_fac); |
|
100 |
} |
|
101 |
||
102 |
||
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
103 |
$LADCP_file = &antsFileArg(); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
104 |
$CTD_file = &antsFileArg(); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
105 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
106 |
&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
|
107 |
&antsActivateOut(); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
108 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
109 |
#---------------------------------------------------------------------- |
1 | 110 |
# Step 1: Read LADCP Data |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
111 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
112 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
113 |
print(STDERR "Reading LADCP data ($LADCP_file)..."); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
114 |
readData($LADCP_file,\%LADCP); |
3 | 115 |
printf(STDERR "\n\t%d ensembles",scalar(@{$LADCP{ENSEMBLE}})) if ($opt_d); |
116 |
print(STDERR "\n"); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
117 |
|
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 |
# Step 2: Set Processing Parameters |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
120 |
#---------------------------------------------------------------------- |
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 |
print(STDERR "Setting processing parameters...\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
123 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
124 |
printf(STDERR "\tloading $LADCPPROC/LADCPproc.defaults...\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
125 |
require "$LADCPPROC/LADCPproc.defaults"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
126 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
127 |
if (defined($opt_s)) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
128 |
print(STDERR "\tloading $opt_s...\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
129 |
require $opt_s; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
130 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
131 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
132 |
if ($LADCP{BLANKING_DISTANCE} == 0) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
133 |
print(STDERR "\t\tBLANKING_DISTANCE == 0 => excluding all data from bin 1\n") |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
134 |
if ($opt_d); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
135 |
$wbin_start = 2 unless ($wbin_start > 2); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
136 |
$ubin_start = 2 unless ($ubin_start > 2); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
137 |
$shbin_start = 2 unless ($shbin_start > 2); |
3 | 138 |
$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
|
139 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
140 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
141 |
&antsAddParams('ADCP_orientation', |
3 | 142 |
$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
|
143 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
144 |
$SHEAR_PREGRID_DZ = 20; |
1 | 145 |
$GRID_DZ = defined($opt_o) ? $opt_o : 5; |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
146 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
147 |
my($year) = substr($LADCP{ENSEMBLE}[0]->{DATE},6,4); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
148 |
my($month) = substr($LADCP{ENSEMBLE}[0]->{DATE},0,2); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
149 |
my($dau ) = substr($LADCP{ENSEMBLE}[0]->{DATE},3,2); |
1 | 150 |
my($magdec,$maginc,$h_strength,$v_strength) = split('\s+',`magdec $CTD{lon} $CTD{lat} $year $month $day`); |
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 |
croak("$0: unknown magnetic declination\n") |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
153 |
unless defined($magdec); |
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 |
&antsAddParams('magnetic_declination',$magdec); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
156 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
157 |
#---------------------------------------------------------------------- |
1 | 158 |
# Step 3: Read CTD data |
159 |
#---------------------------------------------------------------------- |
|
160 |
||
161 |
print(STDERR "Reading CTD data ($CTD_file)..."); |
|
162 |
readCTD($CTD_file,\%CTD); |
|
3 | 163 |
printf(STDERR "\n\t%d scans",scalar(@{$CTD{press}})) if ($opt_d); |
164 |
print(STDERR "\n"); |
|
1 | 165 |
|
166 |
#---------------------------------------------------------------------- |
|
167 |
# Step 4: Pre-Process CTD & LADCP Data |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
168 |
#---------------------------------------------------------------------- |
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 "Pre-processing data..."); |
3 | 171 |
printf(STDERR "\n\tCTD...") if ($opt_d); |
0
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 |
#------------------------ |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
174 |
# clean CTD pressure data |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
175 |
#------------------------ |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
176 |
my($pSpikes) = 0; |
1 | 177 |
for (my($r)=1; $r<@{$CTD{press}}; $r++) { |
178 |
$pSpikes++,$CTD{press}[$r]=nan |
|
179 |
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
|
180 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
181 |
print(STDERR "\n\t\t$pSpikes pressure spikes removed") |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
182 |
if ($pSpikes>0 && $opt_d); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
183 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
184 |
#------------------------------------ |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
185 |
# calculate w and find deepest record |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
186 |
#------------------------------------ |
1 | 187 |
$CTD{maxpress} = -9e99; |
188 |
for (my($r)=1; $r<@{$CTD{press}}-1; $r++) { |
|
189 |
$CTD{w}[$r] = 0.99*($CTD{press}[$r+1] - $CTD{press}[$r-1]) / (2*$CTD{sampint}); |
|
190 |
if ($CTD{press}[$r] > $CTD{maxpress}) { |
|
191 |
$CTD{maxpress} = $CTD{press}[$r]; |
|
192 |
$CTD{atbottom} = $r; |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
193 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
194 |
} |
1 | 195 |
printf(STDERR "\n\t\tmax pressure [%ddbar] at scan#%d",$CTD{maxpress},$CTD{atbottom}) |
196 |
if $opt_d; |
|
197 |
||
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
198 |
#---------------------------------------------------------------------- |
1 | 199 |
# Step 4b: Pre-Process LADCP Data |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
200 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
201 |
|
3 | 202 |
print(STDERR "\n\tLADCP...") if ($opt_d); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
203 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
204 |
#------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
205 |
# transform to earth coordinates if required |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
206 |
#------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
207 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
208 |
$U = 0; # velocity indices |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
209 |
$V = 1; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
210 |
$W = 2; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
211 |
$E = 3; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
212 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
213 |
$LADCP{HEADING_BIAS} = -$magdec; |
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 |
if ($LADCP{BEAM_COORDINATES}) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
216 |
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
|
217 |
if ($opt_d); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
218 |
for (my($ens)=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
219 |
$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
|
220 |
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
|
221 |
@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]} = |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
222 |
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
|
223 |
@{$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
|
224 |
(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
|
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 |
$LADCP{BEAM_COORDINATES} = 0; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
228 |
$LADCP{EARTH_COORDINATES} = 1; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
229 |
unless ($opt_4) { |
1 | 230 |
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
|
231 |
if ($opt_d); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
232 |
&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
|
233 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
234 |
} elsif ($LADCP{EARTH_COORDINATES}) { |
2 | 235 |
if ($opt_d) { |
236 |
if ($opt_c) { |
|
237 |
printf(STDERR "\n\t\tcalculating tilt and correcting for compass error and magnetic declination of %.1f deg...\n",$magdec); |
|
238 |
} else { |
|
239 |
printf(STDERR "\n\t\tcalculating tilt and correcting for magnetic declination of %.1f deg...\n",$magdec); |
|
240 |
} |
|
241 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
242 |
for (my($ens)=0; $ens<=$#{$LADCP{ENSEMBLE}}; $ens++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
243 |
$LADCP{ENSEMBLE}[$ens]->{TILT} = &angle_from_vertical($LADCP{ENSEMBLE}[$ens]->{PITCH},$LADCP{ENSEMBLE}[$ens]->{ROLL}); |
2 | 244 |
my($hdg) = rad($LADCP{ENSEMBLE}[$ens]->{HEADING}); |
245 |
$LADCP{HEADING_BIAS} = ($CC_offset + $CC_cos_fac*cos($hdg) + $CC_sin_fac*sin($hdg)) - $magdec |
|
246 |
if ($opt_c); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
247 |
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
|
248 |
@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]} = |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
249 |
velApplyHdgBias(\%LADCP,$ens,@{$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin]}); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
250 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
251 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
252 |
} else { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
253 |
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
|
254 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
255 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
256 |
#------------------------------------------------------ |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
257 |
# 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
|
258 |
#------------------------------------------------------ |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
259 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
260 |
print(STDERR "\t\tconstructing profile time series...") |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
261 |
if ($opt_d); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
262 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
263 |
($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
|
264 |
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
|
265 |
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
|
266 |
unless defined($LADCP_start); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
267 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
268 |
if ($opt_d) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
269 |
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
|
270 |
$LADCP{ENSEMBLE}[$LADCP_start]->{TIME}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
271 |
$LADCP{ENSEMBLE}[$LADCP_start]->{NUMBER}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
272 |
$LADCP{ENSEMBLE}[$LADCP_start]->{DEPTH}); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
273 |
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
|
274 |
$LADCP{ENSEMBLE}[$LADCP_bottom]->{TIME}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
275 |
$LADCP{ENSEMBLE}[$LADCP_bottom]->{NUMBER}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
276 |
$LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH}); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
277 |
printf(STDERR "\t\t\tEnd of cast : %s (#%5d) at %6.1fm", |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
278 |
$LADCP{ENSEMBLE}[$LADCP_end]->{TIME}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
279 |
$LADCP{ENSEMBLE}[$LADCP_end]->{NUMBER}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
280 |
$LADCP{ENSEMBLE}[$LADCP_end]->{DEPTH}); |
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 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
283 |
print(STDERR "\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
284 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
285 |
#---------------------------------------------------------------------- |
1 | 286 |
# 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
|
287 |
# - {DEPTH} field is overwritten! |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
288 |
#---------------------------------------------------------------------- |
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 |
print(STDERR "Matching CTD to LADCP time series..."); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
291 |
|
1 | 292 |
$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
|
293 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
294 |
print(STDERR "Associating CTD data with LADCP ensembles..."); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
295 |
|
3 | 296 |
for (my($min_depth)=9e99,my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) { |
297 |
my($lastSvel); |
|
1 | 298 |
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
|
299 |
if ($r < 0 && $ens == $LADCP_start) { |
1 | 300 |
$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
|
301 |
while ($r < 0); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
302 |
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
|
303 |
$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
|
304 |
$LADCP_start = $ens; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
305 |
} |
1 | 306 |
if ($r > $#{$CTD{press}}) { |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
307 |
printf(STDERR "\n\tCTD data end while instrument is still in water => truncating %ds of LADCP data", |
3 | 308 |
$LADCP{ENSEMBLE}[$LADCP_end]->{ELAPSED_TIME}-$LADCP{ENSEMBLE}[$ens]->{ELAPSED_TIME}) |
309 |
if ($opt_d); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
310 |
$LADCP_end = $ens - 1; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
311 |
last; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
312 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
313 |
my($dr); |
1 | 314 |
for ($dr=0; !numberp($CTD{press}[$r+$dr]); $dr--) {} |
315 |
$LADCP{ENSEMBLE}[$ens]->{DEPTH} = depth($CTD{press}[$r+$dr],$CTD{lat}); |
|
3 | 316 |
if ($LADCP{ENSEMBLE}[$ens]->{DEPTH} < $min_depth) { |
317 |
$min_depth = $LADCP{ENSEMBLE}[$ens]->{DEPTH}; |
|
318 |
$LADCP_top = $ens; |
|
319 |
} |
|
1 | 320 |
$LADCP{ENSEMBLE}[$ens]->{CTD_W} = $CTD{w}[$r]; |
321 |
$LADCP{ENSEMBLE}[$ens]->{CTD_TEMP} = $CTD{temp}[$r]; |
|
322 |
$LADCP{ENSEMBLE}[$ens]->{CTD_SVEL} = sVel($CTD{salin}[$r],$CTD{temp}[$r],$CTD{press}[$r+$dr]); |
|
323 |
if (numberp($LADCP{ENSEMBLE}[$ens]->{CTD_SVEL})) { |
|
324 |
$lastSvel = $LADCP{ENSEMBLE}[$ens]->{CTD_SVEL}; |
|
325 |
} else { |
|
326 |
$LADCP{ENSEMBLE}[$ens]->{CTD_SVEL} = $lastSvel; |
|
327 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
328 |
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
|
329 |
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
|
330 |
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
|
331 |
$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$U] *= $sscorr; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
332 |
$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$V] *= $sscorr; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
333 |
$LADCP{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$W] *= $sscorr; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
334 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
335 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
336 |
|
3 | 337 |
&antsAddParams('top_depth',,round($LADCP{ENSEMBLE}[$LADCP_top]->{DEPTH}), |
338 |
'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
|
339 |
'start_date',$LADCP{ENSEMBLE}[$LADCP_start]->{DATE}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
340 |
'start_time',$LADCP{ENSEMBLE}[$LADCP_start]->{TIME}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
341 |
'bottom_date',$LADCP{ENSEMBLE}[$LADCP_bottom]->{DATE}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
342 |
'bottom_time',$LADCP{ENSEMBLE}[$LADCP_bottom]->{TIME}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
343 |
'end_date',$LADCP{ENSEMBLE}[$LADCP_end]->{DATE}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
344 |
'end_time',$LADCP{ENSEMBLE}[$LADCP_end]->{TIME}); |
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 "\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
347 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
348 |
#---------------------------------------------------------------------- |
1 | 349 |
# Step 6: Calculate Acoustic Backscatter Profile |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
350 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
351 |
|
3 | 352 |
print(STDERR "Calculating acoustic backscatter profiles..."); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
353 |
mk_backscatter_profs($LADCP_start,$LADCP_end); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
354 |
print(STDERR "\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
355 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
356 |
#---------------------------------------------------------------------- |
1 | 357 |
# Step 7: Find Seabed |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
358 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
359 |
|
3 | 360 |
if ($LADCP{ENSEMBLE}[$LADCP_start]->{XDUCER_FACING_DOWN}) { |
361 |
||
362 |
print(STDERR "Finding seabed..."); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
363 |
|
3 | 364 |
print(STDERR "\n\tin acoustic backscatter profiles...") if ($opt_d); |
365 |
($water_depth,$sig_water_depth) = |
|
366 |
find_backscatter_seabed($LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH}); |
|
367 |
||
368 |
$min_hab = $water_depth - $LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH}; |
|
369 |
printf(STDERR "\n\twater depth = %d(+-%.1f)m",$water_depth,$sig_water_depth); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
370 |
printf(STDERR "\n\tclosest approach = %dmab",$min_hab); |
3 | 371 |
|
372 |
print(STDERR "\n\tin RDI BT data...") if ($opt_d); |
|
373 |
($BT_water_depth,$sig_BT_water_depth) = |
|
374 |
find_seabed(\%LADCP,$LADCP_bottom,$LADCP{BEAM_COORDINATES}); |
|
375 |
||
376 |
if (defined($BT_water_depth)) { |
|
377 |
$min_hab = $BT_water_depth - $LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH}; |
|
378 |
printf(STDERR "\n\twater depth = %d(+-%.1f)m",$BT_water_depth,$sig_BT_water_depth); |
|
379 |
printf(STDERR "\n\tclosest approach = %dmab",$min_hab); |
|
380 |
# $water_depth = $BT_water_depth; # assume BT data are better |
|
381 |
# $sig_water_depth = $sig_BT_water_depth; # (at least they are higher vertical resolution) |
|
382 |
} |
|
383 |
||
384 |
unless (defined($water_depth)) { |
|
385 |
print(STDERR "\n\tno seabed found\n"); |
|
386 |
print(STDERR "\n\tunknown water depth => PPI editing disabled\n") |
|
387 |
if ($opt_d); |
|
388 |
$clip_margin = 0; |
|
389 |
} |
|
390 |
||
391 |
print(STDERR "\n"); |
|
392 |
||
393 |
} else { # UPLOOKER |
|
394 |
$water_depth = $sig_water_depth = $min_hab = nan; |
|
395 |
print(STDERR "Uplooker data => PPI editing disabled\n") |
|
396 |
if ($opt_d); |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
397 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
398 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
399 |
#---------------------------------------------------------------------- |
1 | 400 |
# Step 8: Edit Data |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
401 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
402 |
|
3 | 403 |
print(STDERR "Calculating shear profiles..."); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
404 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
405 |
$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
|
406 |
|
3 | 407 |
print(STDERR "\n\tdowncast...") if ($opt_d); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
408 |
edit_velocity($LADCP_start,$LADCP_bottom); # downcast |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
409 |
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
|
410 |
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
|
411 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
412 |
@dc_sh_n = @sh_n; # save downcast results |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
413 |
@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
|
414 |
@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
|
415 |
@dc_wsh_mu = @wsh_mu; @dc_wsh_sig = @wsh_sig; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
416 |
|
3 | 417 |
print(STDERR "\n\tupcast...") if ($opt_d); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
418 |
edit_velocity($LADCP_end,$LADCP_bottom); # upcast |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
419 |
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
|
420 |
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
|
421 |
|
1 | 422 |
@uc_sh_n = @sh_n; # save upcast results |
423 |
@uc_ush_mu = @ush_mu; @uc_ush_sig = @ush_sig; |
|
424 |
@uc_vsh_mu = @vsh_mu; @uc_vsh_sig = @vsh_sig; |
|
425 |
@uc_wsh_mu = @wsh_mu; @uc_wsh_sig = @wsh_sig; |
|
426 |
||
3 | 427 |
print(STDERR "\n\tcombined...") if ($opt_d); |
1 | 428 |
for (my($gi)=0; $gi<@dc_ush_mu; $gi++) { |
429 |
if ($dc_sh_n[$gi]>0 && $uc_sh_n[$gi]>0) { |
|
430 |
$sh_n[$gi] = $dc_sh_n[$gi] + $uc_sh_n[$gi]; |
|
431 |
$ush_mu[$gi] = ($dc_sh_n[$gi]*$dc_ush_mu[$gi] + $uc_sh_n[$gi]*$uc_ush_mu[$gi]) / $sh_n[$gi]; |
|
432 |
$vsh_mu[$gi] = ($dc_sh_n[$gi]*$dc_vsh_mu[$gi] + $uc_sh_n[$gi]*$uc_vsh_mu[$gi]) / $sh_n[$gi]; |
|
433 |
$wsh_mu[$gi] = ($dc_sh_n[$gi]*$dc_wsh_mu[$gi] + $uc_sh_n[$gi]*$uc_wsh_mu[$gi]) / $sh_n[$gi]; |
|
434 |
$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]); |
|
435 |
$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]); |
|
436 |
$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]); |
|
437 |
} elsif ($dc_sh_n[$gi] > 0) { |
|
438 |
$sh_n[$gi] = $dc_sh_n[$gi]; |
|
439 |
$ush_mu[$gi] = $dc_ush_mu[$gi]; $vsh_mu[$gi] = $dc_vsh_mu[$gi]; $wsh_mu[$gi] = $dc_wsh_mu[$gi]; |
|
440 |
$ush_sig[$gi] = $dc_ush_sig[$gi]; $vsh_sig[$gi] = $dc_vsh_sig[$gi]; $wsh_sig[$gi] = $dc_wsh_sig[$gi]; |
|
441 |
} elsif ($uc_sh_n[$gi] > 0) { |
|
442 |
$sh_n[$gi] = $uc_sh_n[$gi]; |
|
443 |
$ush_mu[$gi] = $uc_ush_mu[$gi]; $vsh_mu[$gi] = $uc_vsh_mu[$gi]; $wsh_mu[$gi] = $uc_wsh_mu[$gi]; |
|
444 |
$ush_sig[$gi] = $uc_ush_sig[$gi]; $vsh_sig[$gi] = $uc_vsh_sig[$gi]; $wsh_sig[$gi] = $uc_wsh_sig[$gi]; |
|
445 |
} else { |
|
446 |
$sh_n[$gi] = 0; |
|
447 |
$ush_mu[$gi] = $vsh_mu[$gi] = $wsh_mu[$gi] = nan; |
|
448 |
$ush_sig[$gi] = $vsh_sig[$gi] = $wsh_sig[$gi] = nan; |
|
449 |
} |
|
450 |
} |
|
451 |
||
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
452 |
print(STDERR "\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
453 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
454 |
#---------------------------------------------------------------------- |
1 | 455 |
# Step 9: Get bottom track profile |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
456 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
457 |
|
3 | 458 |
if ($LADCP{ENSEMBLE}[$LADCP_start]->{XDUCER_FACING_DOWN}) { |
459 |
print(STDERR "Getting BT profile..."); |
|
460 |
getBTprof($LADCP_start,$LADCP_end); |
|
461 |
print(STDERR "\n"); |
|
462 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
463 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
464 |
#---------------------------------------------------------------------- |
3 | 465 |
# Step 10: Write Output Files |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
466 |
#---------------------------------------------------------------------- |
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 |
print(STDERR "Writing shear profiles..."); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
469 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
470 |
@antsNewLayout = ('depth','dc_nshear','dc_u_z','dc_u_z.sig','dc_v_z','dc_v_z.sig','dc_w_z','dc_w_z.sig', |
1 | 471 |
'uc_nshear','uc_u_z','uc_u_z.sig','uc_v_z','uc_v_z.sig','uc_w_z','uc_w_z.sig', |
2 | 472 |
'nshear','u_z','u_z.sig','v_z','v_z.sig','w_z','w_z.sig','Sv','Sv.n'); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
473 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
474 |
$commonParams = $antsCurParams; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
475 |
&antsAddParams('ubin_start',$ubin_start,'ubin_end',$ubin_end, # record processing params |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
476 |
'wbin_start',$wbin_start,'wbin_end',$wbin_end, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
477 |
'shbin_start',$shbin_start,'shbin_end',$shbin_end, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
478 |
'w_ref_bin',$w_ref_bin,'w_dif',$w_dif, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
479 |
'wake_hd_dif',$wake_hd_dif,'wake_ang_min',$wake_ang_min, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
480 |
'min_wake_w',$min_wake_w,'n_wake_bins',$n_wake_bins, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
481 |
'e_max',$e_max,'min_cor',$min_cor, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
482 |
'max_shdev',$max_shdev,'max_shdev_sum',$max_shdev_sum, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
483 |
'water_depth',round($water_depth),'water_depth.sig',round($sig_water_depth), |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
484 |
'min_hab',round($min_hab), |
2 | 485 |
'clip_margin',$clip_margin,'first_clip_bin',$first_clip_bin, |
3 | 486 |
'Svbin_start',$Svbin_start,'Svbin_end',$Svbin_end, |
487 |
'BT_bin_start',$BT_bin_start,'BT_bin_search_above',$BT_bin_search_above, |
|
488 |
'BT_max_bin_spread',$BT_max_bin_spread,'BT_max_w_difference',$BT_max_w_difference, |
|
489 |
); |
|
490 |
if (defined($BT_min_depth)) { |
|
491 |
&antsAddParams('BT_min_depth',$BT_min_depth,'BT_max_depth',$BT_max_depth); |
|
492 |
} else { |
|
493 |
&antsAddParams('BT_max_depth_error',$BT_max_depth_error); |
|
494 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
495 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
496 |
for (my($gi)=0; $gi<@ush_mu; $gi++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
497 |
&antsOut(depthOfGI($gi), # depth in center of bin |
1 | 498 |
numberp($dc_sh_n[$gi])?$dc_sh_n[$gi]:0, # downcast |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
499 |
$dc_ush_mu[$gi],$dc_ush_sig[$gi], |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
500 |
$dc_vsh_mu[$gi],$dc_vsh_sig[$gi], |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
501 |
$dc_wsh_mu[$gi],$dc_wsh_sig[$gi], |
1 | 502 |
numberp($uc_sh_n[$gi])?$uc_sh_n[$gi]:0, # upcast |
503 |
$uc_ush_mu[$gi],$uc_ush_sig[$gi], |
|
504 |
$uc_vsh_mu[$gi],$uc_vsh_sig[$gi], |
|
505 |
$uc_wsh_mu[$gi],$uc_wsh_sig[$gi], |
|
2 | 506 |
$sh_n[$gi], # combined |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
507 |
$ush_mu[$gi],$ush_sig[$gi], |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
508 |
$vsh_mu[$gi],$vsh_sig[$gi], |
1 | 509 |
$wsh_mu[$gi],$wsh_sig[$gi], |
2 | 510 |
$nSv_prof[$gi]?$sSv_prof[$gi]/$nSv_prof[$gi]:nan, |
511 |
$nSv_prof[$gi], |
|
1 | 512 |
); |
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
513 |
} |
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 |
print(STDERR "\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
516 |
|
3 | 517 |
#--------------------------------------- |
518 |
# Acoustic backscatter depth-time-series |
|
519 |
#--------------------------------------- |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
520 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
521 |
if (defined($opt_a)) { |
3 | 522 |
print(STDERR "Writing acoustic backscatter depth-time-series to <$opt_a>..."); |
523 |
||
524 |
||
525 |
@antsNewLayout = ('ens','elapsed','CTD_depth','depth','bin','downcast', |
|
526 |
'Sv_beam1','Sv_beam2','Sv_beam3','Sv_beam4','Sv.median'); |
|
527 |
&antsOut('EOF'); |
|
528 |
close(STDOUT); |
|
529 |
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
|
530 |
|
3 | 531 |
$antsCurParams = $commonParams; |
532 |
&antsAddParams('min_elapsed',$LADCP{ENSEMBLE}[$LADCP_start]->{ELAPSED_TIME}, |
|
533 |
'max_elapsed',$LADCP{ENSEMBLE}[$LADCP_end]->{ELAPSED_TIME}, |
|
534 |
'min_depth',$LADCP{ENSEMBLE}[$LADCP_top]->{XDUCER_FACING_UP} ? |
|
535 |
&depthOfBin($LADCP_top,$LADCP{N_BINS}-1) : $LADCP{ENSEMBLE}[$LADCP_top]->{DEPTH}, |
|
536 |
'max_depth',$LADCP{ENSEMBLE}[$LADCP_bottom]->{XDUCER_FACING_UP} ? |
|
537 |
$LADCP{ENSEMBLE}[$LADCP_bottom]->{DEPTH} : &depthOfBin($LADCP_bottom,$LADCP{N_BINS}-1) |
|
538 |
); |
|
539 |
||
540 |
for (my($ens)=$LADCP_start; $ens<=$LADCP_end; $ens++) { |
|
541 |
for (my($bin)=0; $bin<$LADCP{N_BINS}; $bin++) { |
|
542 |
&antsOut($LADCP{ENSEMBLE}[$ens]->{NUMBER}, |
|
543 |
$LADCP{ENSEMBLE}[$ens]->{ELAPSED_TIME}, |
|
544 |
$LADCP{ENSEMBLE}[$ens]->{DEPTH}, |
|
545 |
&depthOfBin($ens,$bin),$bin, |
|
546 |
($ens <= $LADCP_bottom) ? 1 : 0, |
|
547 |
@{$LADCP{ENSEMBLE}[$ens]->{SV}[$bin]}, |
|
548 |
median(@{$LADCP{ENSEMBLE}[$ens]->{SV}[$bin]}) |
|
549 |
); |
|
550 |
} |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
551 |
} |
3 | 552 |
|
0
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
553 |
print(STDERR "\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
554 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
555 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
556 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
557 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
558 |
if (defined($opt_t)) { |
3 | 559 |
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
|
560 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
561 |
@antsNewLayout = ('ens','elapsed','depth','CTD_w','LADCP_w'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
562 |
&antsOut('EOF'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
563 |
$antsCurParams = $commonParams; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
564 |
close(STDOUT); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
565 |
open(STDOUT,">$opt_t") || croak("$opt_t: $!\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
566 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
567 |
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
|
568 |
&antsOut($LADCP{ENSEMBLE}[$ens]->{NUMBER}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
569 |
$LADCP{ENSEMBLE}[$ens]->{ELAPSED_TIME}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
570 |
$LADCP{ENSEMBLE}[$ens]->{DEPTH}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
571 |
$LADCP{ENSEMBLE}[$ens]->{CTD_W}, |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
572 |
$LADCP{ENSEMBLE}[$ens]->{W}); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
573 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
574 |
print(STDERR "\n"); |
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 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
577 |
#---------------------------------------------------------------------- |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
578 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
579 |
if (defined($opt_b)) { |
3 | 580 |
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
|
581 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
582 |
@antsNewLayout = ('depth','u','v','w','u.sig','v.sig','w.sig','ndata'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
583 |
&antsOut('EOF'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
584 |
$antsCurParams = $commonParams; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
585 |
close(STDOUT); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
586 |
open(STDOUT,">$opt_b") || croak("$opt_b: $!\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
587 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
588 |
my($skipped); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
589 |
for (my($gi)=0; $gi<@BT_nsamp; $gi++) { |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
590 |
$skipped = 1 if ($BT_nsamp[$gi] > 0); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
591 |
next unless ($skipped); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
592 |
&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
|
593 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
594 |
print(STDERR "\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
595 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
596 |
|
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 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
599 |
if (defined($opt_f)) { |
3 | 600 |
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
|
601 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
602 |
@antsNewLayout = ('ens'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
603 |
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
|
604 |
$antsNewLayout[$i] = "bin$i"; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
605 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
606 |
&antsOut('EOF'); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
607 |
$antsCurParams = $commonParams; |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
608 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
609 |
close(STDOUT); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
610 |
open(STDOUT,">$opt_f") || croak("$opt_f: $!\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
611 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
612 |
&antsPrintHeaders(STDOUT,@antsNewLayout); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
613 |
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
|
614 |
printf('%4d ',$LADCP{ENSEMBLE}[$ens]->{NUMBER}); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
615 |
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
|
616 |
printf("%02x ",$edit_flags[$ens][$bin]); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
617 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
618 |
print($opt_R); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
619 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
620 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
621 |
print(STDERR "\n"); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
622 |
} |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
623 |
|
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
624 |
&antsExit(); |
de00d0f32431
initial version to process P403 yoyo
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
diff
changeset
|
625 |