Skip to content

Commit 00a0041

Browse files
committed
fix(ecs): strip commented lines with empty values so echopype parser succeeds
1 parent a01554b commit 00a0041

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

  • oceanstream/echodata/calibrate

‎oceanstream/echodata/calibrate/ecs.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ def _normalize_ecs_text(text: str) -> str:
7070
stripped = line.rstrip("\r\n")
7171
# Only rewrite top-level headers (no leading whitespace).
7272
if not stripped or line.startswith((" ", "\t")):
73+
# Filter out commented param lines with empty/invalid values
74+
# e.g. " # SoundSpeed = # (meters per second)..."
75+
# These crash echopype's PARAM_MATCHER
76+
trimmed = stripped.lstrip()
77+
if trimmed.startswith("#"):
78+
# Check if it's a commented param with "= #" (empty value)
79+
if "= #" in trimmed or "= \n" in line or trimmed.endswith("="):
80+
# Skip this line entirely — it's a no-op comment
81+
continue
7382
out_lines.append(line)
7483
continue
7584
nl = line[len(stripped):] or "\n"

0 commit comments

Comments
 (0)