Closed hevgyrt closed 5 months ago
Hey @hevgyrt thank you for your interest in MHKiT and bringing the issue to our attention. It looks like @jmcvey3 has assigned himself to address this and hopefully can get a resolution for you to try soon. Thanks James for taking the lead.
Hi @hevgyrt, see if you can pull PR #280 and let me know how that works. It should solve problem 1 listed above, but I wasn't able to replicate problem 2.
Both of these bugs result from how Nortek stores "raw altimeter" data (labeled "ID 26" in their integration docs), which appear to be initial measurements used to figure how far away the water surface is. In the sample file I have, this ID is only stored in ensemble 0; therefore if I start at nens>0, I get an error. For problem 2, it seems that "ID 26" is saved multiple times (at least 11 times in the first 15000 ensembles) in your datafile. The Nortek Signature reader was set up to handle your situation, so I'm not sure what it's getting caught up on.
Affirmed these changes have fixed the bug (https://github.com/lkilcher/dolfyn/issues/122)
Describe the bug:
NOTE: This issue is copied from the dolfyn repo I have the two following issues with regards to using the
nens
argument option in thedolfyn.read
function.To Reproduce:
dat = dolfyn.read('myfile.ad2cp',nens=[3,150])
, I getFile ~/miniconda3/envs/ekok/lib/python3.9/site-packages/dolfyn/io/api.py:103, in read(fname, userdata, nens, kwargs) 99 func_map = dict(RDI=read_rdi, 100 nortek=read_nortek, 101 signature=read_signature) 102 func = func_map[file_type] --> 103 return func(fname, userdata=userdata, nens=nens, kwargs)
File ~/miniconda3/envs/ekok/lib/python3.9/site-packages/dolfyn/io/nortek2.py:67, in read_signature(filename, userdata, nens, rebuild_index, debug, **kwargs) 64 userdata = _find_userdata(filename, userdata) 66 rdr = _Ad2cpReader(filename, rebuild_index=rebuild_index, debug=debug) ---> 67 d = rdr.readfile(nens[0], nens[1]) 68 rdr.sci_data(d) 69 out = _reorg(d)
File ~/miniconda3/envs/ekok/lib/python3.9/site-packages/dolfyn/io/nortek2.py:311, in _Ad2cpReader.readfile(self, ens_start, ens_stop) 307 if sz != rdr._N[tmp_idx]: 308 raise Exception( 309 "The number of samples in this 'Altimeter Raw' " 310 "burst is different from prior bursts.") --> 311 self._read_burst(id, outdat[id], c26) 312 outdat[id]['ensemble'][c26] = c 313 c26 += 1
File ~/miniconda3/envs/ekok/lib/python3.9/site-packages/dolfyn/io/nortek2.py:251, in _Ad2cpReader._read_burst(self, id, dat, c, echo) 249 def _read_burst(self, id, dat, c, echo=False): 250 rdr = self._burst_readers[id] --> 251 rdr.read_into(self.f, dat, c)
File ~/miniconda3/envs/ekok/lib/python3.9/site-packages/dolfyn/io/nortek2_defs.py:79, in _DataDef.read_into(self, fobj, data, ens, cs) 77 for nm, shp, d in zip(self._names, self._shape, dat_tuple): 78 try: ---> 79 data[nm][..., ens] = d 80 except ValueError: 81 data[nm][..., ens] = np.asarray(d).reshape(shp)
IndexError: index 11 is out of bounds for axis 0 with size 11