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

Refactored EK80 data XML parser and also removed the usage of dict_to_dict method #1186

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion echopype/convert/parse_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def _read_datagrams(self, fid):
'water_level_draft': 0.0,
'water_level_draft_is_manual': 0,
'transducer_name': 'Unknown',
'transducer_sound_speed': 1490.0},
'sound_speed': 1490.0},
'xml': '<?xml version="1.0" encoding="utf-8"?>\r\n<Environment Depth="240" ... />\r\n</Environment>'}
""" # noqa
num_datagrams_parsed = 0
Expand Down
20 changes: 10 additions & 10 deletions echopype/convert/set_groups_ek80.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def set_env(self) -> xr.Dataset:
},
)

varnames = ["sound_velocity_source", "transducer_name", "transducer_sound_speed"]
varnames = ["sound_velocity_source", "transducer_name", "sound_speed"]
for vn in varnames:
if vn in self.parser_obj.environment:
dict_env[vn] = (
Expand Down Expand Up @@ -193,12 +193,12 @@ def set_env(self) -> xr.Dataset:
def set_sonar(self, beam_group_type: list = ["power", None]) -> xr.Dataset:
# Collect unique variables
params = [
"transducer_frequency",
"frequency",
"serial_number",
"transducer_name",
"transducer_serial_number",
"application_name",
"application_version",
"version",
"channel_id_short",
]
var = defaultdict(list)
Expand Down Expand Up @@ -231,7 +231,7 @@ def set_sonar(self, beam_group_type: list = ["power", None]) -> xr.Dataset:
sonar_vars = {
"frequency_nominal": (
["channel"],
var["transducer_frequency"],
var["frequency"],
{
"units": "Hz",
"long_name": "Transducer frequency",
Expand Down Expand Up @@ -282,7 +282,7 @@ def set_sonar(self, beam_group_type: list = ["power", None]) -> xr.Dataset:
# will not try to populate sonar_serial_number from the raw datagrams
"sonar_serial_number": "",
"sonar_software_name": var["application_name"][0],
"sonar_software_version": var["application_version"][0],
"sonar_software_version": var["version"][0],
"sonar_type": "echosounder",
}
ds = ds.assign_attrs(sonar_attr_dict)
Expand All @@ -294,7 +294,7 @@ def set_platform(self) -> xr.Dataset:

freq = np.array(
[
self.parser_obj.config_datagram["configuration"][ch]["transducer_frequency"]
self.parser_obj.config_datagram["configuration"][ch]["frequency"]
for ch in self.sorted_channel["power_complex"]
]
)
Expand Down Expand Up @@ -455,7 +455,7 @@ def _assemble_ds_ping_invariant(self, params, data_type):

freq = np.array(
[
self.parser_obj.config_datagram["configuration"][ch]["transducer_frequency"]
self.parser_obj.config_datagram["configuration"][ch]["frequency"]
for ch in self.sorted_channel[data_type]
]
)
Expand Down Expand Up @@ -678,7 +678,7 @@ def _add_freq_start_end_ds(self, ds_tmp: xr.Dataset, ch: str) -> xr.Dataset:
freq_start = np.array(self.parser_obj.ping_data_dict["frequency_start"][ch])
freq_stop = np.array(self.parser_obj.ping_data_dict["frequency_end"][ch])
elif not self.sorted_channel["power"]:
freq = self.parser_obj.config_datagram["configuration"][ch]["transducer_frequency"]
freq = self.parser_obj.config_datagram["configuration"][ch]["frequency"]
freq_start = np.full(len(self.parser_obj.ping_time[ch]), freq)
freq_stop = freq_start
else:
Expand Down Expand Up @@ -1239,7 +1239,7 @@ def set_vendor(self) -> xr.Dataset:
# - receiver sampling frequency
# - transceiver type
table_params = [
"transducer_frequency",
"frequency",
"impedance", # transceiver impedance (z_er), different from transducer impedance (z_et)
"rx_sample_frequency", # receiver sampling frequency
"transceiver_type",
Expand Down Expand Up @@ -1272,7 +1272,7 @@ def set_vendor(self) -> xr.Dataset:
{
"frequency_nominal": (
["channel"],
param_dict["transducer_frequency"],
param_dict["frequency"],
{
"units": "Hz",
"long_name": "Transducer frequency",
Expand Down
Loading