Skip to content

Commit

Permalink
Handle variable bottom track beams_cy
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcvey3 committed Feb 14, 2024
1 parent e45186e commit 39fdf26
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions dolfyn/io/nortek2_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,13 @@ def _check_index(idx, infile, fix_hw_ens=False, dp=False):
# Check if spacing is equal for dual profiling ADCPs
if dp:
skip_size = np.diff(ibad)
avg_skip = np.median(skip_size)
n_skip, count = np.unique(skip_size, return_counts=True)
# If multiple skips are of the same size, assume okay
for n, c in zip(n_skip, count):
if c > 1:
skip_size[skip_size == n] = 0
# assume last "ibad" element is always good for dp's
mask = np.append(skip_size - avg_skip, 0).astype(bool)
mask = np.append(skip_size, 0).astype(bool)
ibad = ibad[mask]
for ib in ibad:
FLAG = True
Expand Down Expand Up @@ -498,13 +502,22 @@ def _calc_config(index):
inds = index['ID'] == id
_config = index['config'][inds]
_beams_cy = index['beams_cy'][inds]

# Check that these variables are consistent
if not _isuniform(_config):
raise Exception("config are not identical for id: 0x{:X}."
.format(id))
if not _isuniform(_beams_cy):
raise Exception("beams_cy are not identical for id: 0x{:X}."
.format(id))
err = True
if id == 23:
# change in "n_cells" doesn't matter
lob = np.unique(_beams_cy)
beams = list(map(_beams_cy_int2dict, lob, 23 * np.ones(lob.size)))
if all([d['cy'] for d in beams]) and all([d['n_beams'] for d in beams]):
err = False
if err:
raise Exception("beams_cy are not identical for id: 0x{:X}.".format(id))

# Now that we've confirmed they are the same:
config[id] = _headconfig_int2dict(_config[0], mode=type)
config[id].update(_beams_cy_int2dict(_beams_cy[0], id))
Expand Down

0 comments on commit 39fdf26

Please sign in to comment.