Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EK60 Conversion: Drop channels that don't have power data #1383

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions echopype/convert/set_groups_ek60.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ def __init__(self, *args, **kwargs):
# In some examples the channels may not be ordered, thus sorting is required
self.sorted_channel = dict(sorted(channel_ids.items(), key=lambda item: item[1]))

# Select channels where parser `power` is not empty
self.sorted_channel = {
key: value
for key, value in self.sorted_channel.items()
if len(self.parser_obj.ping_data_dict["power"][key]) != 0
}

# obtain corresponding frequency dict from sorted channels
self.freq = [
self.parser_obj.config_datagram["transceivers"][ch]["frequency"]
Expand Down
28 changes: 28 additions & 0 deletions echopype/tests/convert/test_convert_ek60.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytest

from echopype import open_raw
from echopype.convert import ParseEK60


@pytest.fixture
Expand Down Expand Up @@ -236,3 +237,30 @@ def test_convert_ek60_different_num_channel_mode_values(file_path, ek60_path):
ed["Sonar/Beam_group1"]["channel_mode"].data.dtype,
np.float32
)

@pytest.mark.test
@pytest.mark.integration
def test_converting_ek60_raw_with_missing_channel_power():
"""
Tests that we can convert a EK60 RAW file that has missing power data for a
specific channel.
"""
# Parse RAW
raw_path = "echopype/test_data/ek60_missing_channel_power/Summer2017-D20170807-T171736.raw"
ek60_parser = ParseEK60(raw_path)
ek60_parser.parse_raw()

# Open RAW
ed = open_raw(raw_path, sonar_model="EK60")

# Get channels that have empty `power`
channels = list(ek60_parser.config_datagram["transceivers"].keys())
empty_power_chs = {
ch: ek60_parser.config_datagram["transceivers"][ch]["channel_id"]
for ch in channels
if len(ek60_parser.ping_data_dict["power"][ch]) == 0
}

# Check that all empty power channels do not exist in the EchoData Beam group
for _, empty_power_channel_name in empty_power_chs.items():
assert empty_power_channel_name not in ed["Sonar/Beam_group1"]["channel"]