Skip to content

Commit 3d21242

Browse files
committed
fix(batch): handle NaN pulse_mode in echogram rendering
1 parent 6f1ad14 commit 3d21242

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

scripts/batch_processing/run_combine_daily.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -624,8 +624,8 @@ def _draw_pulse_axis(
624624
"""Draw pulse-mode colour bar (blue=Long, orange=Short) using time-proportional x."""
625625
from matplotlib.patches import Rectangle
626626

627-
colors = {0: "#2196F3", 1: "#FF9800"}
628-
labels_map = {0: "Long pulse", 1: "Short pulse"}
627+
colors = {0: "#2196F3", 1: "#FF9800", -1: "#9E9E9E"}
628+
labels_map = {0: "Long pulse", 1: "Short pulse", -1: "Unknown"}
629629

630630
x_min, x_max = x_hours[0], x_hours[-1]
631631
total_span = x_max - x_min
@@ -738,7 +738,11 @@ def render_echogram(
738738

739739
pulse_mode = None
740740
if "pulse_mode" in ds:
741-
pulse_mode = ds["pulse_mode"].values
741+
pm = ds["pulse_mode"].values
742+
# Replace NaN with -1 (unknown) so int conversion works
743+
if np.issubdtype(pm.dtype, np.floating):
744+
pm = np.where(np.isnan(pm), -1, pm).astype(np.int8)
745+
pulse_mode = pm
742746

743747
has_pulse = pulse_mode is not None
744748

0 commit comments

Comments
 (0)