1 #!/usr/bin/perl |
1 #!/usr/bin/perl |
2 #====================================================================== |
2 #====================================================================== |
3 # L I S T E N S |
3 # L I S T E N S |
4 # doc: Sat Jan 18 18:41:49 2003 |
4 # doc: Sat Jan 18 18:41:49 2003 |
5 # dlm: Sun Aug 15 10:29:12 2010 |
5 # dlm: Wed Jan 5 06:09:49 2011 |
6 # (c) 2003 A.M. Thurnherr |
6 # (c) 2003 A.M. Thurnherr |
7 # uE-Info: 34 35 NIL 0 0 72 2 2 4 NIL ofnI |
7 # uE-Info: 191 73 NIL 0 0 72 2 2 4 NIL ofnI |
8 #====================================================================== |
8 #====================================================================== |
9 |
9 |
10 # Print useful info from the ensemble list or dump ensembles to |
10 # Print useful info from the ensemble list or dump ensembles to |
11 # separate files. |
11 # separate files. |
12 |
12 |
30 # - added in-w)ater data only |
30 # - added in-w)ater data only |
31 # - restructured for simplicity |
31 # - restructured for simplicity |
32 # Mar 2, 2009: - added # of valid bin-1 vels to non-ANTS output |
32 # Mar 2, 2009: - added # of valid bin-1 vels to non-ANTS output |
33 # Jul 30, 2009: - NaN => nan |
33 # Jul 30, 2009: - NaN => nan |
34 # Aug 15, 2010: - BUG: usage typo |
34 # Aug 15, 2010: - BUG: usage typo |
|
35 # Dec 10, 2010: - changed ANTS output to time/date instead of UNIX time |
|
36 # Jan 5, 2011: - added -b |
35 |
37 |
36 # Notes: |
38 # Notes: |
37 # - -E outputs data in earth coordinates |
39 # - -E outputs data in earth coordinates, unless -b is set also |
38 # - -E output is always in ANTS format, ignoring -A |
40 # - -E output is always in ANTS format, ignoring -A |
39 # - no soundspeed correction |
41 # - no soundspeed correction |
40 |
42 |
41 require "getopts.pl"; |
43 require "getopts.pl"; |
42 $0 =~ m{(.*/)[^/]+}; |
44 $0 =~ m{(.*/)[^/]+}; |
43 require "$1RDI_BB_Read.pl"; |
45 require "$1RDI_BB_Read.pl"; |
44 require "$1RDI_Coords.pl"; |
46 require "$1RDI_Coords.pl"; |
45 |
47 |
46 die("Usage: $0 [-A)nts] [-Q)uiet (errcheck only)] " . |
48 die("Usage: $0 [-A)nts] [-Q)uiet (errcheck only)] " . |
47 "[-f)ields <[name=]FIELD[,...]>] " . |
49 "[-f)ields <[name=]FIELD[,...]>] " . |
48 "[write -E)nsemples <pref> [-M)agnetic <declination>] [min -p)ercent-good <#>]] " . |
50 "[write -E)nsemples <pref> [-M)agnetic <declination>] [min -p)ercent-good <#>] [keep -b)eam coords]] " . |
49 "[-r)ange <first_ens,last_ens>] [in-w)ater ensembles only] " . |
51 "[-r)ange <first_ens,last_ens>] [in-w)ater ensembles only] " . |
50 "<RDI file...>\n") |
52 "<RDI file...>\n") |
51 unless (&Getopts("AE:f:M:p:Qr:w") && $#ARGV >= 0); |
53 unless (&Getopts("AbE:f:M:p:Qr:w") && $#ARGV >= 0); |
52 |
54 |
53 print(STDERR "WARNING: magnetic declination not set!\n") |
55 print(STDERR "WARNING: magnetic declination not set!\n") |
54 if defined($opt_E) && !defined($opt_M); |
56 if defined($opt_E) && !defined($opt_M); |
55 |
57 |
56 die("$0: illegal option combination\n") |
58 die("$0: illegal option combination\n") |
57 if ($opt_Q && $opt_A) || ((defined($opt_M) || defined($opt_p)) && !defined($opt_E)); |
59 if ($opt_Q && $opt_A) || ((defined($opt_M) || defined($opt_p) || defined($opt_b)) && !defined($opt_E)); |
58 |
60 |
59 ($first_ens,$last_ens) = split(',',$opt_r) |
61 ($first_ens,$last_ens) = split(',',$opt_r) |
60 if defined($opt_r); |
62 if defined($opt_r); |
61 |
63 |
62 undef($opt_A) if defined($opt_E); |
64 undef($opt_A) if defined($opt_E); |
98 if ($dta{BEAM_COORDINATES}) { # coords used |
100 if ($dta{BEAM_COORDINATES}) { # coords used |
99 $beamCoords = 1; |
101 $beamCoords = 1; |
100 } elsif (!$dta{EARTH_COORDINATES}) { |
102 } elsif (!$dta{EARTH_COORDINATES}) { |
101 die("$ARGV[0]: only beam and earth coordinates implemented so far\n"); |
103 die("$ARGV[0]: only beam and earth coordinates implemented so far\n"); |
102 } |
104 } |
|
105 |
|
106 die("$ARGV[0]: -b only makes sense for beam-coordinate data\n") |
|
107 if ($opt_b && !$beamCoords); |
103 |
108 |
104 if ($opt_A) { # select output fmt: ANTS |
109 if ($opt_A) { # select output fmt: ANTS |
105 unless ($opt_Q) { |
110 unless ($opt_Q) { |
106 printf("#ANTS#PARAMS# N_ensembles{%d}\n",scalar(@{$dta{ENSEMBLE}})); |
111 printf("#ANTS#PARAMS# N_ensembles{%d}\n",scalar(@{$dta{ENSEMBLE}})); |
107 print('#ANTS#FIELDS# {ens} {time} {xducer_up} {temp} {hdg} {pitch} {roll} {XMIT_VOLTAGE} {XMIT_CURRENT}'); |
112 print('#ANTS#FIELDS# {ens} {time} {xducer_up} {temp} {hdg} {pitch} {roll} {XMIT_VOLTAGE} {XMIT_CURRENT}'); |
181 if ($dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][1] < $opt_p); |
186 if ($dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][1] < $opt_p); |
182 undef($dta{ENSEMBLE}[$e]->{VELOCITY}[$b][2]) |
187 undef($dta{ENSEMBLE}[$e]->{VELOCITY}[$b][2]) |
183 if ($dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][2] < $opt_p); |
188 if ($dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][2] < $opt_p); |
184 undef($dta{ENSEMBLE}[$e]->{VELOCITY}[$b][3]) |
189 undef($dta{ENSEMBLE}[$e]->{VELOCITY}[$b][3]) |
185 if ($dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][3] < $opt_p); |
190 if ($dta{ENSEMBLE}[$e]->{PERCENT_GOOD}[$b][3] < $opt_p); |
186 @v = velInstrumentToEarth(\%dta,$e, |
191 @v = $opt_b ? @{$dta{ENSEMBLE}[$e]->{VELOCITY}[$b]} : |
187 velBeamToInstrument(\%dta, |
192 velInstrumentToEarth(\%dta,$e, |
188 @{$dta{ENSEMBLE}[$e]->{VELOCITY}[$b]})); |
193 velBeamToInstrument(\%dta, |
|
194 @{$dta{ENSEMBLE}[$e]->{VELOCITY}[$b]})); |
189 } else { |
195 } else { |
190 @v = velApplyHdgBias(\%dta,$e,@{$dta{ENSEMBLE}[$e]->{VELOCITY}[$b]}); |
196 @v = velApplyHdgBias(\%dta,$e,@{$dta{ENSEMBLE}[$e]->{VELOCITY}[$b]}); |
191 } |
197 } |
192 |
198 |
193 $v[0] = nan unless defined($v[0]); |
199 $v[0] = nan unless defined($v[0]); |