Skip to content

Commit 7216989

Browse files
committed
Added support for split-beam angle computation with mixed channel beam types in complex mode
1 parent 9f680e0 commit 7216989

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

echopype/consolidate/split_beam_angle.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@
88
import numpy as np
99
import xarray as xr
1010

11+
from ..utils.log import _init_logger
1112
from ..calibrate.ek80_complex import compress_pulse, get_norm_fac, get_transmit_signal
1213

14+
15+
logger = _init_logger(__name__)
16+
1317
# Beam type identifiers
1418
BEAM_TYPE_SPLIT_4_SECTOR = 1 # 4-sector split-beam (common Simrad type)
1519
BEAM_TYPE_SPLIT_3_SECTOR = 17 # 3-sector
@@ -105,7 +109,6 @@ def _compute_angle_from_complex(
105109
raise NotImplementedError
106110

107111
else:
108-
print("beam_type: ", beam_type)
109112
raise ValueError("beam_type not recognized!")
110113

111114
theta = theta / sens[0] - offset[0]
@@ -235,7 +238,7 @@ def get_angle_complex_samples(
235238
beam_type_ch = ds_beam["beam_type"].sel(channel=ch_id).item()
236239

237240
if beam_type_ch not in SUPPORTED_BEAM_TYPES:
238-
print(f"Skipping channel {ch_id}: unsupported beam_type {beam_type_ch}")
241+
logger.warning(f"Skipping channel {ch_id}: unsupported beam_type {beam_type_ch}")
239242
continue
240243

241244
theta_ch, phi_ch = _compute_angle_from_complex(

echopype/tests/consolidate/test_consolidate_integration.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,5 +335,34 @@ def test_add_splitbeam_angle_BB_pc(test_path):
335335
assert np.allclose(pyel_vals, ep_vals, atol=1e-6)
336336

337337

338+
def test_add_splitbeam_angle_partial_valid_channels(test_path):
339+
raw_file = test_path["EK80_CAL"] / "2018115-D20181213-T094600.raw"
340+
ed = ep.open_raw(raw_file, sonar_model="EK80")
341+
342+
# Manually override beam_type for one channel to simulate single-beam
343+
beam_types = ed["Sonar/Beam_group1"]["beam_type"].values
344+
total_channels = beam_types.shape[0]
345+
346+
# Force the first channel to an unsupported beam_type
347+
beam_types[1] = 0
348+
ed["Sonar/Beam_group1"]["beam_type"].data[:] = beam_types
349+
350+
# Compute Sv
351+
ds_Sv = ep.calibrate.compute_Sv(ed, waveform_mode="CW", encode_mode="complex")
352+
353+
# Add split-beam angles
354+
ds_Sv = ep.consolidate.add_splitbeam_angle(source_Sv=ds_Sv, echodata=ed, waveform_mode="CW",
355+
encode_mode="complex", pulse_compression=False, to_disk=False)
356+
357+
valid_angle_channels = [
358+
ch for ch in ds_Sv.channel.values
359+
if not np.all(np.isnan(ds_Sv["angle_alongship"].sel(channel=ch)))
360+
]
361+
362+
# Verify angles exist for valid channel only
363+
assert "angle_alongship" in ds_Sv
364+
assert "angle_athwartship" in ds_Sv
365+
assert len(valid_angle_channels) == total_channels - 1
366+
338367
# TODO: need a test for power/angle data, with mock EchoData object
339368
# containing some channels with single-beam data and some channels with split-beam data

0 commit comments

Comments
 (0)