Skip to content

Commit

Permalink
Merge branch 'main' into fix_division_by_zero
Browse files Browse the repository at this point in the history
  • Loading branch information
leewujung authored Sep 4, 2024
2 parents 9c39b33 + 63cdf95 commit c916fe9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
8 changes: 7 additions & 1 deletion echopype/convert/parse_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,13 @@ def _read_datagrams(self, fid):

# XML datagrams store environment or instrument parameters for EK80
if new_datagram["type"].startswith("XML"):
if new_datagram["subtype"] == "environment":
# Check that environment datagrams contain more than
# just drop_keel_offset and drop_keel_offset_is_manual
# Temporary fix for handling >1 EK80 environment datagrams described in:
# https://github.com/OSOceanAcoustics/echopype/issues/1386
if new_datagram["subtype"] == "environment" and set(
["drop_keel_offset", "drop_keel_offset_is_manual"]
) != set(new_datagram["environment"].keys()):
self.environment = new_datagram["environment"]
self.environment["xml"] = new_datagram["xml"]
self.environment["timestamp"] = new_datagram["timestamp"]
Expand Down
20 changes: 20 additions & 0 deletions echopype/tests/convert/test_convert_ek80.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,3 +511,23 @@ def test_parse_missing_sound_velocity_profile():

# Remove Zarr File
shutil.rmtree(save_path)


@pytest.mark.unit
def test_parse_ek80_with_invalid_env_datagrams():
"""
Tests parsing EK80 RAW file with invalid environment datagrams. Checks that the EchoData object
contains the necessary environment variables for calibration.
"""

# Parse RAW
ed = open_raw(
"echopype/test_data/ek80_invalid_env_datagrams/SH24-replay-D20240705-T070536.raw",
sonar_model="EK80",
)

# Check that each calibration specific variable exists, is not NaN, and is of type float64
for var in ["acidity", "depth", "salinity", "temperature", "sound_speed_indicative"]:
env_var = ed["Environment"][var]
assert env_var.notnull().all() and env_var.dtype == np.float64

0 comments on commit c916fe9

Please sign in to comment.