1 #!/usr/bin/perl |
1 #!/usr/bin/perl |
2 #====================================================================== |
2 #====================================================================== |
3 # E D I T P D 0 |
3 # E D I T P D 0 |
4 # doc: Mon Nov 25 20:24:31 2013 |
4 # doc: Mon Nov 25 20:24:31 2013 |
5 # dlm: Tue Nov 15 11:05:46 2016 |
5 # dlm: Thu Jul 27 18:30:16 2017 |
6 # (c) 2013 A.M. Thurnherr |
6 # (c) 2013 A.M. Thurnherr |
7 # uE-Info: 73 76 NIL 0 0 72 2 2 4 NIL ofnI |
7 # uE-Info: 122 0 NIL 0 0 72 2 2 4 NIL ofnI |
8 #====================================================================== |
8 #====================================================================== |
9 |
9 |
10 # edit RDI PD0 file, e.g. to replace pitch/roll/heading with external values |
10 # edit RDI PD0 file, e.g. to replace pitch/roll/heading with external values |
11 |
11 |
12 # NOTES: |
12 # NOTES: |
37 # - does not handle bin-remapping |
37 # - does not handle bin-remapping |
38 # - input in instrument coords required |
38 # - input in instrument coords required |
39 # |
39 # |
40 # ensure_UL() correct data for wrong transducer orientation |
40 # ensure_UL() correct data for wrong transducer orientation |
41 # ensure_DL() - sets correct flag & negates roll value |
41 # ensure_DL() - sets correct flag & negates roll value |
|
42 # |
|
43 # dealias(<WV lim[m/s]>) correct data for erroneously low WV setting |
|
44 # - HEURISTIC, i.e. may not work |
42 # |
45 # |
43 # - -x notes: |
46 # - -x notes: |
44 # - multiple perl expressions can be combined with , |
47 # - multiple perl expressions can be combined with , |
45 # |
48 # |
46 # - Edit File Syntax: |
49 # - Edit File Syntax: |
69 # Jun 8, 2016: - adapted to new interface of velInstrumentToBeam() |
72 # Jun 8, 2016: - adapted to new interface of velInstrumentToBeam() |
70 # - added %-good to beam2earth and earth2beam |
73 # - added %-good to beam2earth and earth2beam |
71 # - made single-ping ensemble requirement for most routines |
74 # - made single-ping ensemble requirement for most routines |
72 # Jul 12, 2016: - updated ensure_{DL,UL} routines |
75 # Jul 12, 2016: - updated ensure_{DL,UL} routines |
73 # Nov 15, 2016: - BUG: ensure_{DL,UL} routines did not negate heading data |
76 # Nov 15, 2016: - BUG: ensure_{DL,UL} routines did not negate heading data |
|
77 # Jul 27, 2017: - began working on dealias() |
74 |
78 |
75 use Getopt::Std; |
79 use Getopt::Std; |
76 |
80 |
77 ($ADCP_TOOLS) = ($0 =~ m{(.*/)[^/]+}); |
81 ($ADCP_TOOLS) = ($0 =~ m{(.*/)[^/]+}); |
78 $ADCP_tools_minVersion = 1.4; |
82 $ADCP_tools_minVersion = 1.4; |
99 |
103 |
100 #-------------------------------------------------- |
104 #-------------------------------------------------- |
101 # Data Editing Library |
105 # Data Editing Library |
102 #-------------------------------------------------- |
106 #-------------------------------------------------- |
103 |
107 |
104 # |
108 #-------------------------------------------------- |
105 # override pitch/roll/heading |
109 # override pitch/roll/heading |
106 # |
110 #-------------------------------------------------- |
|
111 |
107 sub p($) { $dta{ENSEMBLE}[$e]->{PITCH} = $_[0]; return 1; } |
112 sub p($) { $dta{ENSEMBLE}[$e]->{PITCH} = $_[0]; return 1; } |
108 sub r($) { $dta{ENSEMBLE}[$e]->{ROLL} = $_[0]; return 1; } |
113 sub r($) { $dta{ENSEMBLE}[$e]->{ROLL} = $_[0]; return 1; } |
109 sub h($) { $dta{ENSEMBLE}[$e]->{HEADING} = $_[0]; return 1;} |
114 sub h($) { $dta{ENSEMBLE}[$e]->{HEADING} = $_[0]; return 1;} |
110 |
115 |
111 # |
116 #-------------------------------------------------- |
|
117 # correct data for erroneously low WV limit |
|
118 #-------------------------------------------------- |
|
119 |
|
120 { my(@target); # static scope, undef initially |
|
121 |
|
122 sub dealias_V0($) |
|
123 { |
|
124 my($WV) = @_; |
|
125 |
|
126 if (@target) { # dealias everything but first ensemble |
|
127 for (my($bin)=0; $bin<$dta{N_BINS}; $bin++) { |
|
128 for (my($beam)=0; $beam<4; $beam++) { |
|
129 next unless defined($dta{ENSEMBLE}[$e]->{VELOCITY}[$bin][$beam]); |
|
130 my($dealiased) = 0; |
|
131 $dealiased = ($dta{ENSEMBLE}[$e]->{VELOCITY}[$bin][$beam] - 2*$WV) |
|
132 if ($dta{ENSEMBLE}[$e]->{VELOCITY}[$bin][$beam] > 0); |
|
133 $dealiased = ($dta{ENSEMBLE}[$e]->{VELOCITY}[$bin][$beam] + 2*$WV) |
|
134 if ($dta{ENSEMBLE}[$e]->{VELOCITY}[$bin][$beam] < 0); |
|
135 if (abs($target[$beam]-$dta{ENSEMBLE}[$e]->{VELOCITY}[$bin][$beam]) > |
|
136 abs($target[$beam]-$dealiased)) { |
|
137 $dta{ENSEMBLE}[$e]->{VELOCITY}[$bin][$beam] = undef; #$dealiased; |
|
138 $dealiased++; |
|
139 } |
|
140 } |
|
141 } |
|
142 } else { # @target is undef |
|
143 $dealiased = 0; |
|
144 } |
|
145 |
|
146 @target = (0,0,0,0); # calc ref-lr average target for next ens |
|
147 for (my($bin)=1; $bin<=5; $bin++) { # should work even if N_BINS < 5 |
|
148 for (my($beam)=0; $beam<4; $beam++) { |
|
149 $target[$beam] += $dta{ENSEMBLE}[$e]->{VELOCITY}[$bin][$beam]/4 |
|
150 if defined($dta{ENSEMBLE}[$e]->{VELOCITY}[$bin][$beam]); |
|
151 } |
|
152 } |
|
153 |
|
154 return 1; |
|
155 } |
|
156 |
|
157 } # static scope |
|
158 |
|
159 #-------------------------------------------------- |
112 # override transducer orientation |
160 # override transducer orientation |
113 # |
161 # |
114 # These routines are intended to correct ADCP data for |
162 # These routines are intended to correct ADCP data for |
115 # erroneous orientation switch readings, primarily because |
163 # erroneous orientation switch readings, primarily because |
116 # of a stuck switch. |
164 # of a stuck switch. |
123 # compass and pitch/roll only agree with the |
171 # compass and pitch/roll only agree with the |
124 # roll negated. |
172 # roll negated. |
125 # Hdg: Based on the time-series of headings recorded |
173 # Hdg: Based on the time-series of headings recorded |
126 # during P18 profile 003 the heading needs |
174 # during P18 profile 003 the heading needs |
127 # to be negated. Doing so yields a good profile. |
175 # to be negated. Doing so yields a good profile. |
|
176 #-------------------------------------------------- |
128 |
177 |
129 sub ensure_DL() |
178 sub ensure_DL() |
130 { |
179 { |
131 if ($dta{ENSEMBLE}[$e]->{XDUCER_FACING_UP}) { |
180 if ($dta{ENSEMBLE}[$e]->{XDUCER_FACING_UP}) { |
132 $dta{ENSEMBLE}[$e]->{ROLL} *= -1; |
181 $dta{ENSEMBLE}[$e]->{ROLL} *= -1; |