author | Andreas Thurnherr <ant@ldeo.columbia.edu> |
Sun, 12 Apr 2020 20:03:22 -0400 | |
changeset 51 | 148c092b3a09 |
parent 50 | 6bfec705d25e |
child 52 | 5b07a9b89aee |
permissions | -rw-r--r-- |
14 | 1 |
#====================================================================== |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
2 |
# R D I _ P D 0 _ I O . P L |
14 | 3 |
# doc: Sat Jan 18 14:54:43 2003 |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
4 |
# dlm: Sun Apr 12 20:02:30 2020 |
14 | 5 |
# (c) 2003 A.M. Thurnherr |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
6 |
# uE-Info: 123 72 NIL 0 0 72 0 2 4 NIL ofnI |
14 | 7 |
#====================================================================== |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
8 |
|
37 | 9 |
# Read RDI PD0 binary data files (*.[0-9][0-9][0-9]) |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
10 |
|
14 | 11 |
# HISTORY: |
12 |
# Jan 18, 2003: - incepted aboard the Aurora Australis (KAOS) |
|
13 |
# Jan 19, 2003: - continued |
|
14 |
# Jan 20, 2003: - replaced INTENSITY by AMPLITUDE |
|
15 |
# Jan 21, 2003: - changed heading-correction field names |
|
16 |
# Jan 27, 2003: - cosmetics |
|
17 |
# Feb 14, 2003: - moved BT setup into header |
|
18 |
# Mar 15, 2003: - moved 10th xmit voltage into header as BATTERY field |
|
19 |
# - removed again, because values are not meaningful |
|
20 |
# Feb 24, 2004: - continued aboard Nathaniel B. Palmer (Anslope II) |
|
21 |
# - BUG: ensemble # was wrong on error messages |
|
22 |
# Feb 26, 2004: - removed ESW_ERROR and bitmasking of ERROR_STATUS_WORD |
|
23 |
# Feb 27, 2004: - removed some unused (commented-out) baggage |
|
24 |
# Mar 11, 2004: - BUG: renamed ACD -> ADC |
|
25 |
# Mar 18, 2004: - cosmetics |
|
26 |
# Mar 30, 2004: - rewrote to speed up reading; new version takes |
|
27 |
# ~40% less time |
|
28 |
# Sep 14, 2005: - made BT data optional (NUMBER_OF_DATA_TYPES) |
|
29 |
# - added DATA_FORMAT |
|
30 |
# Sep 15, 2005: - debugged |
|
31 |
# - implement checksum to robustly find EOF |
|
32 |
# - renamed to RDI_BB_Read.pl |
|
33 |
# - BUG: had used POSIX::mktime with wrong month def! |
|
34 |
# Oct 30, 2005: - added WH300 FW16.27 file format |
|
35 |
# - added DATA_FORMAT_VARIANT |
|
36 |
# - changed semantics so that first valid ensemble is |
|
39 | 37 |
# in E[0] (instead of E[$ensNo-1]) |
14 | 38 |
# Nov 8, 2005: - replaced UNIXTIME by UNIX_TIME |
39 |
# - added SECNO |
|
40 |
# Aug 31: 2006: - added DAYNO |
|
41 |
# Aug 1, 2007: - BUG: typo in monthLength() |
|
42 |
# Sep 18, 2007: - modified readHeader() readDta() WBRhdr() WBRens() to |
|
43 |
# conserve memory (no large arrays as retvals) |
|
44 |
# Jun 4, 2008: - BUG: BB150 code was not considered on Sep 18, 2007 |
|
45 |
# Aug 15, 2010: - downgraded "unexpected number of data types" from error to warning |
|
46 |
# - BUG: WBRcfn had not been set correctly |
|
47 |
# - modified to allow processing files without time info |
|
48 |
# May 12, 2011: - added code to report built-in-test errors |
|
49 |
# Mar 19, 2013: - added support for WH600 data file (58 fixed leader bytes) |
|
50 |
# Mar 20, 2013: - removed DATA_FORMAT stuff |
|
51 |
# - added support for BT data in subset of ensembles |
|
52 |
# Apr 29, 2013: - changed semantics to assume EOF when unexpected number of data types |
|
53 |
# are present in an ensemble |
|
54 |
# Nov 25, 2013: - renamed from [RDI_BB_Read.pl] |
|
55 |
# - begin implementing WBWens() |
|
56 |
# - checkEnsemble() expunged |
|
18 | 57 |
# Mar 3, 2014: - BUG: WBPens() did not handle incomple ensembles at EOF correctly |
58 |
# Mar 4, 2014: - added support for DATA_SOURCE_ID |
|
59 |
# Apr 24, 2014: - added debug statements to log %-GOOD values |
|
60 |
# May 6, 2014: - loosened input format checks |
|
48
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
61 |
# May 7, 2014: - removed BT_PRESENT flag |
21 | 62 |
# Sep 6, 2014: - adapted WBRhdr to >7 data types |
63 |
# Oct 15, 2014: - implemented work-around for readData() not recognizing |
|
64 |
# incomplete ensemble at the end, which seems to imply that there is |
|
39 | 65 |
# a garbage final ensemble that passes the checksum test??? |
26
02776c168135
made RDI_BB_IO work with files containing leading garbage
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
24
diff
changeset
|
66 |
# Oct 2, 2015: - added &skip_initial_trash() |
28 | 67 |
# Dec 18, 2015: - added most data types to WBPofs() |
68 |
# - BUG: WBPens() requires round() for scaled values |
|
31 | 69 |
# Jan 9, 2016: - removed system() from writeData() |
70 |
# - BUG: WBRhdr() did not set DATA_SOURCE_ID |
|
29 | 71 |
# - added PRODUCER |
31 | 72 |
# - BUG: writeData() did not work correctly for ECOGIG OC26 moored data (spaces in filename?) |
73 |
# - added support for patching coordinate system |
|
32 | 74 |
# Feb 16, 2016: - added transducer orientation to WBPens() |
75 |
# - BUG: most WBPens() error messages used wrong file name |
|
76 |
# Feb 23, 2016: - changed WBRhdr() to use 2nd ensemble (with correct data-source id) |
|
77 |
# Feb 26, 2016: - added basic BT data to WBPens(); not BT_RL_* and BT_SIGNAL_STRENGTH |
|
36
515b06dae59c
version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
32
diff
changeset
|
78 |
# Feb 29, 2016: - LEAP DAY: actually got BT data patching to work |
515b06dae59c
version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
32
diff
changeset
|
79 |
# Jul 30, 2016: - BUG: incomplete last ensemble with garbage content was returned on reading |
515b06dae59c
version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
32
diff
changeset
|
80 |
# WH300 data |
37 | 81 |
# Aug 5, 2016: - cosmetics |
82 |
# Aug 23, 2016: - added &clearEns() |
|
83 |
# Nov 9, 2016: - made WBRhdr() return undef on "empty" files |
|
84 |
# Nov 18, 2016: - BUG: ensNo was not reported correctly in format errors |
|
85 |
# Nov 23, 2016: - no longer set pitch/roll/heading to undef in clearEns() |
|
86 |
# Mar 7, 2016: - renamed round() to stop clashing with ANTSLIB |
|
39 | 87 |
# May 18, 2017: - maded readHeader() more permissive (checkFmt flag) |
88 |
# - added partial support for Ocean Surveyor data |
|
89 |
# Aug 1, 2017: BUG: minor typo in ocean surveyor code (err check not done?) |
|
90 |
# Aug 7, 2017: - added LAG_LENGTH |
|
91 |
# - added SPEED_OF_SOUND to header |
|
92 |
# Aug 8, 2017: - replaced croak() by die() |
|
93 |
# - added actual transducer frequencies |
|
40
6a46e9d31106
after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
39
diff
changeset
|
94 |
# Nov 22, 2017: - BUG: dayNo() and monthLength() clashed with [libconv.pl] |
42 | 95 |
# - added support for RDI_PD0_IO::IGNORE_Y2K_CLOCK |
96 |
# Dec 7, 2017: - added suppress_error to readHeader() |
|
97 |
# Dec 23, 2017: - BUG: could no longer read Anslope II raw files |
|
98 |
# - added support for patching ADCP time data |
|
99 |
# - added support for RDI_PD0_IO::OVERRIDE_Y2K_CLOCK |
|
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
100 |
# Feb 6, 2018: - added supprort for first_ens, last_ens in readData() |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
101 |
# Feb 7, 2018: - BUG: new params were not optional |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
102 |
# - made read routines more permissive by allowing |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
103 |
# garbage between ensembles |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
104 |
# Mar 15, 2018: - BUG: WBPens() did not work for files with garbage |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
105 |
# Mar 16, 2018: - added skipped garbage warning |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
106 |
# - BUG: garbage skipping did not work correctly for files w/o BT |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
107 |
# Mar 20, 2018: - BUG: garbage skipping STILL did not work correctly for files w/o BT |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
108 |
# Apr 9, 2018: - added last_bin argument to readData() |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
109 |
# Apr 10, 2018: - slight improvement (parameter range check) |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
110 |
# Apr 23, 2018: - make WBRens() work (again?) with BB150 data froim 1996 |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
111 |
# Apr 24, 2018: - BUG: undefined lat_bin argument to readData() did not work |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
112 |
# Apr 30, 2018: - added support for repeated ensembles |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
113 |
# - added warning on wrong ensemble length |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
114 |
# Jun 9, 2018: - removed double \n from warnings |
48
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
115 |
# Jun 12, 2018: - BUG: IMPed files did not pass the garbage detection |
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
116 |
# Jun 13, 2019: - adapted reading routines to RTI files (free order of data types) |
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
117 |
# - removed old BT_PRESENT code |
50 | 118 |
# Jun 28, 2019: - renamed SECONDS to SECOND for consistency |
119 |
# Jun 30, 2019: - added dirty flag to prevent bad PD0 patching |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
120 |
# - added $show_progress |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
121 |
# Feb 13, 2020: - added support for $readDataProgress (to Jun 13 version) |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
122 |
# Apr 12, 2020: - merged laptop and whoosher versions which both implemented |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
123 |
# progreass; not sure whether this merge is successful |
39 | 124 |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
125 |
|
14 | 126 |
# FIRMWARE VERSIONS: |
127 |
# It appears that different firmware versions generate different file |
|
128 |
# structures. Currently (Sep 2005) these routines have been tested |
|
129 |
# with the following firmware versions (as reported by [listHdr]): |
|
130 |
# |
|
39 | 131 |
# Firmw. DATA_FORMAT(_VARIANT) Owner Cruise FIXED_LEADER_LENGTH |
14 | 132 |
#------------------------------------------------------------ |
39 | 133 |
# 05.52 BB150 (1) UH CLIVAR/P16S 42 |
14 | 134 |
# 16.12 WH300 (1) FSU A0304 53 |
39 | 135 |
# 16.21 WH300 (1) LDEO NBP0402 53 |
136 |
# 16.27 WH300 (2) Nash ? 59 |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
137 |
|
29 | 138 |
# PD0 FILE FORMAT EXTENSIONS: |
139 |
# |
|
32 | 140 |
# - file creator encoded in DATA_SOURCE_ID |
141 |
# |
|
142 |
# - first ensemble uses default RDI DATA_SOURCE_ID because the LDEO_IX |
|
143 |
# software assumes this |
|
144 |
# |
|
39 | 145 |
# - DATA_SOURCE_ID = 0x7F original TRDI PD0 file |
29 | 146 |
# |
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
147 |
# - DATA_SOURCE_ID = 0xA0 | PATCHED_MASK produced by IMP+LADCP, KVH+LADCP |
29 | 148 |
# PATCHED_MASK & 0x04: pitch value has been patched |
149 |
# PATCHED_MASK & 0x02: roll value has been patched |
|
150 |
# PATCHED_MASK & 0x01: heading value has been patched |
|
151 |
# - PITCH & ROLL can be missing (0x8000 badval as in velocities) |
|
152 |
# - HEADING can be missing (0xF000 badval, as 0x8000 is valid 327.68 heading) |
|
153 |
# |
|
31 | 154 |
# - DATA_SOURCE_ID = 0xE0 produced by editPD0 |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
155 |
|
14 | 156 |
# NOTES: |
157 |
# - RDI stores data in VAX/Intel byte order (little endian) |
|
158 |
# - the output data structure does not exactly mirror the file data |
|
159 |
# structure; the header is not stored at all and the fixed leader |
|
160 |
# data are not duplicated in every ensemble |
|
161 |
# - in the RDI files some fields that logically belong into the header |
|
162 |
# or the fixed leader (e.g. BT_MIN_CORRELATION) appear in the |
|
163 |
# ensemble data --- these are not read on input |
|
164 |
# - the field names are generally unabbreviated except for |
|
165 |
# BT (= Bottom Track), RL (= Reference Layer), MIN and MAX |
|
166 |
# - all arrays are 0-referenced, but the ensemble number is not! |
|
167 |
# - a list of filenames can be be passed to readData() so that |
|
168 |
# files split onto several memory cards (typically .000 .001 &c) |
|
169 |
# can be read --- not sure if this works, actually |
|
170 |
# - the RDI manuals are not entirely clear everywhere; I have made |
|
171 |
# guesses in some cases, but they should not affect the main |
|
172 |
# fields of interest |
|
173 |
# - some fields in the fixed leader are not really fixed in a LADCP |
|
174 |
# setting (e.g. xducer orientation); I'v made an educated guess |
|
175 |
# as to which fields to move to the ENS array |
|
176 |
# - all units except pressure are SI, i.e. in m and m/s |
|
177 |
# - I don't understand the ERROR_STATUS_WORD; here's what 3 different |
|
178 |
# instruments returned: |
|
39 | 179 |
# 0x88000100 FSU instrument during A0304 (Firmware 16.12) |
14 | 180 |
# 0x88008180 LDEO uplooker (slave) during NBP0402 (Firmware 16.21) |
181 |
# 0x00008180 LDEO downlooker (master) during NBP0402 (Firmware 16.21) |
|
182 |
# According to the manual (January 2001 version) this would, for example, |
|
183 |
# indicate power failures on both FSU and LDEO slave instruments... |
|
40
6a46e9d31106
after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
39
diff
changeset
|
184 |
# - defining the variable "$RDI_PD0_IO::IGNORE_Y2K_CLOCK" before calling &readData() |
6a46e9d31106
after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
39
diff
changeset
|
185 |
# makes the code ignore the Y2K clock and use the old clock instead; this |
6a46e9d31106
after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
39
diff
changeset
|
186 |
# is used for Dan Torres' KVH system |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
187 |
|
14 | 188 |
# &readData() returns perl obj (ref to anonymous hash) with the following |
189 |
# structure: |
|
190 |
# |
|
18 | 191 |
# DATA_SOURCE_ID scalar 0x7f (Workhorse, also DVL) |
14 | 192 |
# NUMBER_OF_DATA_TYPES scalar 6 (no BT) or 7 |
193 |
# ENSEMBLE_BYTES scalar ?, number of bytes w/o checksum |
|
194 |
# HEADER_BYTES scalar ? |
|
195 |
# FIXED_LEADER_BYTES scalar 42 for BB150; 53 for WH300, 58 for WH600, 59 for WH300(Nash) |
|
196 |
# VARIABLE_LEADER_BYTES scalar ? |
|
39 | 197 |
# VELOCITY_DATA_BYTES scalar ? |
14 | 198 |
# CORRELATION_DATA_BYTES scalar ? |
199 |
# ECHO_INTENSITY_DATA_BYTES scalar ? |
|
39 | 200 |
# PERCENT_GOOD_DATA_BYTES scalar ? |
14 | 201 |
# CPU_FW_VER scalar 0--255 |
202 |
# CPU_FW_REV scalar 0--255 |
|
203 |
# BEAM_FREQUENCY scalar 75, 150, 300, 600, 1200, 2400 [kHz] |
|
39 | 204 |
# LAG_LENGTH scalar ??? |
205 |
# CONVEX_BEAM_PATTERN bool undefined, 1 |
|
14 | 206 |
# CONCAVE_BEAM_PATTERN bool undefined, 1 |
207 |
# SENSOR_CONFIG scalar 1--3 |
|
208 |
# XDUCER_HEAD_ATTACHED bool undefined, 1 |
|
209 |
# BEAM_ANGLE scalar 15,20,30,undefined=other [deg] |
|
39 | 210 |
# N_BEAMS scalar 4--5 |
14 | 211 |
# N_DEMODS scalar 2--3(???),undefined=n/a |
212 |
# N_BINS scalar 1--128 |
|
213 |
# PINGS_PER_ENSEMBLE scalar 0--16384 |
|
214 |
# BIN_LENGTH scalar 0.01--64 [m] |
|
215 |
# BLANKING_DISTANCE scalar 0-99.99 [m] |
|
39 | 216 |
# MIN_CORRELATION scalar 0--255 |
14 | 217 |
# N_CODE_REPETITIONS scalar 0--255 |
218 |
# MIN_PERCENT_GOOD scalar 1--100 [%] |
|
219 |
# MAX_ERROR_VELOCITY scalar 0--5 [m/s] |
|
220 |
# TIME_BETWEEN_PINGS scalar 0--? [s] |
|
221 |
# BEAM_COORDINATES bool undefined,1 |
|
222 |
# INSTRUMENT_COORDINATES bool undefined,1 |
|
223 |
# SHIP_COORDINATES bool undefined,1 |
|
224 |
# EARTH_COORDINATES bool undefined,1 |
|
39 | 225 |
# PITCH_AND_ROLL_USED bool undefined,1 |
14 | 226 |
# USE_3_BEAM_ON_LOW_CORR bool undefined,1 |
39 | 227 |
# BIN_MAPPING_ALLOWED bool undefined,1 |
228 |
# HEADING_ALIGNMENT scalar -179.99..180 [deg] |
|
229 |
# HEADING_BIAS scalar -179.99..180 [deg] |
|
14 | 230 |
# CALCULATE_SPEED_OF_SOUND bool undefined,1 |
39 | 231 |
# USE_PRESSURE_SENSOR bool undefined,1 |
232 |
# USE_COMPASS bool undefined,1 |
|
14 | 233 |
# USE_PITCH_SENSOR bool undefined,1 |
39 | 234 |
# USE_ROLL_SENSOR bool undefined,1 |
235 |
# USE_CONDUCTIVITY_SENSOR bool undefined,1 |
|
14 | 236 |
# USE_TEMPERATURE_SENSOR bool undefined,1 |
237 |
# SPEED_OF_SOUND_CALCULATED bool undefined,1 |
|
238 |
# PRESSURE_SENSOR_AVAILABLE bool undefined,1 |
|
239 |
# COMPASS_AVAILABLE bool undefined,1 |
|
240 |
# PITCH_SENSOR_AVAILABLE bool undefined,1 |
|
241 |
# ROLL_SENSOR_AVAILABLE bool undefined,1 |
|
242 |
# CONDUCTIVITY_SENSOR_AVAILABLE bool undefined,1 |
|
243 |
# TEMPERATURE_SENSOR_AVAILABLE bool undefined,1 |
|
39 | 244 |
# DISTANCE_TO_BIN1_CENTER scalar 0--655.35 [m] |
14 | 245 |
# TRANSMITTED_PULSE_LENGTH scalar 0--655.35 [m] |
246 |
# RL_FIRST_BIN scalar 1--128 |
|
39 | 247 |
# RL_LAST_BIN scalar 1--128 |
14 | 248 |
# FALSE_TARGET_THRESHOLD scalar 0--254, undefined=disabled |
39 | 249 |
# LOW_LATENCY_SETTING scalar 0--5(???) |
14 | 250 |
# TRANSMIT_LAG_DISTANCE scalar 0--655.35 [m] |
251 |
# CPU_SERIAL_NUMBER scalar undefined, 0--65535 if WH300 |
|
252 |
# NARROW_BANDWIDTH bool undefined,1 (only set if WH300) |
|
253 |
# WIDE_BANDWIDTH bool undefined,1 (only set if WH300) |
|
254 |
# TRANSMIT_POWER scalar undefined, 0--255(high) if WH300 |
|
39 | 255 |
# TRANSMIT_POWER_HIGH bool undefined,1 (only set if WH300) |
14 | 256 |
# BT_PINGS_PER_ENSEMBLE scalar 0--999 |
257 |
# BT_DELAY_BEFORE_REACQUIRE scalar 0--999 |
|
258 |
# BT_MIN_CORRELATION scalar 0--255 |
|
259 |
# BT_MIN_EVAL_AMPLITUDE scalar 0--255 |
|
39 | 260 |
# BT_MIN_PERCENT_GOOD scalar 0--100 [%] |
261 |
# BT_MODE scalar 4,5,6(?) |
|
14 | 262 |
# BT_MAX_ERROR_VELOCITY scalar 0--5 [m/s], undef=not screened |
263 |
# BT_RL_MIN_SIZE scalar 0--99.9 [m] |
|
264 |
# BT_RL_NEAR scalar 0--999.9 [m] |
|
265 |
# BT_RL_FAR scalar 0--999.9 [m] |
|
266 |
# BT_MAX_TRACKING_DEPTH scalar 8--999.9 [m] |
|
39 | 267 |
# ENSEMBLE[ensemble_no-1] array ensemble info |
14 | 268 |
# XDUCER_FACING_UP bool undefined, 1 |
269 |
# XDUCER_FACING_DOWN bool undefined, 1 |
|
270 |
# N_BEAMS_USED scalar 3,4,5(?) |
|
271 |
# NUMBER scalar 1--16777215 |
|
39 | 272 |
# BUILT_IN_TEST_ERROR scalar ?,undefined=none |
14 | 273 |
# SPEED_OF_SOUND scalar 1400--1600 [m/s] |
274 |
# XDUCER_DEPTH scalar 0.1--999.9 [m] |
|
39 | 275 |
# HEADING scalar 0--359.99 [deg] --- IMP EXTENSION: undef |
18 | 276 |
# PITCH scalar -20.00-20.00 [deg] --- IMP EXTENSION: undef |
277 |
# ROLL scalar -20.00-20.00 [deg] --- IMP EXTENSION: undef |
|
14 | 278 |
# SALINITY scalar 0-40 [psu] |
39 | 279 |
# TEMPERATURE scalar -5.00--40.00 [deg] |
14 | 280 |
# MIN_PRE_PING_WAIT_TIME scalar ? [s] |
281 |
# HEADING_STDDEV scalar 0-180 [deg] |
|
282 |
# PITCH_STDDEV scalar 0.0-20.0 [deg] |
|
39 | 283 |
# ROLL_STDDEV scalar 0.0-20.0 [deg] |
14 | 284 |
# ADC_XMIT_CURRENT scalar 0--255 |
285 |
# ADC_XMIT_VOLTAGE scalar 0--255 |
|
39 | 286 |
# ADC_AMBIENT_TEMPERATURE scalar 0--255 |
14 | 287 |
# ADC_PRESSURE_PLUS scalar 0--255 |
288 |
# ADC_PRESSURE_MINUS scalar 0--255 |
|
289 |
# ADC_ATTITUDE_TEMPERATURE scalar 0--255 |
|
290 |
# ADC_ATTITUDE scalar 0--255 |
|
291 |
# ADC_CONTAMINATION scalar 0--255 |
|
292 |
# ERROR_STATUS_WORD scalar undefined, ? (only set if WH300) |
|
293 |
# PRESSURE scalar undefined, ?-? [dbar] (only set if WH300) |
|
39 | 294 |
# PRESSURE_STDDEV scalar undefined, ?-? [dbar] (only set if WH300) |
14 | 295 |
# DATE string MM/DD/YYYY |
296 |
# YEAR scalar ? |
|
297 |
# MONTH scalar 1--12 |
|
39 | 298 |
# DAY scalar 1--31 |
14 | 299 |
# TIME string HH:MM:SS.hh |
300 |
# HOUR scalar 0--23 |
|
301 |
# MINUTE scalar 0--59 |
|
50 | 302 |
# SECOND scalar 0--59.99 |
14 | 303 |
# UNIX_TIME scalar 0--? |
304 |
# SECNO scalar 0--? (number of seconds since daystart) |
|
305 |
# DAYNO double fractional day number since start of current year (1.0 is midnight Jan 1st) |
|
39 | 306 |
# VELOCITY[bin][beam] scalars -32.767--32.768 [m/s], undef=bad |
307 |
# CORRELATION[bin][beam] scalars 1--255, undefined=bad |
|
308 |
# ECHO_AMPLITUDE[bin][beam] scalars 0--255 |
|
309 |
# PERCENT_GOOD[bin][beam] scalars 0--255 |
|
310 |
# BT_RANGE[beam] scalars tons [m] |
|
311 |
# BT_VELOCITY[beam] scalars see VELOCITY |
|
312 |
# BT_CORRELATION[beam] scalars see CORRELATION |
|
313 |
# BT_EVAL_AMPLITUDE[beam] scalars 0--255 |
|
314 |
# BT_PERCENT_GOOD[beam] scalars see PERCENT_GOOD |
|
315 |
# BT_RL_VELOCITY[beam] scalars see VELOCITY |
|
316 |
# BT_RL_CORRELATION[beam] scalars see CORRELATION |
|
317 |
# BT_RL_ECHO_AMPLITUDE[beam] scalars see ECHO_AMPLITUDE |
|
318 |
# BT_RL_PERCENT_GOOD[beam] scalars see PERCENT_GOOD |
|
319 |
# BT_SIGNAL_STRENGTH[beam] scalars 0--255 |
|
14 | 320 |
# HIGH_GAIN bool 1, undefined |
321 |
# LOW_GAIN bool 1, undefined |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
322 |
|
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
323 |
use strict; |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
324 |
use Time::Local; # timegm() |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
325 |
|
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
326 |
$RDI_PD0_IO::show_progress = 0; # when set, print . every 1000 ens read |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
327 |
|
14 | 328 |
#---------------------------------------------------------------------- |
329 |
# Time Conversion Subroutines |
|
40
6a46e9d31106
after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
39
diff
changeset
|
330 |
# - prepended with _ to avoid conflicts with [libconv.pl] |
14 | 331 |
#---------------------------------------------------------------------- |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
332 |
|
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
333 |
sub _monthLength($$) # of days in month |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
334 |
{ |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
335 |
my($Y,$M) = @_; |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
336 |
|
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
337 |
return 31 if ($M==1 || $M==3 || $M==5 || $M==7 || |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
338 |
$M==8 || $M==10 || $M==12); |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
339 |
return 30 if ($M==4 || $M==6 || $M==9 || $M==11); |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
340 |
return 28 if ($Y%4 != 0); |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
341 |
return 29 if ($Y%100 != 0); |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
342 |
return 28 if ($Y%400 > 0); |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
343 |
return 29; |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
344 |
} |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
345 |
|
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
346 |
{ my($epoch,$lM,$lD,$lY,$ldn); # static scope |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
347 |
|
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
348 |
sub _dayNo($$$$$$) |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
349 |
{ |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
350 |
my($Y,$M,$D,$h,$m,$s) = @_; |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
351 |
my($dn); |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
352 |
|
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
353 |
if ($Y==$lY && $M==$lM && $D==$lD) { # same day as last samp |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
354 |
$dn = $ldn; |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
355 |
} else { # new day |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
356 |
$epoch = $Y unless defined($epoch); # 1st call |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
357 |
$lY = $Y; $lM = $M; $lD = $D; # store |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
358 |
|
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
359 |
for ($dn=0,my($cY)=$epoch; $cY<$Y; $cY++) { # multiple years |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
360 |
$dn += 337 + &_monthLength($Y,$M); |
14 | 361 |
} |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
362 |
|
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
363 |
$dn += $D; # day in month |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
364 |
while (--$M > 0) { # preceding months |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
365 |
$dn += &_monthLength($Y,$M); |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
366 |
} |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
367 |
|
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
368 |
$ldn = $dn; # store |
14 | 369 |
} |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
370 |
return $dn + $h/24 + $m/24/60 + $s/24/3600; |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
371 |
} |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
372 |
|
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
373 |
} # static scope |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
374 |
|
14 | 375 |
#---------------------------------------------------------------------- |
376 |
# Read Data |
|
377 |
#---------------------------------------------------------------------- |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
378 |
|
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
379 |
my($WBRcfn,$WBPcfn); # current file names for reading/patching |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
380 |
my($BIT_errors) = 0; # built-in-test errors |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
381 |
|
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
382 |
my($FmtErr) = "%s: illegal %s Id 0x%04x at ensemble %d"; |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
383 |
|
14 | 384 |
#---------------------------------------------------------------------- |
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
385 |
# skip to next valid start of ensemble (skip over garbage) |
26
02776c168135
made RDI_BB_IO work with files containing leading garbage
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
24
diff
changeset
|
386 |
#---------------------------------------------------------------------- |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
387 |
|
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
388 |
sub goto_next_ens(@) |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
389 |
{ |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
390 |
my($fh,$return_skipped) = @_; # if return_skipped not set, return file pos |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
391 |
my($buf,$dta); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
392 |
|
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
393 |
my($found) = 0; # zero consecutive 0x7f found |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
394 |
my($skipped) = 0; my($garbage_start); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
395 |
while ($found < 2) { |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
396 |
sysread($fh,$buf,1) == 1 || last; |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
397 |
($dta) = unpack('C',$buf); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
398 |
if ($dta == 0x7f) { |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
399 |
$found++; |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
400 |
} elsif ($found==1 && |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
401 |
($dta==0xE0 || # from editPD0 |
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
402 |
(($dta&0xF0)==0xA0 && ($dta&0x0F)<8))) { # from IMP+LADCP or KVH+LADCP |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
403 |
$found++; |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
404 |
} elsif ($found == 0) { |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
405 |
$garbage_start = sysseek($fh,0,1)-1 unless defined($garbage_start); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
406 |
$skipped++; |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
407 |
} else { # here, found == 1 but 2nd byte was not found |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
408 |
$garbage_start = sysseek($fh,0,1)-$found unless defined($garbage_start); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
409 |
$skipped += $found; |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
410 |
$found = 0; |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
411 |
} |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
412 |
} |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
413 |
my($fpos) = ($found < 2) ? undef : sysseek($fh,-2,1); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
414 |
return $skipped if ($return_skipped); |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
415 |
|
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
416 |
if ($skipped) { |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
417 |
if (eof($fh)) { |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
418 |
# 04/18/18: disabled the following line of code because it is very common at |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
419 |
# least with the older RDI instruments I am looking at in the context |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
420 |
# of the SR1b repeat section analysis |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
421 |
# print(STDERR "WARNING (RDI_PD0_IO): PD0 file ends with $skipped garbage bytes\n"); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
422 |
} elsif ($garbage_start == 0) { |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
423 |
print(STDERR "WARNING (RDI_PD0_IO): PD0 file starts with $skipped garbage bytes\n"); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
424 |
} else { |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
425 |
print(STDERR "WARNING (RDI_PD0_IO): $skipped garbage bytes in PD0 file beginning at byte $garbage_start\n"); |
26
02776c168135
made RDI_BB_IO work with files containing leading garbage
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
24
diff
changeset
|
426 |
} |
02776c168135
made RDI_BB_IO work with files containing leading garbage
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
24
diff
changeset
|
427 |
} |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
428 |
|
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
429 |
return $fpos; |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
430 |
} |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
431 |
|
26
02776c168135
made RDI_BB_IO work with files containing leading garbage
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
24
diff
changeset
|
432 |
#---------------------------------------------------------------------- |
14 | 433 |
# readHeader(file_name,^dta) WBRhdr(^data) |
434 |
# - read header data |
|
435 |
# - also includes some data from 1st ens |
|
436 |
#---------------------------------------------------------------------- |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
437 |
|
14 | 438 |
sub readHeader(@) |
439 |
{ |
|
42 | 440 |
my($fn,$dta,$suppress_error) = @_; |
14 | 441 |
$WBRcfn = $fn; |
39 | 442 |
open(WBRF,$WBRcfn) || die("$WBRcfn: $!"); |
42 | 443 |
if (WBRhdr($dta)) { |
444 |
return 1; |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
445 |
} elsif ($suppress_error) { |
42 | 446 |
return undef; |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
447 |
} else { |
42 | 448 |
die("$WBRcfn: Insufficient data\n"); |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
449 |
} |
14 | 450 |
} |
451 |
||
48
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
452 |
sub WBRhdr($) |
14 | 453 |
{ |
48
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
454 |
my($dta) = @_; |
26
02776c168135
made RDI_BB_IO work with files containing leading garbage
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
24
diff
changeset
|
455 |
my($start_ens,$buf,$hid,$did,$Ndt,$B,$W,$i,$dummy,$id,@WBRofs); |
14 | 456 |
my($B1,$B2,$B3,$B4,$B5,$B6,$B7,$W1,$W2,$W3,$W4,$W5); |
39 | 457 |
my($BT_dt); |
458 |
||
14 | 459 |
#-------------------- |
460 |
# HEADER |
|
461 |
#-------------------- |
|
462 |
||
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
463 |
my($skipped) = goto_next_ens(\*WBRF,1); |
50 | 464 |
if ($skipped > 0) { |
465 |
$RDI_PD0_IO::File_Dirty = 1; |
|
466 |
printf(STDERR "WARNING: %d bytes of initial garbage\n",$skipped); |
|
467 |
} |
|
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
468 |
|
37 | 469 |
sysread(WBRF,$buf,6) == 6 || return undef; |
32 | 470 |
($hid,$did,$dta->{ENSEMBLE_BYTES},$dummy,$dta->{NUMBER_OF_DATA_TYPES}) |
471 |
= unpack('CCvCC',$buf); |
|
36
515b06dae59c
version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
32
diff
changeset
|
472 |
$hid == 0x7f || die(sprintf($FmtErr,$WBRcfn,"Header (hid)",$hid,0)); |
515b06dae59c
version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
32
diff
changeset
|
473 |
$did == 0x7f || die(sprintf($FmtErr,$WBRcfn,"Header (did)",$did,0)); |
32 | 474 |
|
37 | 475 |
$start_ens = sysseek(WBRF,$dta->{ENSEMBLE_BYTES}-6+2,1) || return undef; |
476 |
sysread(WBRF,$buf,6) == 6 || return undef; |
|
14 | 477 |
($hid,$did,$dta->{ENSEMBLE_BYTES},$dummy,$dta->{NUMBER_OF_DATA_TYPES}) |
478 |
= unpack('CCvCC',$buf); |
|
36
515b06dae59c
version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
32
diff
changeset
|
479 |
$hid == 0x7f || die(sprintf($FmtErr,$WBRcfn,"Header (hid2)",$hid,0)); |
29 | 480 |
$dta->{DATA_SOURCE_ID} = $did; |
481 |
if ($did == 0x7f) { |
|
482 |
$dta->{PRODUCER} = 'TRDI ADCP'; |
|
31 | 483 |
} elsif (($did&0xF0) == 0xA0) { |
484 |
$dta->{PRODUCER} = 'IMP+LADCP (Thurnherr software)'; |
|
485 |
} elsif (($did&0xF0) == 0xE0) { |
|
486 |
$dta->{PRODUCER} = 'editPD0 (Thurnherr software)'; |
|
29 | 487 |
} else { |
31 | 488 |
$dta->{PRODUCER} = sprintf('unknown (0x%02X)'); |
29 | 489 |
} |
490 |
||
14 | 491 |
sysread(WBRF,$buf,2*$dta->{NUMBER_OF_DATA_TYPES}) |
492 |
== 2*$dta->{NUMBER_OF_DATA_TYPES} |
|
493 |
|| die("$WBRcfn: $!"); |
|
494 |
@WBRofs = unpack("v$dta->{NUMBER_OF_DATA_TYPES}",$buf); |
|
495 |
# for ($i=0; $i<$dta->{NUMBER_OF_DATA_TYPES}; $i++) { |
|
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
496 |
# printf(STDERR "WBRofs[$i] = %d",$WBRofs[$i]); |
14 | 497 |
# } |
498 |
||
39 | 499 |
|
500 |
$dta->{HEADER_BYTES} = $WBRofs[0]; |
|
501 |
$dta->{FIXED_LEADER_BYTES} = $WBRofs[1] - $WBRofs[0]; |
|
502 |
$dta->{VARIABLE_LEADER_BYTES} = $WBRofs[2] - $WBRofs[1]; |
|
503 |
||
504 |
if ($dta->{FIXED_LEADER_BYTES} == 42) { # Eric Firing's old instrument I used in 2004 |
|
505 |
$dta->{INSTRUMENT_TYPE} = 'BB150'; |
|
506 |
} elsif ($dta->{FIXED_LEADER_BYTES} == 53) { # old firmware: no serial numbers |
|
507 |
$dta->{INSTRUMENT_TYPE} = 'Workhorse'; |
|
508 |
} elsif ($dta->{FIXED_LEADER_BYTES} == 59) { # new firmware: with serial numbers |
|
509 |
$dta->{INSTRUMENT_TYPE} = 'Workhorse'; |
|
510 |
} elsif ($dta->{FIXED_LEADER_BYTES} == 58) { # DVL |
|
511 |
$dta->{INSTRUMENT_TYPE} = 'Explorer'; |
|
512 |
} elsif ($dta->{FIXED_LEADER_BYTES} == 60) { # OS75 |
|
513 |
$dta->{INSTRUMENT_TYPE} = 'Ocean Surveyor'; |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
514 |
} else { |
39 | 515 |
$dta->{INSTRUMENT_TYPE} = 'unknown'; |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
516 |
} |
39 | 517 |
|
518 |
#-------------------------------- |
|
519 |
# Variable Leader: SPEED_OF_SOUND |
|
520 |
#-------------------------------- |
|
14 | 521 |
|
26
02776c168135
made RDI_BB_IO work with files containing leading garbage
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
24
diff
changeset
|
522 |
sysseek(WBRF,$start_ens+$WBRofs[1],0) || die("$WBRcfn: $!"); |
14 | 523 |
sysread(WBRF,$buf,2) == 2 || die("$WBRcfn: $!"); |
524 |
$id = unpack('v',$buf); |
|
39 | 525 |
if ($dta->{INSTRUMENT_TYPE} eq 'Ocean Surveyor') { |
526 |
$id == 0x0081 || printf(STDERR $FmtErr."\n",$WBRcfn,"Variable Leader",$id,1); |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
527 |
} else { |
39 | 528 |
$id == 0x0080 || printf(STDERR $FmtErr."\n",$WBRcfn,"Variable Leader",$id,1); |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
529 |
} |
39 | 530 |
sysseek(WBRF,12,1) || die("$WBRcfn: $!"); # skip up to speed of sound |
14 | 531 |
sysread(WBRF,$buf,2) == 2 || die("$WBRcfn: $!"); |
39 | 532 |
$dta->{SPEED_OF_SOUND} = unpack('v',$buf); |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
533 |
|
14 | 534 |
#-------------------- |
535 |
# FIXED LEADER |
|
536 |
#-------------------- |
|
537 |
||
26
02776c168135
made RDI_BB_IO work with files containing leading garbage
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
24
diff
changeset
|
538 |
sysseek(WBRF,$start_ens+$WBRofs[0],0) || die("$WBRcfn: $!"); |
14 | 539 |
sysread(WBRF,$buf,42) == 42 || die("$WBRcfn: $!"); |
39 | 540 |
($id,$dta->{CPU_FW_VER},$dta->{CPU_FW_REV},$B1,$B2,$dummy, |
541 |
$dta->{LAG_LENGTH},$dummy, |
|
14 | 542 |
$dta->{N_BINS},$dta->{PINGS_PER_ENSEMBLE},$dta->{BIN_LENGTH}, |
543 |
$dta->{BLANKING_DISTANCE},$dummy,$dta->{MIN_CORRELATION}, |
|
544 |
$dta->{N_CODE_REPETITIONS},$dta->{MIN_PERCENT_GOOD}, |
|
545 |
$dta->{MAX_ERROR_VELOCITY},$dta->{TIME_BETWEEN_PINGS},$B3,$B4,$B5, |
|
546 |
$dta->{HEADING_ALIGNMENT},$dta->{HEADING_BIAS},$B6,$B7, |
|
547 |
$dta->{DISTANCE_TO_BIN1_CENTER},$dta->{TRANSMITTED_PULSE_LENGTH}, |
|
548 |
$dta->{REF_LAYER_FIRST_BIN},$dta->{REF_LAYER_LAST_BIN}, |
|
549 |
$dta->{FALSE_TARGET_THRESHOLD},$dta->{LOW_LATENCY_SETTING}, |
|
550 |
$dta->{TRANSMIT_LAG_DISTANCE}) = |
|
551 |
unpack('vCCCCC3CvvvCCCCvCCCCvvCCvvCCCCv',$buf); |
|
552 |
||
39 | 553 |
if ($dta->{INSTRUMENT_TYPE} eq 'Ocean Surveyor') { |
554 |
$id == 0x0001 || printf(STDERR $FmtErr."\n",$WBRcfn,"Fixed Leader",$id,0); |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
555 |
} else { |
39 | 556 |
$id == 0x0000 || printf(STDERR $FmtErr."\n",$WBRcfn,"Fixed Leader",$id,0); |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
557 |
} |
14 | 558 |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
559 |
# $dta->{BEAM_FREQUENCY} = 2**($B1 & 0x07) * 75; # nominal |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
560 |
if (($B1&0x07) == 0b000) { $dta->{BEAM_FREQUENCY} = 76.8; } # actual |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
561 |
elsif (($B1&0x07) == 0b001) { $dta->{BEAM_FREQUENCY} = 153.6; } |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
562 |
elsif (($B1&0x07) == 0b010) { $dta->{BEAM_FREQUENCY} = 307.2; } |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
563 |
elsif (($B1&0x07) == 0b011) { $dta->{BEAM_FREQUENCY} = 614.4; } |
39 | 564 |
elsif (($B1&0x07) == 0b100) { $dta->{BEAM_FREQUENCY} = 1228.8; } |
565 |
elsif (($B1&0x07) == 0b101) { $dta->{BEAM_FREQUENCY} = 2457.6; } |
|
566 |
else { die(sprintf("$WBRcfn: cannot decode BEAM_FREQUENCY (%03b)\n",$B1&0x07)); } |
|
567 |
||
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
568 |
$dta->{CONVEX_BEAM_PATTERN} = 1 if ($B1 & 0x08); |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
569 |
$dta->{CONCAVE_BEAM_PATTERN} = 1 if (!($B1 & 0x08)); |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
570 |
$dta->{SENSOR_CONFIG} = ($B1 & 0x30) >> 4; |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
571 |
$dta->{XDUCER_HEAD_ATTACHED} = 1 if ($B1 & 0x40); |
14 | 572 |
|
573 |
if (($B2 & 0x03) == 0x00) { $dta->{BEAM_ANGLE} = 15; } |
|
574 |
elsif (($B2 & 0x03) == 0x01) { $dta->{BEAM_ANGLE} = 20; } |
|
575 |
elsif (($B2 & 0x03) == 0x02) { $dta->{BEAM_ANGLE} = 30; } |
|
576 |
if (($B2 & 0xF0) == 0x40) { $dta->{N_BEAMS} = 4; } |
|
577 |
elsif (($B2 & 0xF0) == 0x50) { $dta->{N_BEAMS} = 5; $dta->{N_DEMODS} = 3; } |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
578 |
elsif (($B2 & 0xF0) == 0xF0) { $dta->{N_BEAMS} = 5; $dta->{N_DEMODS} = 2; } |
14 | 579 |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
580 |
$dta->{BIN_LENGTH} /= 100; |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
581 |
$dta->{BLANKING_DISTANCE} /= 100; |
14 | 582 |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
583 |
$dta->{MAX_ERROR_VELOCITY} /= 1000; |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
584 |
$dta->{TIME_BETWEEN_PINGS} *= 60; |
14 | 585 |
$dta->{TIME_BETWEEN_PINGS} += $B3 + $B4/100; |
586 |
||
587 |
$dta->{BEAM_COORDINATES} = 1 if (($B5 & 0x18) == 0x00); |
|
588 |
$dta->{INSTRUMENT_COORDINATES} = 1 if (($B5 & 0x18) == 0x08); |
|
589 |
$dta->{SHIP_COORDINATES} = 1 if (($B5 & 0x18) == 0x10); |
|
590 |
$dta->{EARTH_COORDINATES} = 1 if (($B5 & 0x18) == 0x18); |
|
591 |
$dta->{PITCH_AND_ROLL_USED} = 1 if ($B5 & 0x04); |
|
592 |
$dta->{USE_3_BEAM_ON_LOW_CORR} = 1 if ($B5 & 0x02); |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
593 |
$dta->{BIN_MAPPING_ALLOWED} = 1 if ($B5 & 0x01); |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
594 |
|
14 | 595 |
$dta->{HEADING_ALIGNMENT} = |
596 |
($dta->{EARTH_COORDINATES} || $dta->{SHIP_COORDINATES}) ? |
|
597 |
$dta->{HEADING_ALIGNMENT} / 100 : undef; |
|
598 |
$dta->{HEADING_BIAS} = |
|
599 |
($dta->{EARTH_COORDINATES} || $dta->{SHIP_COORDINATES}) ? |
|
600 |
$dta->{HEADING_BIAS} / 100 : undef; |
|
601 |
||
602 |
$dta->{CALCULATE_SPEED_OF_SOUND} = 1 if ($B6 & 0x40); |
|
603 |
$dta->{USE_PRESSURE_SENSOR} = 1 if ($B6 & 0x20); |
|
604 |
$dta->{USE_COMPASS} = 1 if ($B6 & 0x10); |
|
605 |
$dta->{USE_PITCH_SENSOR} = 1 if ($B6 & 0x08); |
|
606 |
$dta->{USE_ROLL_SENSOR} = 1 if ($B6 & 0x04); |
|
607 |
$dta->{USE_CONDUCTIVITY_SENSOR} = 1 if ($B6 & 0x02); |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
608 |
$dta->{USE_TEMPERATURE_SENSOR} = 1 if ($B6 & 0x01); |
14 | 609 |
|
610 |
$dta->{SPEED_OF_SOUND_CALCULATED} = 1 if ($B7 & 0x40); |
|
611 |
$dta->{PRESSURE_SENSOR_AVAILABLE} = 1 if ($B7 & 0x20); |
|
612 |
$dta->{COMPASS_AVAILABLE} = 1 if ($B7 & 0x10); |
|
613 |
$dta->{PITCH_SENSOR_AVAILABLE} = 1 if ($B7 & 0x08); |
|
614 |
$dta->{ROLL_SENSOR_AVAILABLE} = 1 if ($B7 & 0x04); |
|
615 |
$dta->{CONDUCTIVITY_SENSOR_AVAILABLE} = 1 if ($B7 & 0x02); |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
616 |
$dta->{TEMPERATURE_SENSOR_AVAILABLE} = 1 if ($B7 & 0x01); |
14 | 617 |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
618 |
$dta->{DISTANCE_TO_BIN1_CENTER} /= 100; |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
619 |
$dta->{TRANSMITTED_PULSE_LENGTH} /= 100; |
14 | 620 |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
621 |
$dta->{FALSE_TARGET_THRESHOLD} = undef |
14 | 622 |
if ($dta->{FALSE_TARGET_THRESHOLD} == 255); |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
623 |
$dta->{TRANSMIT_LAG_DISTANCE} /= 100; |
14 | 624 |
|
625 |
if ($dta->{INSTRUMENT_TYPE} eq 'Workhorse') { |
|
626 |
sysread(WBRF,$buf,11) == 11 || die("$WBRcfn: $!"); |
|
627 |
($W1,$W2,$W3,$W4,$W5,$dta->{TRANSMIT_POWER}) = |
|
628 |
unpack('vvvvvC',$buf); |
|
629 |
||
630 |
$dta->{CPU_SERIAL_NUMBER} = sprintf("%04X%04X%04X%04X",$W1,$W2,$W3,$W4); |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
631 |
|
14 | 632 |
$dta->{NARROW_BANDWIDTH} = ($W5 == 1); |
633 |
$dta->{WIDE_BANDWIDTH} = ($W5 == 0); |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
634 |
$dta->{TRANSMIT_POWER_HIGH} = ($dta->{TRANSMIT_POWER} == 255); |
14 | 635 |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
636 |
if ($dta->{FIXED_LEADER_BYTES} == 59) { # new style with serial number |
14 | 637 |
sysread(WBRF,$buf,6) == 6 || die("$WBRcfn: $!"); |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
638 |
($dummy,$dta->{SERIAL_NUMBER},$dummy) = # last bytes is beam angle, but that info has |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
639 |
unpack('CVC',$buf); # already been provided above |
14 | 640 |
} |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
641 |
} |
14 | 642 |
|
643 |
if ($dta->{INSTRUMENT_TYPE} eq 'Explorer') { |
|
644 |
sysread(WBRF,$buf,16) == 16 || die("$WBRcfn: $!"); |
|
645 |
($dummy,$dummy,$W5,$dummy,$dta->{SERIAL_NUMBER}) = |
|
646 |
unpack('VVvvV',$buf); |
|
647 |
$dta->{NARROW_BANDWIDTH} = ($W5 == 1); |
|
648 |
$dta->{WIDE_BANDWIDTH} = ($W5 == 0); |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
649 |
} |
14 | 650 |
|
651 |
#----------------------- |
|
652 |
# 1st ENSEMBLE, BT Setup |
|
653 |
#----------------------- |
|
654 |
||
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
655 |
# CODE DISABLED BECAUSE BT_PRESENT FLAG WAS REMOVED. WITHOUT THIS CODE, |
49 | 656 |
# [listHdr] DOES NOT LIST ANY BT INFO |
657 |
# |
|
658 |
# if ($dta->{BT_PRESENT}) { |
|
659 |
# sysseek(WBRF,$start_ens+$WBRofs[$BT_dt],0) || die("$WBRcfn: $!"); |
|
660 |
# sysread(WBRF,$buf,12) == 12 || die("$WBRcfn: $!"); |
|
661 |
# ($id,$dta->{BT_PINGS_PER_ENSEMBLE},$dta->{BT_DELAY_BEFORE_REACQUIRE}, |
|
662 |
# $dta->{BT_MIN_CORRELATION},$dta->{BT_MIN_EVAL_AMPLITUDE}, |
|
663 |
# $dta->{BT_MIN_PERCENT_GOOD},$dta->{BT_MODE}, |
|
664 |
# $dta->{BT_MAX_ERROR_VELOCITY}) = unpack('vvvCCCCv',$buf); |
|
665 |
# |
|
666 |
# $id == 0x0600 || |
|
667 |
# printf(STDERR $FmtErr."\n",$WBRcfn,"Bottom Track",$id,0,tell(WBRF)); |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
668 |
# |
49 | 669 |
# $dta->{BT_MAX_ERROR_VELOCITY} = |
670 |
# $dta->{BT_MAX_ERROR_VELOCITY} ? $dta->{BT_MAX_ERROR_VELOCITY} / 1000 |
|
671 |
# : undef; |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
672 |
# |
49 | 673 |
# sysseek(WBRF,28,1) || die("$WBRcfn: $!"); |
674 |
# sysread(WBRF,$buf,6) == 6 || die("$WBRcfn: $!"); |
|
675 |
# ($dta->{BT_RL_MIN_SIZE},$dta->{BT_RL_NEAR},$dta->{BT_RL_FAR}) |
|
676 |
# = unpack('vvv',$buf); |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
677 |
# |
49 | 678 |
# $dta->{BT_RL_MIN_SIZE} /= 10; |
679 |
# $dta->{BT_RL_NEAR} /= 10; |
|
680 |
# $dta->{BT_RL_FAR} /= 10; |
|
681 |
# |
|
682 |
# sysseek(WBRF,20,1) || die("$WBRcfn: $!"); # skip data |
|
683 |
# sysread(WBRF,$buf,2) == 2 || die("$WBRcfn: $!"); |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
684 |
# $dta->{BT_MAX_TRACKING_DEPTH} = unpack('v',$buf) / 10; |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
685 |
# } |
14 | 686 |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
687 |
return $dta; |
14 | 688 |
} |
689 |
||
690 |
#---------------------------------------------------------------------- |
|
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
691 |
# readData(file_name,^data[,first_ens,last_ens[,last_bin]]) |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
692 |
# - read ensembles |
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
693 |
# - read all ensembles unless first_ens and last_ens are given |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
694 |
# - read all bins unless last_bin is given |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
695 |
# - NB: CODE GETS PROGRESSIVELY SLOWER => HUGE PAIN FOR LARGE FILES |
14 | 696 |
#---------------------------------------------------------------------- |
697 |
||
698 |
sub readData(@) |
|
699 |
{ |
|
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
700 |
my($fn,$dta,$fe,$le,$lb) = @_; |
14 | 701 |
$WBRcfn = $fn; |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
702 |
open(WBRF,$WBRcfn) || die("$WBRcfn: $!\n"); |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
703 |
WBRhdr($dta) || die("$WBRcfn: Insufficient Data\n"); |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
704 |
$lb = $dta->{N_BINS} |
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
705 |
unless (numberp($lb) && $lb>=1 && $lb<=$dta->{N_BINS}); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
706 |
WBRens($lb,$dta->{FIXED_LEADER_BYTES},\@{$dta->{ENSEMBLE}},$fe,$le); |
14 | 707 |
print(STDERR "$WBRcfn: $BIT_errors built-in-test errors\n") |
708 |
if ($BIT_errors); |
|
709 |
} |
|
710 |
||
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
711 |
sub WBRens(@) |
14 | 712 |
{ |
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
713 |
my($nbins,$fixed_leader_bytes,$E,$fe,$le) = @_; |
48
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
714 |
my($B1,$B2,$B3,$B4,$I,$bin,$beam,$dummy,@dta,$i,$cs); |
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
715 |
my($ens,$ensNo,$dayStart,$ens_length,$hid,$did,$el); |
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
716 |
local our($ndt,$buf,$id,$start_ens,@WBRofs); |
14 | 717 |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
718 |
sysseek(WBRF,0,0) || die("$WBRcfn: $!"); |
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
719 |
ENSEMBLE: |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
720 |
for ($ens=0; 1; $ens++) { |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
721 |
print(STDERR '.') if ($RDI_PD0_IO::show_progress && $ens % 1000 == 0); |
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
722 |
$start_ens = goto_next_ens(\*WBRF); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
723 |
last unless defined($start_ens); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
724 |
|
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
725 |
#---------------------------------------- |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
726 |
# Handle first_ens and last_ens |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
727 |
#---------------------------------------- |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
728 |
|
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
729 |
if (defined($fe) && $ens>0 && ${$E}[$ens-1]->{NUMBER}<$fe) { # delete previous ensemble |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
730 |
pop(@{$E}); $ens--; |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
731 |
} |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
732 |
|
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
733 |
if (defined($le) && $ens>0 && ${$E}[$ens-1]->{NUMBER}>$le) { # delete previous ensemble and finish |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
734 |
pop(@{$E}); $ens--; |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
735 |
last; |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
736 |
} |
14 | 737 |
|
738 |
#---------------------------------------- |
|
739 |
# Get ensemble length and # of data types |
|
740 |
#---------------------------------------- |
|
741 |
||
742 |
sysseek(WBRF,$start_ens,0) || die("$WBRcfn: $!"); |
|
743 |
sysread(WBRF,$buf,6) == 6 || last; |
|
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
744 |
($hid,$did,$el,$dummy,$ndt) = unpack('CCvCC',$buf); |
37 | 745 |
$hid == 0x7f || die(sprintf($FmtErr,$WBRcfn,"Header",$hid,defined($ensNo)?$ensNo+1:0)); |
29 | 746 |
${$E}[$ens]->{DATA_SOURCE_ID} = $did; |
747 |
if ($did == 0x7f) { |
|
748 |
${$E}[$ens]->{PRODUCER} = 'TRDI ADCP'; |
|
749 |
} elsif ($did&0xF0 == 0xA0) { |
|
750 |
${$E}[$ens]->{PRODUCER} = 'IMP+LADCP (Thurnherr software)'; |
|
31 | 751 |
} elsif ($did&0xF0 == 0xE0) { |
29 | 752 |
${$E}[$ens]->{PRODUCER} = 'editPD0 (Thurnherr software)'; |
753 |
} else { |
|
754 |
${$E}[$ens]->{PRODUCER} = 'unknown'; |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
755 |
} |
29 | 756 |
|
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
757 |
if (defined($ens_length) && ($el != $ens_length)) { |
50 | 758 |
$RDI_PD0_IO::File_Dirty = 1; |
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
759 |
print(STDERR "WARNING (RDI_PD0_IO): ensemble ${$E}[$#{$E}]->{NUMBER} skipped (unexpected length)\n"); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
760 |
pop(@{$E}); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
761 |
$ens--; |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
762 |
next; |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
763 |
} |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
764 |
|
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
765 |
$ens_length = $el; |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
766 |
|
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
767 |
## printf(STDERR "$WBRcfn: WARNING: unexpected number of data types (%d, ens=$ens)\n",$ndt),last |
18 | 768 |
## unless ($ndt == 6 || $ndt == 7); |
50 | 769 |
my($nread) = sysread(WBRF,$buf,2*$ndt); # 2019 EPR test |
770 |
if ($nread != 2*$ndt) { |
|
771 |
printf(STDERR "$WBRcfn: WARNING: expected to read %d bytes, got only %d in ensemble %d\n", |
|
772 |
2*$ndt,$nread,${$E}[$ens]->{NUMBER}); |
|
773 |
last; |
|
774 |
} |
|
775 |
||
776 |
||
14 | 777 |
@WBRofs = unpack("v$ndt",$buf); |
778 |
$fixed_leader_bytes = $WBRofs[1] - $WBRofs[0]; |
|
779 |
# print(STDERR "@WBRofs\n"); |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
780 |
|
14 | 781 |
#------------------------------- |
782 |
# Make Sure Ensemble is Complete |
|
783 |
#------------------------------- |
|
784 |
||
785 |
# UH BB150 writes incomplete ensembles (i.e. short read |
|
786 |
# indicates EOF). FSU WH300 has bogus data in incomplete |
|
787 |
# final ensemble. |
|
788 |
||
789 |
sysseek(WBRF,$start_ens,0) || die("$WBRcfn: $!"); |
|
37 | 790 |
unless ((sysread(WBRF,$buf,$ens_length) == $ens_length) && # incomplete ensemble |
36
515b06dae59c
version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
32
diff
changeset
|
791 |
(sysread(WBRF,$cs,2) == 2)) { |
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
792 |
# print(STDERR "INCOMPLETE ENSEMBLE\n"); |
36
515b06dae59c
version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
32
diff
changeset
|
793 |
pop(@{$E}); |
515b06dae59c
version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
32
diff
changeset
|
794 |
last; |
515b06dae59c
version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
32
diff
changeset
|
795 |
} |
14 | 796 |
|
37 | 797 |
unless (unpack('%16C*',$buf) == unpack('v',$cs)) { # bad checksum |
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
798 |
# print(STDERR "BAD CHECKSUM\n"); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
799 |
pop(@{$E}); $ens--; |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
800 |
next; |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
801 |
} |
14 | 802 |
|
803 |
#------------------------------ |
|
804 |
# Variable Leader |
|
805 |
#------------------------------ |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
806 |
|
37 | 807 |
my($lastEns) = $ensNo; |
14 | 808 |
sysseek(WBRF,$start_ens+$WBRofs[1],0) || die("$WBRcfn: $!"); |
809 |
sysread(WBRF,$buf,4) == 4 || die("$WBRcfn: $!"); |
|
37 | 810 |
($id,$ensNo) = unpack("vv",$buf); # only lower two bytes!!! |
14 | 811 |
|
39 | 812 |
if (${$E}[$ens]->{INSTRUMENT_TYPE} eq 'Ocean Surveyor') { |
813 |
$id == 0x0081 || |
|
814 |
die(sprintf($FmtErr,$WBRcfn,"Variable Leader",$id,$ensNo + ($lastEns - ($lastEns & 0xFFFF)))); |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
815 |
} else { |
39 | 816 |
$id == 0x0080 || |
817 |
die(sprintf($FmtErr,$WBRcfn,"Variable Leader",$id,$ensNo + ($lastEns - ($lastEns & 0xFFFF)))); |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
818 |
} |
14 | 819 |
|
42 | 820 |
# if ($fixed_leader_bytes==42 || $fixed_leader_bytes==58) { # BB150 & Explorer DVL (if DISABLED!) |
821 |
sysread(WBRF,$buf,7) == 7 || die("$WBRcfn: $!"); # always read pre-Y2K clock |
|
14 | 822 |
(${$E}[$ens]->{YEAR},${$E}[$ens]->{MONTH}, |
823 |
${$E}[$ens]->{DAY},${$E}[$ens]->{HOUR},${$E}[$ens]->{MINUTE}, |
|
50 | 824 |
${$E}[$ens]->{SECOND},$B4) = unpack('CCCCCCC',$buf); |
825 |
${$E}[$ens]->{SECOND} += $B4/100; |
|
14 | 826 |
${$E}[$ens]->{YEAR} += (${$E}[$ens]->{YEAR} > 80) ? 1900 : 2000; |
40
6a46e9d31106
after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
39
diff
changeset
|
827 |
# } else { |
6a46e9d31106
after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
39
diff
changeset
|
828 |
# sysseek(WBRF,7,1) || die("$WBRcfn: $!"); # use Y2K RTC instead |
6a46e9d31106
after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
39
diff
changeset
|
829 |
# } |
14 | 830 |
|
831 |
sysread(WBRF,$buf,1) == 1 || die("$WBRcfn: $!"); |
|
832 |
$ensNo += unpack('C',$buf) << 16; |
|
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
833 |
|
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
834 |
for (my($i)=$ens; $i>0; $i--) { # check for duplicate ens; e.g. 2018 S4P 24UL |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
835 |
if (${$E}[$i]->{NUMBER} == $ensNo) { |
50 | 836 |
$RDI_PD0_IO::File_Dirty = 1; |
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
837 |
print(STDERR "WARNING (RDI_PD0_IO): duplicate ensemble $ensNo skipped\n"); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
838 |
pop(@{$E}); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
839 |
$ens--; |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
840 |
next ENSEMBLE; |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
841 |
} |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
842 |
} |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
843 |
|
14 | 844 |
${$E}[$ens]->{NUMBER} = $ensNo; |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
845 |
|
14 | 846 |
sysread(WBRF,$buf,30) == 30 || die("$WBRcfn: $!"); |
847 |
(${$E}[$ens]->{BUILT_IN_TEST_ERROR},${$E}[$ens]->{SPEED_OF_SOUND}, |
|
848 |
${$E}[$ens]->{XDUCER_DEPTH},${$E}[$ens]->{HEADING}, |
|
849 |
${$E}[$ens]->{PITCH},${$E}[$ens]->{ROLL}, |
|
850 |
${$E}[$ens]->{SALINITY},${$E}[$ens]->{TEMPERATURE}, |
|
851 |
${$E}[$ens]->{MIN_PRE_PING_WAIT_TIME},$B1,$B2, |
|
852 |
${$E}[$ens]->{HEADING_STDDEV},${$E}[$ens]->{PITCH_STDDEV}, |
|
853 |
${$E}[$ens]->{ROLL_STDDEV},${$E}[$ens]->{ADC_XMIT_CURRENT}, |
|
854 |
${$E}[$ens]->{ADC_XMIT_VOLTAGE},${$E}[$ens]->{ADC_AMBIENT_TEMPERATURE}, |
|
855 |
${$E}[$ens]->{ADC_PRESSURE_PLUS},${$E}[$ens]->{ADC_PRESSURE_MINUS}, |
|
856 |
${$E}[$ens]->{ADC_ATTITUDE_TEMPERATURE},${$E}[$ens]->{ADC_ATTITUDE}, |
|
857 |
${$E}[$ens]->{ADC_CONTAMINATION}) |
|
858 |
= unpack('vvvvvvvvCCCCCCCCCCCCCC',$buf); |
|
859 |
||
860 |
${$E}[$ens]->{BUILT_IN_TEST_ERROR} = undef |
|
861 |
unless (${$E}[$ens]->{BUILT_IN_TEST_ERROR}); |
|
862 |
$BIT_errors++ if (${$E}[$ens]->{BUILT_IN_TEST_ERROR}); |
|
863 |
||
864 |
${$E}[$ens]->{XDUCER_DEPTH} /= 10; |
|
18 | 865 |
|
866 |
#------------------------------------------------- |
|
867 |
# IMP EXTENSION: PITCH/ROLL/HEADING CAN BE MISSING |
|
868 |
#------------------------------------------------- |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
869 |
|
18 | 870 |
${$E}[$ens]->{HEADING} = (${$E}[$ens]->{HEADING} == 0xF000) |
871 |
? undef |
|
872 |
: ${$E}[$ens]->{HEADING} / 100; |
|
873 |
${$E}[$ens]->{PITCH} = (${$E}[$ens]->{PITCH} == 0x8000) |
|
874 |
? undef |
|
875 |
: unpack('s',pack('S',${$E}[$ens]->{PITCH})) / 100; |
|
876 |
${$E}[$ens]->{ROLL} = (${$E}[$ens]->{ROLL} == 0x8000) |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
877 |
? undef |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
878 |
: unpack('s',pack('S',${$E}[$ens]->{ROLL})) / 100; |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
879 |
|
18 | 880 |
${$E}[$ens]->{TEMPERATURE} = unpack('s',pack('S',${$E}[$ens]->{TEMPERATURE})) / 100; |
14 | 881 |
${$E}[$ens]->{MIN_PRE_PING_WAIT_TIME} *= 60; |
882 |
${$E}[$ens]->{MIN_PRE_PING_WAIT_TIME} += $B1 + $B2/100; |
|
883 |
${$E}[$ens]->{PITCH_STDDEV} /= 10; |
|
884 |
${$E}[$ens]->{ROLL_STDDEV} /= 10; |
|
885 |
||
40
6a46e9d31106
after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
39
diff
changeset
|
886 |
if (($fixed_leader_bytes==53 || $fixed_leader_bytes==59) && # Workhorse instruments |
6a46e9d31106
after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
39
diff
changeset
|
887 |
!defined($RDI_PD0_IO::IGNORE_Y2K_CLOCK)) { |
14 | 888 |
sysread(WBRF,$buf,23) == 23 || die("$WBRcfn: $!"); |
889 |
(${$E}[$ens]->{ERROR_STATUS_WORD}, |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
890 |
$dummy,${$E}[$ens]->{PRESSURE},${$E}[$ens]->{PRESSURE_STDDEV}, |
14 | 891 |
$dummy,${$E}[$ens]->{YEAR},$B3,${$E}[$ens]->{MONTH}, |
892 |
${$E}[$ens]->{DAY},${$E}[$ens]->{HOUR},${$E}[$ens]->{MINUTE}, |
|
50 | 893 |
${$E}[$ens]->{SECOND},$B4) |
14 | 894 |
= unpack('VvVVCCCCCCCCC',$buf); |
895 |
||
896 |
${$E}[$ens]->{PRESSURE} /= 1000; |
|
897 |
${$E}[$ens]->{PRESSURE_STDDEV} /= 1000; |
|
898 |
${$E}[$ens]->{YEAR} *= 100; ${$E}[$ens]->{YEAR} += $B3; |
|
50 | 899 |
${$E}[$ens]->{SECOND} += $B4/100; |
14 | 900 |
} |
901 |
||
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
902 |
# THE FOLLOWING LINE OF CODE WAS REMOVED 7/30/2016 WHEN I ADDED A POP |
36
515b06dae59c
version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
32
diff
changeset
|
903 |
# TO THE last STATEMENT ABOVE (INCOMPLETE ENSEMBLE) |
42 | 904 |
# THE LINE WAS RE-ENABLED ON 12/23/2017 BECAUSE OTHERWISE THE |
905 |
# ANSLOPE II PROFILES IN THE HOWTO CANNOT BE READ. |
|
906 |
pop(@{$E}),last if (${$E}[$ens]->{MONTH}>12); # 10/15/2014; IWISE#145 UL ??? |
|
21 | 907 |
|
14 | 908 |
if ($fixed_leader_bytes == 58) { # Explorer DVL |
909 |
sysread(WBRF,$buf,14) == 14 || die("$WBRcfn: $!"); |
|
910 |
(${$E}[$ens]->{ERROR_STATUS_WORD}, |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
911 |
$dummy,${$E}[$ens]->{PRESSURE},${$E}[$ens]->{PRESSURE_STDDEV}) |
14 | 912 |
= unpack('VvVV',$buf); |
913 |
${$E}[$ens]->{PRESSURE} /= 1000; |
|
914 |
${$E}[$ens]->{PRESSURE_STDDEV} /= 1000; |
|
915 |
} |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
916 |
|
14 | 917 |
${$E}[$ens]->{DATE} |
918 |
= sprintf("%02d/%02d/%d",${$E}[$ens]->{MONTH}, |
|
919 |
${$E}[$ens]->{DAY}, |
|
920 |
${$E}[$ens]->{YEAR}); |
|
921 |
${$E}[$ens]->{TIME} |
|
922 |
= sprintf("%02d:%02d:%05.02f",${$E}[$ens]->{HOUR}, |
|
923 |
${$E}[$ens]->{MINUTE}, |
|
50 | 924 |
${$E}[$ens]->{SECOND}); |
14 | 925 |
${$E}[$ens]->{DAYNO} |
40
6a46e9d31106
after Hamburg visit
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
39
diff
changeset
|
926 |
= &_dayNo(${$E}[$ens]->{YEAR},${$E}[$ens]->{MONTH},${$E}[$ens]->{DAY}, |
50 | 927 |
${$E}[$ens]->{HOUR},${$E}[$ens]->{MINUTE},${$E}[$ens]->{SECOND}); |
14 | 928 |
|
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
929 |
# when analyzing an STA file from an OS75 SADCP (Poseidon), |
14 | 930 |
# I noticed that there is no time information. This causes |
931 |
# timegm to bomb. |
|
932 |
if (${$E}[$ens]->{MONTH} == 0) { # no time info |
|
933 |
${$E}[$ens]->{UNIX_TIME} = 0; |
|
934 |
${$E}[$ens]->{SECNO} = 0; |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
935 |
} else { |
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
936 |
# print(STDERR "[$ens]->${$E}[$ens]->{MINUTE}:${$E}[$ens]->{HOUR},${$E}[$ens]->{DAY},${$E}[$ens]->{MONTH},${$E}[$ens]->{YEAR}-<\n"); |
14 | 937 |
${$E}[$ens]->{UNIX_TIME} |
938 |
= timegm(0,${$E}[$ens]->{MINUTE}, |
|
939 |
${$E}[$ens]->{HOUR}, |
|
940 |
${$E}[$ens]->{DAY}, |
|
941 |
${$E}[$ens]->{MONTH}-1, # timegm jan==0!!! |
|
942 |
${$E}[$ens]->{YEAR}) |
|
50 | 943 |
+ ${$E}[$ens]->{SECOND}; |
14 | 944 |
|
945 |
$dayStart = timegm(0,0,0,${$E}[$ens]->{DAY}, |
|
946 |
${$E}[$ens]->{MONTH}-1, |
|
947 |
${$E}[$ens]->{YEAR}) |
|
948 |
unless defined($dayStart); |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
949 |
${$E}[$ens]->{SECNO} = ${$E}[$ens]->{UNIX_TIME} - $dayStart; |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
950 |
} |
14 | 951 |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
952 |
sysseek(WBRF,$start_ens+$WBRofs[0]+4,0) # System Config / Fixed Leader |
14 | 953 |
|| die("$WBRcfn: $!"); |
954 |
||
955 |
sysread(WBRF,$buf,5) == 5 || die("$WBRcfn: $!"); |
|
956 |
($B1,$dummy,$dummy,$dummy,${$E}[$ens]->{N_BEAMS_USED}) |
|
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
957 |
= unpack('CCCCC',$buf); |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
958 |
${$E}[$ens]->{XDUCER_FACING_UP} = 1 if ($B1 & 0x80); |
14 | 959 |
${$E}[$ens]->{XDUCER_FACING_DOWN} = 1 unless ($B1 & 0x80); |
960 |
||
961 |
#-------------------- |
|
962 |
# Velocity Data |
|
963 |
#-------------------- |
|
964 |
||
965 |
my($ndata) = $nbins * 4; |
|
966 |
||
48
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
967 |
my($vel_di) = WBRdtaIndex(0x0100); |
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
968 |
die("no velocity data in ensemble #$ensNo\n") |
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
969 |
unless defined($vel_di); |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
970 |
|
48
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
971 |
sysseek(WBRF,$start_ens+$WBRofs[$vel_di],0) || die("$WBRcfn: $!"); |
14 | 972 |
sysread(WBRF,$buf,2+$ndata*2) == 2+$ndata*2 || die("$WBRcfn: $!"); |
973 |
($id,@dta) = unpack("vv$ndata",$buf); |
|
974 |
||
975 |
for ($i=0,$bin=0; $bin<$nbins; $bin++) { |
|
976 |
for ($beam=0; $beam<4; $beam++,$i++) { |
|
977 |
${$E}[$ens]->{VELOCITY}[$bin][$beam] = |
|
978 |
unpack('s',pack('S',$dta[$i])) / 1000 |
|
979 |
if ($dta[$i] != 0x8000); |
|
980 |
} |
|
981 |
} |
|
982 |
||
983 |
#-------------------- |
|
984 |
# Correlation Data |
|
985 |
#-------------------- |
|
986 |
||
48
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
987 |
my($corr_di) = WBRdtaIndex(0x0200); |
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
988 |
die("no correlation data in ensemble #$ensNo\n") |
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
989 |
unless defined($corr_di); |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
990 |
|
48
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
991 |
sysseek(WBRF,$start_ens+$WBRofs[$corr_di],0) || die("$WBRcfn: $!"); |
14 | 992 |
sysread(WBRF,$buf,2+$ndata) == 2+$ndata || die("$WBRcfn: $!"); |
993 |
($id,@dta) = unpack("vC$ndata",$buf); |
|
994 |
||
995 |
for ($i=0,$bin=0; $bin<$nbins; $bin++) { |
|
996 |
for ($beam=0; $beam<4; $beam++,$i++) { |
|
997 |
${$E}[$ens]->{CORRELATION}[$bin][$beam] = $dta[$i] |
|
998 |
if ($dta[$i]); |
|
999 |
} |
|
1000 |
} |
|
1001 |
||
1002 |
#-------------------- |
|
1003 |
# Echo Intensity Data |
|
1004 |
#-------------------- |
|
1005 |
||
48
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
1006 |
my($echo_di) = WBRdtaIndex(0x0300); |
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
1007 |
die("no echo intensity data in ensemble #$ensNo\n") |
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
1008 |
unless defined($echo_di); |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
1009 |
|
48
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
1010 |
sysseek(WBRF,$start_ens+$WBRofs[$echo_di],0) || die("$WBRcfn: $!"); |
14 | 1011 |
sysread(WBRF,$buf,2+$ndata) == 2+$ndata || die("$WBRcfn: $!"); |
1012 |
($id,@dta) = unpack("vC$ndata",$buf); |
|
1013 |
||
1014 |
$id == 0x0300 || |
|
37 | 1015 |
die(sprintf($FmtErr,$WBRcfn,"Echo Intensity",$id,$ensNo)); |
14 | 1016 |
|
1017 |
for ($i=0,$bin=0; $bin<$nbins; $bin++) { |
|
1018 |
for ($beam=0; $beam<4; $beam++,$i++) { |
|
1019 |
${$E}[$ens]->{ECHO_AMPLITUDE}[$bin][$beam] = $dta[$i]; |
|
1020 |
} |
|
1021 |
} |
|
1022 |
||
1023 |
#-------------------- |
|
1024 |
# Percent Good Data |
|
1025 |
#-------------------- |
|
1026 |
||
48
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
1027 |
my($pctg_di) = WBRdtaIndex(0x0400); |
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
1028 |
die("no percent good data in ensemble #$ensNo\n") |
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
1029 |
unless defined($pctg_di); |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
1030 |
|
48
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
1031 |
sysseek(WBRF,$start_ens+$WBRofs[$pctg_di],0) || die("$WBRcfn: $!"); |
14 | 1032 |
sysread(WBRF,$buf,2+$ndata) == 2+$ndata || die("$WBRcfn: $!"); |
1033 |
($id,@dta) = unpack("vC$ndata",$buf); |
|
1034 |
||
1035 |
$id == 0x0400 || |
|
37 | 1036 |
die(sprintf($FmtErr,$WBRcfn,"Percent-Good Data",$id,$ensNo)); |
14 | 1037 |
|
1038 |
for ($i=0,$bin=0; $bin<$nbins; $bin++) { |
|
1039 |
for ($beam=0; $beam<4; $beam++,$i++) { |
|
1040 |
${$E}[$ens]->{PERCENT_GOOD}[$bin][$beam] = $dta[$i]; |
|
1041 |
} |
|
1042 |
} |
|
1043 |
||
18 | 1044 |
#----------------------------------------- |
14 | 1045 |
# Bottom-Track Data |
18 | 1046 |
# - scan through remaining data types |
1047 |
#----------------------------------------- |
|
14 | 1048 |
|
48
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
1049 |
my($bt_di) = WBRdtaIndex(0x0600); |
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
1050 |
unless (defined($pctg_di)) { # no BT found => next ens |
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1051 |
sysseek(WBRF,$start_ens+$ens_length+2,0) || die("$WBRcfn: $!"); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1052 |
next; |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
1053 |
} |
18 | 1054 |
|
32 | 1055 |
sysseek(WBRF,14,1) || die("$WBRcfn: $!"); # BT range, velocity, corr, %-good, ... |
18 | 1056 |
sysread(WBRF,$buf,28) == 28 || die("$WBRcfn: $!"); |
1057 |
@dta = unpack('v4v4C4C4C4',$buf); |
|
1058 |
for ($beam=0; $beam<4; $beam++) { |
|
32 | 1059 |
${$E}[$ens]->{BT_RANGE}[$beam] = $dta[$beam] / 100 # lower 2 bytes only! |
1060 |
if ($dta[$beam]); # (see below for high bytes) |
|
18 | 1061 |
} |
1062 |
for ($beam=0; $beam<4; $beam++) { |
|
1063 |
${$E}[$ens]->{BT_VELOCITY}[$beam] = |
|
1064 |
unpack('s',pack('S',$dta[4+$beam])) / 1000 |
|
1065 |
if ($dta[4+$beam] != 0x8000); |
|
1066 |
} |
|
1067 |
for ($beam=0; $beam<4; $beam++) { |
|
1068 |
${$E}[$ens]->{BT_CORRELATION}[$beam] = $dta[8+$beam] |
|
1069 |
if ($dta[8+$beam]); |
|
1070 |
} |
|
32 | 1071 |
for ($beam=0; $beam<4; $beam++) { # BT filter parameter |
18 | 1072 |
${$E}[$ens]->{BT_EVAL_AMPLITUDE}[$beam] = $dta[12+$beam]; |
1073 |
} |
|
1074 |
for ($beam=0; $beam<4; $beam++) { |
|
1075 |
${$E}[$ens]->{BT_PERCENT_GOOD}[$beam] = $dta[16+$beam]; |
|
1076 |
} |
|
1077 |
||
32 | 1078 |
sysseek(WBRF,6,1) || die("$WBRcfn: $!"); # BT ref level stuff |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
1079 |
if (sysread(WBRF,$buf,20) != 20) { # EN642/PITA1 |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
1080 |
pop(@{$E}); |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
1081 |
last; |
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
1082 |
} |
18 | 1083 |
@dta = unpack('v4C4C4C4',$buf); |
1084 |
for ($beam=0; $beam<4; $beam++) { |
|
1085 |
${$E}[$ens]->{BT_RL_VELOCITY}[$beam] = |
|
1086 |
unpack('s',pack('S',$dta[$beam])) / 1000 |
|
1087 |
if ($dta[$beam] != 0x8000); |
|
1088 |
} |
|
1089 |
for ($beam=0; $beam<4; $beam++) { |
|
1090 |
${$E}[$ens]->{BT_RL_CORRELATION}[$beam] = $dta[4+$beam] |
|
1091 |
if ($dta[4+$beam]); |
|
1092 |
} |
|
1093 |
for ($beam=0; $beam<4; $beam++) { |
|
1094 |
${$E}[$ens]->{BT_RL_ECHO_AMPLITUDE}[$beam] = $dta[8+$beam]; |
|
1095 |
} |
|
1096 |
for ($beam=0; $beam<4; $beam++) { |
|
1097 |
${$E}[$ens]->{BT_RL_PERCENT_GOOD}[$beam] = $dta[12+$beam]; |
|
1098 |
} |
|
1099 |
||
32 | 1100 |
sysseek(WBRF,2,1) || die("$WBRcfn: $!"); # BT signal strength & BT range high bytes |
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1101 |
# sysread(WBRF,$buf,9) == 9 || die("$WBRcfn: $!"); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1102 |
if (sysread(WBRF,$buf,9) == 9) { # SR1b JR16 BB150 data files require this |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1103 |
@dta = unpack('C4CC4',$buf); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1104 |
for ($beam=0; $beam<4; $beam++) { |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1105 |
${$E}[$ens]->{BT_SIGNAL_STRENGTH}[$beam] = $dta[$beam]; |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1106 |
} |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1107 |
${$E}[$ens]->{HIGH_GAIN} if ($dta[4]); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1108 |
${$E}[$ens]->{LOW_GAIN} unless ($dta[4]); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1109 |
for ($beam=0; $beam<4; $beam++) { # high bytes (1 byte per beam) |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1110 |
${$E}[$ens]->{BT_RANGE}[$beam] += $dta[5+$beam] * 655.36 |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1111 |
if ($dta[5+$beam]); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1112 |
} |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1113 |
# sysseek(WBRF,8,1) || die("$WBRcfn: $!"); # remainder of ensemble |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1114 |
} |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1115 |
sysseek(WBRF,$start_ens+$ens_length+2,0) || die("$WBRcfn: $!"); |
14 | 1116 |
} # ens loop |
51
148c092b3a09
after somewhat suspicous RDI_PD0_IO.pl merge and just before adding
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
50
diff
changeset
|
1117 |
print(STDERR "\n") if ($RDI_PD0_IO::show_progress); |
14 | 1118 |
} |
1119 |
||
48
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
1120 |
sub WBRdtaIndex($) |
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
1121 |
{ |
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
1122 |
my($trgid) = @_; |
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
1123 |
our($ndt,$buf,$id,$start_ens,@WBRofs); |
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
1124 |
|
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
1125 |
for (my($di)=2; $di<$ndt; $di++) { |
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
1126 |
sysseek(WBRF,$start_ens+$WBRofs[$di],0) || die("$WBRcfn: $!"); |
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
1127 |
sysread(WBRF,$buf,2) == 2 || die("$WBRcfn: $!"); |
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
1128 |
$id = unpack('v',$buf); |
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
1129 |
return $di if ($id == $trgid); |
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
1130 |
} |
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
1131 |
return undef; |
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
1132 |
} |
cdc74ebada81
after partial adaptation to RTI files
Andreas Thurnherr <ant@ldeo.columbia.edu>
parents:
45
diff
changeset
|
1133 |
|
14 | 1134 |
#---------------------------------------------------------------------- |
28 | 1135 |
# writeData(output_file_name,^data) WBPens(nbins,fixed_leader_bytes,^data) |
1136 |
# - writeData() copies file previously read with readData() to output_file_name |
|
1137 |
# - WBPens() patches new PD0 file with ^data |
|
1138 |
# - ^data is modified!!!! |
|
1139 |
# - output file must already exist and have correct structure |
|
1140 |
# - only subset of data structure is patched: |
|
1141 |
# - Header: Data Source Id |
|
1142 |
# - Var Ldr: Soundspeed, Depth, Heading, Pitch, Roll, Temp, Salin |
|
1143 |
# - Data: Velocity, Correlation, Echo Amp, %-Good, |
|
14 | 1144 |
#---------------------------------------------------------------------- |
1145 |
||
1146 |
sub writeData(@) |
|
1147 |
{ |
|
1148 |
my($fn,$dta) = @_; |
|
1149 |
||
50 | 1150 |
die("writeData() needs \$WBRcfn from previous readData()\n") |
31 | 1151 |
unless (length($WBRcfn) > 0); |
50 | 1152 |
die("writeData() only works with clean PD0 files\n") |
1153 |
if ($RDI_PD0_IO::File_Dirty); |
|
31 | 1154 |
|
1155 |
sysseek(WBRF,0,0) || die("$WBRcfn: $!"); # rewind input file |
|
1156 |
$WBPcfn = $fn; # set patch file name for error messages |
|
1157 |
open(WBPF,"+>$WBPcfn") || die("$WBPcfn: $!"); # open patch file for r/w |
|
14 | 1158 |
|
31 | 1159 |
while (1) { # copy input file to patch file |
1160 |
my($buf); |
|
1161 |
my($nread) = sysread(WBRF,$buf,100*1024); |
|
1162 |
die("$WBRcfn: $!\n") if ($nread < 0); |
|
1163 |
last if ($nread == 0); |
|
1164 |
my($nwritten) = syswrite(WBPF,$buf,100*1024); |
|
1165 |
die("$WBPcfn: $! ($nwritten of $nread written)\n") |
|
1166 |
unless ($nwritten = $nread); |
|
1167 |
} |
|
1168 |
sysseek(WBPF,0,0) || die("$WBPcfn: $!"); # rewind patch file |
|
1169 |
||
1170 |
WBPens($dta->{N_BINS},$dta->{FIXED_LEADER_BYTES},$dta); |
|
14 | 1171 |
} |
1172 |
||
37 | 1173 |
sub _round(@) |
28 | 1174 |
{ |
1175 |
return $_[0] >= 0 ? int($_[0] + 0.5) |
|
1176 |
: int($_[0] - 0.5); |
|
1177 |
} |
|
1178 |
||
1179 |
||
14 | 1180 |
sub WBPens($$$) |
1181 |
{ |
|
31 | 1182 |
my($nbins,$fixed_leader_bytes,$dta) = @_; |
14 | 1183 |
my($start_ens,$B1,$B2,$B3,$B4,$I,$id,$bin,$beam,$buf,$dummy,@dta,$i,$cs,@WBPofs); |
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1184 |
my($ens,$dayStart,$ens_length,$hid,$ndt,$el); |
14 | 1185 |
|
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1186 |
# for ($ens=$start_ens=0; $ens<=$#{$dta->{ENSEMBLE}}; $ens++,$start_ens+=$ens_length+2) { |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1187 |
for ($ens=0; $ens<=$#{$dta->{ENSEMBLE}}; $ens++) { |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1188 |
$start_ens = goto_next_ens(\*WBPF); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1189 |
die("ens = $ens\n") unless defined($start_ens); |
14 | 1190 |
|
18 | 1191 |
#------------------------------ |
1192 |
# Patch Header (Data Source Id) |
|
1193 |
#------------------------------ |
|
14 | 1194 |
|
1195 |
sysseek(WBPF,$start_ens,0) || die("$WBPcfn: $!"); |
|
18 | 1196 |
sysread(WBPF,$buf,1) || die("$WBPcfn: unexpected EOF"); |
1197 |
($hid) = unpack('C',$buf); |
|
1198 |
$hid == 0x7f || die(sprintf($FmtErr,$WBPcfn,"Header",$hid,$ens)); |
|
1199 |
||
31 | 1200 |
$buf = pack('C',$dta->{ENSEMBLE}[$ens]->{DATA_SOURCE_ID}); |
18 | 1201 |
my($nw) = syswrite(WBPF,$buf,1); |
1202 |
$nw == 1 || die("$WBPcfn: $nw bytes written ($!)"); |
|
1203 |
||
1204 |
sysread(WBPF,$buf,4) == 4 || die("$WBPcfn: unexpected EOF"); |
|
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1205 |
($el,$dummy,$ndt) = unpack('vCC',$buf); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1206 |
$ens--,next if (defined($ens_length) && ($el != $ens_length)); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1207 |
$ens_length = $el; |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1208 |
|
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1209 |
printf(STDERR "$WBPcfn: WARNING: unexpected number of data types (%d, ens=$ens)\n",$ndt),last |
14 | 1210 |
unless ($ndt == 6 || $ndt == 7); |
18 | 1211 |
|
14 | 1212 |
sysread(WBPF,$buf,2*$ndt) == 2*$ndt || die("$WBPcfn: $!"); |
1213 |
@WBPofs = unpack("v$ndt",$buf); |
|
1214 |
$fixed_leader_bytes = $WBPofs[1] - $WBPofs[0]; |
|
31 | 1215 |
|
1216 |
#-------------------- |
|
1217 |
# Fixed Leader |
|
1218 |
#-------------------- |
|
14 | 1219 |
|
32 | 1220 |
sysseek(WBPF,$start_ens+$WBPofs[0]+4,0) # system config (transducer orientation) |
1221 |
|| die("$WBPcfn: $!"); |
|
1222 |
sysread(WBPF,$buf,1) == 1 || die("$WBPcfn: $!"); |
|
1223 |
$B1 = unpack('C',$buf); |
|
1224 |
$B1 |= 0x80 if ($dta->{ENSEMBLE}[$ens]->{XDUCER_FACING_UP}); |
|
1225 |
$B1 &= 0x7F if ($dta->{ENSEMBLE}[$ens]->{XDUCER_FACING_DOWN}); |
|
1226 |
$buf = pack('C',$B1); |
|
1227 |
sysseek(WBPF,$start_ens+$WBPofs[0]+4,0) |
|
1228 |
|| die("$WBPcfn: $!"); |
|
1229 |
syswrite(WBPF,$buf,1) == 1 || die("$WBPcfn: $!"); |
|
1230 |
||
1231 |
sysseek(WBPF,$start_ens+$WBPofs[0]+25,0) || die("$WBPcfn: $!"); # EX / coord-transformation |
|
31 | 1232 |
sysread(WBPF,$buf,1) == 1 || die("$WBPcfn: $!"); |
1233 |
my($EX) = unpack('C',$buf); |
|
1234 |
if ($dta->{BEAM_COORDINATES}) { |
|
1235 |
$EX &= ~0x18; |
|
1236 |
} elsif ($dta->{EARTH_COORDINATES}) { |
|
1237 |
$EX |= 0x18; |
|
1238 |
} else { |
|
1239 |
die("$WBPcfn: only beam- and earth coordinates are supported (implementation restriction)\n"); |
|
1240 |
} |
|
1241 |
$buf = pack('C',$EX); |
|
1242 |
sysseek(WBPF,$start_ens+$WBPofs[0]+25,0) || die("$WBPcfn: $!"); |
|
1243 |
syswrite(WBPF,$buf,1) == 1 || die("$WBPcfn: $!"); |
|
1244 |
||
42 | 1245 |
#---------------------------------------------------------------------- |
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1246 |
# Variable Leader #0 |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1247 |
# - read ensNo for debugging purposes |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1248 |
#---------------------------------------------------------------------- |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1249 |
|
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1250 |
sysseek(WBPF,$start_ens+$WBPofs[1]+2,0) || die("$WBPcfn: $!"); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1251 |
sysread(WBPF,$buf,2) == 2 || die("$WBPcfn: $!"); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1252 |
my($ensNo) = unpack("v",$buf); # only lower two bytes!!! |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1253 |
sysseek(WBPF,$start_ens+$WBPofs[1]+13,0) || die("$WBPcfn: $!"); # jump to high byte |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1254 |
sysread(WBPF,$buf,1) == 1 || die("$WBPcfn: $!"); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1255 |
$ensNo += unpack('C',$buf) << 16; |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1256 |
die("ensNo = $ensNo (should be $dta->{ENSEMBLE}[$ens]->{NUMBER})\n") |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1257 |
unless ($ensNo == $dta->{ENSEMBLE}[$ens]->{NUMBER}); |
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1258 |
|
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1259 |
#---------------------------------------------------------------------- |
42 | 1260 |
# Variable Leader #1 |
1261 |
# - if $RDI_PD0_IO::OVERRIDE_Y2K_CLOCK is set, the data from the pre-Y2K |
|
1262 |
# clock are used to override the ADCP clock values; this allows |
|
1263 |
# a better time to be recorded by the data acquisition system |
|
1264 |
# without overwriting the main instrument clock data |
|
1265 |
#---------------------------------------------------------------------- |
|
31 | 1266 |
|
42 | 1267 |
if ($RDI_PD0_IO::OVERRIDE_Y2K_CLOCK) { |
1268 |
sysseek(WBPF,$start_ens+$WBPofs[1]+4,0) || die("$WBPcfn: $!"); # jump to RTC_YEAR |
|
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1269 |
sysread(WBPF,$buf,7) == 7 || die("$WBPcfn: $!"); # read pre-Y2K clock |
42 | 1270 |
($dta->{ENSEMBLE}[$ens]->{YEAR}, |
1271 |
$dta->{ENSEMBLE}[$ens]->{MONTH}, |
|
1272 |
$dta->{ENSEMBLE}[$ens]->{DAY}, |
|
1273 |
$dta->{ENSEMBLE}[$ens]->{HOUR}, |
|
1274 |
$dta->{ENSEMBLE}[$ens]->{MINUTE}, |
|
50 | 1275 |
$dta->{ENSEMBLE}[$ens]->{SECOND},$B4) = |
42 | 1276 |
unpack('CCCCCCC',$buf); |
50 | 1277 |
$dta->{ENSEMBLE}[$ens]->{SECOND} += $B4/100; |
42 | 1278 |
$dta->{ENSEMBLE}[$ens]->{YEAR} += ($dta->{ENSEMBLE}[$ens]->{YEAR} > 80) ? 1900 : 2000; |
1279 |
} |
|
1280 |
||
1281 |
#---------------------------------------------------------------------- |
|
1282 |
# Variable Leader #2 |
|
43
b63fa355644c
commit to merge with changes from EN620
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
42
diff
changeset
|
1283 |
# - read ensemble number for debugging purposes |
42 | 1284 |
# - patch everything from SPEED_OF_SOUND to TEMPERATURE |
1285 |
# - at one stage, IMP allowed for missing values in pitch/roll and heading; |
|
1286 |
# on 12/23/2017 the corresponding code was disabled (replaced by assertion) |
|
1287 |
#---------------------------------------------------------------------- |
|
1288 |
||
1289 |
sysseek(WBPF,$start_ens+$WBPofs[1]+14,0) || die("$WBPcfn: $!"); # jump to SPEED_OF_SOUND |
|
14 | 1290 |
|
37 | 1291 |
$dta->{ENSEMBLE}[$ens]->{XDUCER_DEPTH} = _round($dta->{ENSEMBLE}[$ens]->{XDUCER_DEPTH}*10); |
18 | 1292 |
|
42 | 1293 |
# $dta->{ENSEMBLE}[$ens]->{HEADING} = defined($dta->{ENSEMBLE}[$ens]->{HEADING}) |
1294 |
# ? _round($dta->{ENSEMBLE}[$ens]->{HEADING}*100) |
|
1295 |
# : 0xF000; |
|
1296 |
# $dta->{ENSEMBLE}[$ens]->{PITCH} = defined($dta->{ENSEMBLE}[$ens]->{PITCH}) |
|
1297 |
# ? unpack('S',pack('s',_round($dta->{ENSEMBLE}[$ens]->{PITCH}*100))) |
|
1298 |
# : 0x8000; |
|
1299 |
# $dta->{ENSEMBLE}[$ens]->{ROLL} = defined($dta->{ENSEMBLE}[$ens]->{ROLL}) |
|
1300 |
# ? unpack('S',pack('s',_round($dta->{ENSEMBLE}[$ens]->{ROLL}*100))) |
|
1301 |
# : 0x8000; |
|
28 | 1302 |
|
42 | 1303 |
croak("$0: assertion failed") unless defined($dta->{ENSEMBLE}[$ens]->{HEADING}) && |
1304 |
defined($dta->{ENSEMBLE}[$ens]->{PITCH}) && |
|
1305 |
defined($dta->{ENSEMBLE}[$ens]->{ROLL}); |
|
1306 |
$dta->{ENSEMBLE}[$ens]->{HEADING} = _round($dta->{ENSEMBLE}[$ens]->{HEADING}*100); |
|
1307 |
$dta->{ENSEMBLE}[$ens]->{PITCH} = unpack('S',pack('s',_round($dta->{ENSEMBLE}[$ens]->{PITCH}*100))); |
|
1308 |
$dta->{ENSEMBLE}[$ens]->{ROLL} = unpack('S',pack('s',_round($dta->{ENSEMBLE}[$ens]->{ROLL}*100))); |
|
1309 |
$dta->{ENSEMBLE}[$ens]->{TEMPERATURE} = unpack('S',pack('s',_round($dta->{ENSEMBLE}[$ens]->{TEMPERATURE}*100))); |
|
14 | 1310 |
|
1311 |
$buf = pack('vvvvvvv', |
|
31 | 1312 |
$dta->{ENSEMBLE}[$ens]->{SPEED_OF_SOUND}, |
1313 |
$dta->{ENSEMBLE}[$ens]->{XDUCER_DEPTH},$dta->{ENSEMBLE}[$ens]->{HEADING}, |
|
1314 |
$dta->{ENSEMBLE}[$ens]->{PITCH},$dta->{ENSEMBLE}[$ens]->{ROLL}, |
|
1315 |
$dta->{ENSEMBLE}[$ens]->{SALINITY},$dta->{ENSEMBLE}[$ens]->{TEMPERATURE}); |
|
14 | 1316 |
|
1317 |
my($nw) = syswrite(WBPF,$buf,14); |
|
1318 |
$nw == 14 || die("$WBPcfn: $nw bytes written ($!)"); |
|
1319 |
||
28 | 1320 |
|
42 | 1321 |
#---------------------------------------------------------------------- |
1322 |
# Variable Leader #3 |
|
1323 |
# - patch Y2K RTC |
|
1324 |
#---------------------------------------------------------------------- |
|
1325 |
||
1326 |
sysseek(WBPF,$start_ens+$WBPofs[1]+57,0) || die("$WBPcfn: $!"); # jump to RTC_CENTURY |
|
1327 |
||
1328 |
my($century) = int($dta->{ENSEMBLE}[$ens]->{YEAR} / 100); |
|
1329 |
my($year) = $dta->{ENSEMBLE}[$ens]->{YEAR} % 100; |
|
50 | 1330 |
my($seconds) = int($dta->{ENSEMBLE}[$ens]->{SECOND}); |
1331 |
my($hundredths) = 100 * ($dta->{ENSEMBLE}[$ens]->{SECOND} - $seconds); |
|
42 | 1332 |
$buf = pack('CCCCCCCC',$century,$year,$dta->{ENSEMBLE}[$ens]->{MONTH}, |
1333 |
$dta->{ENSEMBLE}[$ens]->{DAY},$dta->{ENSEMBLE}[$ens]->{HOUR}, |
|
1334 |
$dta->{ENSEMBLE}[$ens]->{MINUTE},$seconds,$hundredths); |
|
1335 |
my($nw) = syswrite(WBPF,$buf,8); |
|
1336 |
$nw == 8 || die("$WBPcfn: $nw bytes written ($!)"); |
|
1337 |
||
28 | 1338 |
#-------------------- |
1339 |
# Velocity Data |
|
1340 |
#-------------------- |
|
1341 |
||
32 | 1342 |
sysseek(WBPF,$start_ens+$WBPofs[2]+2,0) || die("$WBPcfn: $!"); # skip velocity data id (assume it is correct) |
28 | 1343 |
for ($bin=0; $bin<$nbins; $bin++) { |
1344 |
for ($beam=0; $beam<4; $beam++) { |
|
31 | 1345 |
$dta->{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$beam] = defined($dta->{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$beam]) |
37 | 1346 |
? _round($dta->{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$beam]*1000) |
28 | 1347 |
: 0x8000; |
31 | 1348 |
$buf = pack('v',unpack('S',pack('s',$dta->{ENSEMBLE}[$ens]->{VELOCITY}[$bin][$beam]))); |
28 | 1349 |
my($nw) = syswrite(WBPF,$buf,2); |
1350 |
$nw == 2 || die("$WBPcfn: $nw bytes written ($!)"); |
|
1351 |
} |
|
1352 |
} |
|
1353 |
||
1354 |
#-------------------- |
|
1355 |
# Correlation Data |
|
1356 |
#-------------------- |
|
1357 |
||
32 | 1358 |
sysseek(WBPF,$start_ens+$WBPofs[3]+2,0) || die("$WBPcfn: $!"); |
28 | 1359 |
for ($bin=0; $bin<$nbins; $bin++) { |
1360 |
for ($beam=0; $beam<4; $beam++) { |
|
31 | 1361 |
$buf = pack('C',$dta->{ENSEMBLE}[$ens]->{CORRELATION}[$bin][$beam]); |
28 | 1362 |
my($nw) = syswrite(WBPF,$buf,1); |
1363 |
$nw == 1 || die("$WBPcfn: $nw bytes written ($!)"); |
|
1364 |
} |
|
1365 |
} |
|
1366 |
||
1367 |
#-------------------- |
|
1368 |
# Echo Intensity Data |
|
1369 |
#-------------------- |
|
1370 |
||
32 | 1371 |
sysseek(WBPF,$start_ens+$WBPofs[4]+2,0) || die("$WBPcfn: $!"); |
28 | 1372 |
|
1373 |
for ($bin=0; $bin<$nbins; $bin++) { |
|
1374 |
for ($beam=0; $beam<4; $beam++) { |
|
31 | 1375 |
$buf = pack('C',$dta->{ENSEMBLE}[$ens]->{ECHO_AMPLITUDE}[$bin][$beam]); |
28 | 1376 |
my($nw) = syswrite(WBPF,$buf,1); |
1377 |
$nw == 1 || die("$WBPcfn: $nw bytes written ($!)"); |
|
1378 |
} |
|
1379 |
} |
|
1380 |
||
1381 |
#-------------------- |
|
1382 |
# Percent Good Data |
|
1383 |
#-------------------- |
|
1384 |
||
32 | 1385 |
sysseek(WBPF,$start_ens+$WBPofs[5]+2,0) || die("$WBPcfn: $!"); |
28 | 1386 |
|
1387 |
for ($i=0,$bin=0; $bin<$nbins; $bin++) { |
|
1388 |
for ($beam=0; $beam<4; $beam++,$i++) { |
|
31 | 1389 |
$buf = pack('C',$dta->{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$bin][$beam]); |
28 | 1390 |
my($nw) = syswrite(WBPF,$buf,1); |
1391 |
$nw == 1 || die("$WBPcfn: $nw bytes written ($!)"); |
|
1392 |
} |
|
1393 |
} |
|
1394 |
||
1395 |
#----------------------------------------- |
|
1396 |
# Bottom-Track Data |
|
1397 |
# - scan through remaining data types |
|
1398 |
#----------------------------------------- |
|
1399 |
||
1400 |
my($nxt); |
|
1401 |
for ($nxt=6; $nxt<$ndt; $nxt++) { # scan until BT found |
|
32 | 1402 |
sysseek(WBPF,$start_ens+$WBPofs[$nxt],0) || die("$WBPcfn: $!"); |
36
515b06dae59c
version at end of ECOGIG EN586 cruise
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
32
diff
changeset
|
1403 |
sysread(WBPF,$buf,2) == 2 || die("$WBPcfn: $! [ens=$ens]"); |
28 | 1404 |
$id = unpack('v',$buf); |
1405 |
last if ($id == 0x0600); |
|
1406 |
} |
|
1407 |
||
1408 |
unless ($nxt == $ndt) { # BT found |
|
32 | 1409 |
sysseek(WBPF,14,1) || die("$WBPcfn: $!"); # skip BT config |
1410 |
for ($beam=0; $beam<4; $beam++) { # BT range low bytes (2 per beam) |
|
37 | 1411 |
$buf = pack('v',_round($dta->{ENSEMBLE}[$ens]->{BT_RANGE}[$beam] * 100) & 0xFFFF); |
32 | 1412 |
my($nw) = syswrite(WBPF,$buf,2); |
1413 |
$nw == 2 || die("$WBPcfn: $nw bytes written ($!)"); |
|
1414 |
} |
|
1415 |
||
1416 |
for ($beam=0; $beam<4; $beam++) { # BT velocities |
|
1417 |
$buf = pack('v',unpack('S',pack('s', |
|
1418 |
defined($dta->{ENSEMBLE}[$ens]->{BT_VELOCITY}[$beam]) |
|
37 | 1419 |
? _round($dta->{ENSEMBLE}[$ens]->{BT_VELOCITY}[$beam]*1000) |
32 | 1420 |
: 0x8000))); |
1421 |
my($nw) = syswrite(WBPF,$buf,2); |
|
1422 |
$nw == 2 || die("$WBPcfn: $nw bytes written ($!)"); |
|
1423 |
} |
|
1424 |
||
1425 |
for ($beam=0; $beam<4; $beam++) { # BT correlation |
|
1426 |
$buf = pack('C',$dta->{ENSEMBLE}[$ens]->{BT_CORRELATION}[$beam]); |
|
1427 |
my($nw) = syswrite(WBPF,$buf,1); |
|
1428 |
$nw == 1 || die("$WBPcfn: $nw bytes written ($!)"); |
|
1429 |
} |
|
1430 |
||
1431 |
for ($beam=0; $beam<4; $beam++) { # BT evaluation amp of matching filter |
|
1432 |
$buf = pack('C',$dta->{ENSEMBLE}[$ens]->{BT_EVAL_AMPLITUDE}[$beam]); |
|
1433 |
my($nw) = syswrite(WBPF,$buf,1); |
|
1434 |
$nw == 1 || die("$WBPcfn: $nw bytes written ($!)"); |
|
1435 |
} |
|
1436 |
||
1437 |
for ($beam=0; $beam<4; $beam++) { # BT percent good |
|
1438 |
$buf = pack('C',$dta->{ENSEMBLE}[$ens]->{BT_PERCENT_GOOD}[$beam]); |
|
1439 |
my($nw) = syswrite(WBPF,$buf,1); |
|
1440 |
$nw == 1 || die("$WBPcfn: $nw bytes written ($!)"); |
|
1441 |
} |
|
28 | 1442 |
|
32 | 1443 |
sysseek(WBPF,33,1) || die("$WBPcfn: $!"); # BT range high bytes (1 per beam) |
1444 |
for ($beam=0; $beam<4; $beam++) { |
|
37 | 1445 |
$buf = pack('C',(_round($dta->{ENSEMBLE}[$ens]->{BT_RANGE}[$beam]*100) & 0xFF0000) >> 16); |
32 | 1446 |
my($nw) = syswrite(WBPF,$buf,1); |
1447 |
$nw == 1 || die("$WBPcfn: $nw bytes written ($!)"); |
|
1448 |
} |
|
1449 |
||
1450 |
} # if BT found |
|
28 | 1451 |
|
14 | 1452 |
#---------------- |
1453 |
# Update Checksum |
|
1454 |
#---------------- |
|
1455 |
||
1456 |
sysseek(WBPF,$start_ens,0) || die("$WBPcfn: $!"); |
|
1457 |
sysread(WBPF,$buf,$ens_length) == $ens_length || die("$WBPcfn: $!"); |
|
1458 |
$cs = unpack('%16C*',$buf); |
|
1459 |
$buf = pack('v',$cs); |
|
1460 |
$nw = syswrite(WBPF,$buf,2); |
|
1461 |
$nw == 2 || die("$WBPcfn: $nw bytes written, ens=$ens ($!)"); |
|
1462 |
||
1463 |
} # ens loop |
|
1464 |
} |
|
1465 |
||
37 | 1466 |
#---------------------------------------------------------------------- |
1467 |
# &clearEns(^data,ens-index) |
|
1468 |
# - undefine all velocities in ensemble, including BT |
|
1469 |
# - this is required for the LDEO_IX software, |
|
1470 |
# which does not recognize missing attitude values |
|
1471 |
# - set percent good to zero |
|
1472 |
# - this is done for consistency |
|
1473 |
# - DO NOT undef heading, pitch and roll |
|
1474 |
# - the LDEO software does not recognize missing attitude vals |
|
1475 |
# and, therefore, misinterprets those |
|
1476 |
# - while this should not matter because all the velocities are |
|
1477 |
# also deleted, it was found that setting only the heading to |
|
1478 |
# undef'd and leaving pitch and roll unchanged causes |
|
1479 |
# significant errors in GPS velocity referencing! This |
|
1480 |
# must be a bug |
|
1481 |
# - also, if attitudes are undef'd the LDEO software |
|
1482 |
# cannto determine the instrument offset from pitch/roll |
|
1483 |
# and the pitch/roll DL vs UL plots are bogus |
|
1484 |
#---------------------------------------------------------------------- |
|
1485 |
||
1486 |
sub clearEns($$) |
|
1487 |
{ |
|
1488 |
my($dta,$ens) = @_; |
|
39 | 1489 |
die("clearEns: ens-index $ens out of range\n") |
37 | 1490 |
unless ($ens>=0 && $ens<=$#{$dta->{ENSEMBLE}}); |
1491 |
for (my($bin)=0; $bin<$dta->{N_BINS}; $bin++) { |
|
1492 |
undef(@{$dta->{ENSEMBLE}[$ens]->{VELOCITY}[$bin]}); |
|
1493 |
@{$dta->{ENSEMBLE}[$ens]->{PERCENT_GOOD}[$bin]} = (0,0,0,0); |
|
1494 |
} |
|
1495 |
undef(@{$dta->{ENSEMBLE}[$ens]->{BT_VELOCITY}}); |
|
1496 |
@{$dta->{ENSEMBLE}[$ens]->{BT_PERCENT_GOOD}} = (0,0,0,0); |
|
1497 |
# undef($dta->{ENSEMBLE}[$ens]->{HEADING}); |
|
1498 |
# undef($dta->{ENSEMBLE}[$ens]->{PITCH}); |
|
1499 |
# undef($dta->{ENSEMBLE}[$ens]->{ROLL}); |
|
1500 |
} |
|
1501 |
||
14 | 1502 |
1; # return true for all the world to see |