Skip to content

Problem reading RDI Pinnacle 45 burst data with read_rdi #408

@stinawahlgren

Description

@stinawahlgren

Describe the bug:

I get the following error message when I try to read a pd0-file from a RDI Pinnacle 45 instrument using read_rdi with mhkit version 0.9.0:

ZeroDivisionError                         Traceback (most recent call last)
Cell In[3], line 1
----> 1 data = read_rdi(file)

File [...]/MHKiT-python/mhkit/dolfyn/io/rdi.py:75, in read_rdi(filename, userdata, nens, debug, vmdas_search, winriver, search_num, **kwargs)
     66 # Reads into a dictionary of dictionaries using netcdf naming conventions
     67 # Should be easier to debug
     68 rdr = _RDIReader(
     69     filename,
     70     debug=debug,
   (...)
     73     search_num=search_num,
     74 )
---> 75 datNB, datBB = rdr.load_data(nens=nens)
     77 dats = [dat for dat in [datNB, datBB] if dat is not None]
     79 # Read in userdata

File [...]/MHKiT-python/mhkit/dolfyn/io/rdi.py:355, in _RDIReader.load_data(self, nens)
    353 for dat, cfg in zip(datl, cfgl):
    354     dat, cfg = self.cleanup(dat, cfg)
--> 355     dat = self.finalize(dat, cfg)
    356     if "vel_bt" in dat["data_vars"]:
    357         cfg["rotate_vars"].append("vel_bt")

File [...]/MHKiT-python/mhkit/dolfyn/io/rdi.py:1047, in _RDIReader.finalize(self, dat, cfg)
   1045     cfg["fs"] = round(1 / np.median(np.diff(dat["coords"]["time"])), 2)
   1046 else:
-> 1047     cfg["fs"] = 1 / (cfg["sec_between_ping_groups"] * cfg["pings_per_ensemble"])
   1049 # Save configuration data as attributes
   1050 dat["attrs"] = cfg

ZeroDivisionError: float division by zero

The data is collected in burst mode and with both water column data and bottom track. The reason for the division-by-zero error is that cfg["sec_between_ping_groups"] is 0.

If I comment out line 1047 in mhkit/dolfyn/io/rdi.py (or use line 1045 instead) the function works and the file is read correctly.

Desktop:

  • MHKiT Version: 0.9.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions