Skip to content

Commit 1167400

Browse files
committed
fix: handle 3D depth/echo_range in echogram rendering
1 parent 425edbb commit 1167400

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

scripts/batch_processing/build_full_survey.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,8 +1089,10 @@ def _plot_perday_echogram(
10891089

10901090
range_var = "depth" if "depth" in ds.coords or "depth" in ds.dims else "echo_range"
10911091
depth_vals = ds[range_var].values
1092-
# echo_range may be 2D (channel, range_sample) — flatten to 1D
1093-
if depth_vals.ndim == 2:
1092+
# depth/echo_range may be 2D or 3D — reduce to 1D depth profile
1093+
if depth_vals.ndim == 3: # (channel, ping_time, range_sample)
1094+
depth_vals = np.nanmedian(depth_vals[0], axis=0) # median across pings for ch 0
1095+
elif depth_vals.ndim == 2: # (channel, range_sample)
10941096
depth_vals = depth_vals[0]
10951097
if range_var == "echo_range":
10961098
depth_vals = depth_vals + TRANSDUCER_DEPTH
@@ -1518,8 +1520,10 @@ def _prepare_echogram_data(
15181520

15191521
range_var = "depth" if "depth" in ds.coords or "depth" in ds.dims else "echo_range"
15201522
depth_vals = ds[range_var].values
1521-
# echo_range may be 2D (channel, range_sample) — flatten to 1D
1522-
if depth_vals.ndim == 2:
1523+
# depth/echo_range may be 2D or 3D — reduce to 1D depth profile
1524+
if depth_vals.ndim == 3: # (channel, ping_time, range_sample)
1525+
depth_vals = np.nanmedian(depth_vals[0], axis=0) # median across pings for ch 0
1526+
elif depth_vals.ndim == 2: # (channel, range_sample)
15231527
depth_vals = depth_vals[0]
15241528
if range_var == "echo_range":
15251529
depth_vals = depth_vals + TRANSDUCER_DEPTH

0 commit comments

Comments
 (0)