Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed reshape bug in pad_shorter_ping and added test for EK80 missing receiver_sampling_freq error [all tests ci] #1234

Merged
merged 6 commits into from
Dec 3, 2023
Merged
10 changes: 8 additions & 2 deletions echopype/convert/parse_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,14 @@ def pad_shorter_ping(data_list) -> np.ndarray:
lens = np.array([len(item) for item in data_list])
if np.unique(lens).size != 1: # if some pings have different lengths along range
if data_list[0].ndim == 2:
# Angle data have an extra dimension for alongship and athwartship samples
mask = lens[:, None, None] > np.array([np.arange(lens.max())] * 2).T
# Data may have an extra dimension:
# - Angle data have an extra dimension for alongship and athwartship samples
# - Complex data have an extra dimension for different transducer sectors
mask = (
lens[:, None, None]
> np.array([np.arange(lens.max())] * data_list[0].shape[1]).T
)

else:
mask = lens[:, None] > np.arange(lens.max())

Expand Down
19 changes: 18 additions & 1 deletion echopype/tests/calibrate/test_calibrate_ek80.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,21 @@ def test_ek80_BB_power_echoview(ek80_path):
ev_vals = df_real.values[:, :]
ep_vals = pc_mean.values.real[:, :]
assert np.allclose(ev_vals[:, 69:8284], ep_vals[:, 69:], atol=1e-4)
assert np.allclose(ev_vals[:, 90:8284], ep_vals[:, 90:], atol=1e-5)
assert np.allclose(ev_vals[:, 90:8284], ep_vals[:, 90:], atol=1e-5)


def test_ek80_CW_complex_Sv_receiver_sampling_freq(ek80_path):
ek80_raw_path = str(ek80_path.joinpath("D20230804-T083032.raw"))
ed = ep.open_raw(ek80_raw_path, sonar_model="EK80")
# Parsed receiver_sampling_frequency is 0
assert ed["Vendor_specific"]["receiver_sampling_frequency"] == 0
# Calibration object
waveform_mode = "CW"
encode_mode = "complex"
ds_Sv = ep.calibrate.compute_Sv(
ed, waveform_mode=waveform_mode, encode_mode=encode_mode
)

# receiver_sampling_frequency substituted with default value in compute_Sv
assert ds_Sv["receiver_sampling_frequency"] is not None
assert np.allclose(ds_Sv["receiver_sampling_frequency"].data, 1500000)
praneethratna marked this conversation as resolved.
Show resolved Hide resolved