Skip to content

Commit 3c914c3

Browse files
committed
Added support for lazy loaded Dask arrays; updated test
1 parent 631a6f6 commit 3c914c3

3 files changed

Lines changed: 13 additions & 10 deletions

File tree

echopype/consolidate/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,14 +477,14 @@ def add_splitbeam_angle(
477477
raise ValueError(
478478
"The 'source_Sv' dataset does not have the same dimensions as data in 'echodata'!"
479479
)
480-
481480
# obtain split-beam angles from
482481
# CW mode data
483482
if waveform_mode == "CW":
484483
if encode_mode == "power": # power data
485484
theta, phi = get_angle_power_samples(ds_beam, angle_params)
486485
else: # complex data
487486
# operation is identical with BB complex data
487+
488488
theta, phi = get_angle_complex_samples(ds_beam, angle_params)
489489
# BB mode data
490490
else:

echopype/consolidate/split_beam_angle.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -234,24 +234,25 @@ def get_angle_complex_samples(
234234
else:
235235
# beam_type different for some channels, process each channel separately
236236
theta_list, phi_list, valid_channels = [], [], []
237-
for ch_id in bs["channel"].data:
238-
beam_type_ch = ds_beam["beam_type"].sel(channel=ch_id).item()
237+
beam_types = ds_beam["beam_type"].values
238+
239+
for idx, ch_id in enumerate(bs["channel"].data):
240+
beam_type_ch = beam_types[idx]
239241

240242
if beam_type_ch not in SUPPORTED_BEAM_TYPES:
241243
logger.warning(f"Skipping channel {ch_id}: unsupported beam_type {beam_type_ch}")
242244
continue
243245

244246
theta_ch, phi_ch = _compute_angle_from_complex(
245-
bs=bs.sel(channel=ch_id),
246-
# beam_type is not time-varying
247-
beam_type=(ds_beam["beam_type"].sel(channel=ch_id)),
247+
bs=bs.isel(channel=idx),
248+
beam_type=beam_type_ch,
248249
sens=[
249-
angle_params["angle_sensitivity_alongship"].sel(channel=ch_id),
250-
angle_params["angle_sensitivity_athwartship"].sel(channel=ch_id),
250+
float(angle_params["angle_sensitivity_alongship"].isel(channel=idx).values),
251+
float(angle_params["angle_sensitivity_athwartship"].isel(channel=idx).values),
251252
],
252253
offset=[
253-
angle_params["angle_offset_alongship"].sel(channel=ch_id),
254-
angle_params["angle_offset_athwartship"].sel(channel=ch_id),
254+
float(angle_params["angle_offset_alongship"].isel(channel=idx).values),
255+
float(angle_params["angle_offset_athwartship"].isel(channel=idx).values),
255256
],
256257
)
257258
theta_list.append(theta_ch)

echopype/tests/consolidate/test_consolidate_integration.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,8 @@ def test_add_splitbeam_angle_partial_valid_channels(test_path):
352352
if channel_to_invalidate is None:
353353
channel_to_invalidate = idx
354354

355+
# Simulate disabling one valid channel
356+
beam_types[channel_to_invalidate] = 0
355357
ed["Sonar/Beam_group1"]["beam_type"].data[:] = beam_types
356358

357359
# Compute Sv

0 commit comments

Comments
 (0)