Skip to content

Commit

Permalink
Added parser support for EK80 MRU1 (#1242)
Browse files Browse the repository at this point in the history
* added parser support for MRU1

* added heading variable in ek80 groups and also added test case
  • Loading branch information
praneethratna authored Dec 18, 2023
1 parent 6c83378 commit 529fa60
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
11 changes: 11 additions & 0 deletions echopype/convert/set_groups_ek80.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,17 @@ def set_platform(self) -> xr.Dataset:
"standard_name": "sound_frequency",
},
),
"heading": (
["time2"],
np.array(self.parser_obj.mru.get("heading", [np.nan])),
{
"long_name": "Platform heading (true)",
"standard_name": "platform_orientation",
"units": "degrees_north",
"valid_min": 0.0,
"valid_max": 360.0,
},
),
},
coords={
"channel": (
Expand Down
22 changes: 21 additions & 1 deletion echopype/convert/utils/ek_raw_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,16 @@ class SimradMRUParser(_SimradDatagramParser):
pitch: float
heading: float
type: string == 'MRU1'
low_date: long uint representing LSBytes of 64bit NT date
high_date: long uint representing MSBytes of 64bit NT date
timestamp: datetime.datetime object of NT date, assumed to be UTC
heave: float
roll : float
pitch: float
heading: float
length: long uint
The following methods are defined:
from_string(str): parse a raw ER60 NMEA datagram
Expand All @@ -522,7 +532,17 @@ def __init__(self):
("roll", "f"),
("pitch", "f"),
("heading", "f"),
]
],
1: [
("type", "4s"),
("low_date", "L"),
("high_date", "L"),
("heave", "f"),
("roll", "f"),
("pitch", "f"),
("heading", "f"),
("length", "L"),
],
}

_SimradDatagramParser.__init__(self, "MRU", headers)
Expand Down
14 changes: 14 additions & 0 deletions echopype/tests/convert/test_convert_ek80.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from echopype import open_raw

from echopype.testing import TEST_DATA_FOLDER
from echopype.convert.parse_ek80 import ParseEK80
from echopype.convert.set_groups_ek80 import WIDE_BAND_TRANS, PULSE_COMPRESS, FILTER_IMAG, FILTER_REAL, DECIMATION


Expand Down Expand Up @@ -428,3 +429,16 @@ def test_convert_ek80_no_fil_coeff(ek80_path):
for t in [WIDE_BAND_TRANS, PULSE_COMPRESS]:
for p in [FILTER_REAL, FILTER_IMAG, DECIMATION]:
assert f"{t}_{p}" not in vendor_spec_ds


def test_convert_ek80_mru1(ek80_path):
"""Make sure we can convert EK80 file with MRU1 datagram."""
ek80_mru1_path = str(ek80_path.joinpath('20231016_Cal_-D20231016-T220322.raw'))
echodata = open_raw(raw_file=ek80_mru1_path, sonar_model='EK80')
parser = ParseEK80(str(ek80_mru1_path), None)
parser.parse_raw()

np.all(echodata["Platform"]["pitch"].data == np.array(parser.mru["pitch"]))
np.all(echodata["Platform"]["roll"].data == np.array(parser.mru["roll"]))
np.all(echodata["Platform"]["vertical_offset"].data == np.array(parser.mru["heave"]))
np.all(echodata["Platform"]["heading"].data == np.array(parser.mru["heading"]))

0 comments on commit 529fa60

Please sign in to comment.