From 529fa602d16dbd204b3259d3fbda0960eaabc316 Mon Sep 17 00:00:00 2001 From: Praneeth Ratna <63547155+praneethratna@users.noreply.github.com> Date: Mon, 18 Dec 2023 22:17:09 +0530 Subject: [PATCH] Added parser support for EK80 MRU1 (#1242) * added parser support for MRU1 * added heading variable in ek80 groups and also added test case --- echopype/convert/set_groups_ek80.py | 11 +++++++++++ echopype/convert/utils/ek_raw_parsers.py | 22 ++++++++++++++++++++- echopype/tests/convert/test_convert_ek80.py | 14 +++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/echopype/convert/set_groups_ek80.py b/echopype/convert/set_groups_ek80.py index 8759b5369..0938ac6b4 100644 --- a/echopype/convert/set_groups_ek80.py +++ b/echopype/convert/set_groups_ek80.py @@ -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": ( diff --git a/echopype/convert/utils/ek_raw_parsers.py b/echopype/convert/utils/ek_raw_parsers.py index b259e619f..4a7118659 100644 --- a/echopype/convert/utils/ek_raw_parsers.py +++ b/echopype/convert/utils/ek_raw_parsers.py @@ -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 @@ -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) diff --git a/echopype/tests/convert/test_convert_ek80.py b/echopype/tests/convert/test_convert_ek80.py index 14b57b5fb..641c16ea0 100644 --- a/echopype/tests/convert/test_convert_ek80.py +++ b/echopype/tests/convert/test_convert_ek80.py @@ -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 @@ -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"]))