diff --git a/echopype/convert/parse_base.py b/echopype/convert/parse_base.py index 8bd585503..23a08d52f 100644 --- a/echopype/convert/parse_base.py +++ b/echopype/convert/parse_base.py @@ -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()) diff --git a/echopype/tests/calibrate/test_calibrate_ek80.py b/echopype/tests/calibrate/test_calibrate_ek80.py index 8e544b5f5..36fe4ca3a 100644 --- a/echopype/tests/calibrate/test_calibrate_ek80.py +++ b/echopype/tests/calibrate/test_calibrate_ek80.py @@ -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) \ No newline at end of file + 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)