Skip to content

add_location() fails if times aren't unique #1478

@seagrinch

Description

@seagrinch

I have quite a few EK80 files that appear to have duplicate timestamps. Thus, when I try to run the following...

# Open and convert the raw file
ed = ep.open_raw(os.path.join(raw_file_dir,raw_file), sonar_model='EK80')
ed.to_zarr(save_path=converted_file, overwrite=True)
ed.to_netcdf(save_path=converted_file.replace('.zarr','.nc'), overwrite=True)

# ed = ep.open_converted(converted_file)
# ed = ep.open_converted(converted_file.replace('.zarr','.nc'))

# Calibrate the converted file
ds_Sv = ep.calibrate.compute_Sv(ed, waveform_mode="CW", encode_mode="complex") 
ds_Sv.to_zarr(calibrated_file, mode="w")
ds_Sv.to_netcdf(calibrated_file.replace('.zarr','.nc'), mode="w")

ds_Sv_new = ep.consolidate.add_location(ds_Sv, ed)

I get the following error.

ValueError: The echodata["Platform"]["time1"] array contains duplicate values. Downstream interpolation on the position variables requires unique time values.

I've been able to confirm that there are repeated time steps using...

time_diff = ed['Platform'].time1.diff(dim='time1')
time_diff.plot()
is_unique = ed['Platform'].time1.to_index().is_unique
print(f"Platform.time1 is unique: {is_unique}")

This seems to be an issue with almost every file I've spot checked. Does anyone have suggestions on how to deal with this? Not sure if it's a bug or merely a data cleaning issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions