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

Remove the user option to select NMEA sentences #778

Merged
merged 2 commits into from
Aug 11, 2022
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
6 changes: 0 additions & 6 deletions echopype/convert/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

DEFAULT_CHUNK_SIZE = {"range_sample": 25000, "ping_time": 2500}

NMEA_SENTENCE_DEFAULT = ["GGA", "GLL", "RMC"]

BEAM_SUBGROUP_DEFAULT = "Beam_group1"


Expand Down Expand Up @@ -238,9 +236,6 @@ def _set_convert_params(param_dict: Dict[str, str]) -> Dict[str, str]:

The default set of parameters include:
- Platform group: ``platform_name``, ``platform_type``, ``platform_code_ICES``, ``water_level``
- Platform/NMEA: ``nmea_gps_sentence``,
for selecting specific NMEA sentences,
with default values ['GGA', 'GLL', 'RMC'].
- Top-level group: ``survey_name``

Other parameters will be saved to the top level.
Expand All @@ -261,7 +256,6 @@ def _set_convert_params(param_dict: Dict[str, str]) -> Dict[str, str]:
out_params["platform_code_ICES"] = param_dict.get("platform_code_ICES", "")
out_params["platform_type"] = param_dict.get("platform_type", "")
out_params["water_level"] = param_dict.get("water_level", None)
out_params["nmea_gps_sentence"] = param_dict.get("nmea_gps_sentence", NMEA_SENTENCE_DEFAULT)

# Parameters for the Top-level group
out_params["survey_name"] = param_dict.get("survey_name", "")
Expand Down
6 changes: 4 additions & 2 deletions echopype/convert/set_groups_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

DEFAULT_CHUNK_SIZE = {"range_sample": 25000, "ping_time": 2500}

NMEA_SENTENCE_DEFAULT = ["GGA", "GLL", "RMC"]


class SetGroupsBase(abc.ABC):
"""Base class for saving groups to netcdf or zarr from echosounder data files."""
Expand Down Expand Up @@ -143,10 +145,10 @@ def set_vendor(self) -> xr.Dataset:
raise NotImplementedError

# TODO: move this to be part of parser as it is not a "set" operation
def _parse_NMEA(self):
def _extract_NMEA_latlon(self):
"""Get the lat and lon values from the raw nmea data"""
messages = [string[3:6] for string in self.parser_obj.nmea["nmea_string"]]
idx_loc = np.argwhere(np.isin(messages, self.ui_param["nmea_gps_sentence"])).squeeze()
idx_loc = np.argwhere(np.isin(messages, NMEA_SENTENCE_DEFAULT)).squeeze()
if idx_loc.size == 1: # in case of only 1 matching message
idx_loc = np.expand_dims(idx_loc, axis=0)
nmea_msg = []
Expand Down
2 changes: 1 addition & 1 deletion echopype/convert/set_groups_ek60.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def set_platform(self, NMEA_only=False) -> xr.Dataset:

# Collect variables
# Read lat/long from NMEA datagram
time1, msg_type, lat, lon = self._parse_NMEA()
time1, msg_type, lat, lon = self._extract_NMEA_latlon()

# NMEA dataset: variables filled with nan if do not exist
ds = xr.Dataset(
Expand Down
2 changes: 1 addition & 1 deletion echopype/convert/set_groups_ek80.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def set_platform(self) -> xr.Dataset:
water_level = np.nan
print("WARNING: The water_level_draft was not in the file. " "Value set to NaN.")

time1, msg_type, lat, lon = self._parse_NMEA()
time1, msg_type, lat, lon = self._extract_NMEA_latlon()
time2 = self.parser_obj.mru.get("timestamp", None)
time2 = np.array(time2) if time2 is not None else [np.nan]

Expand Down