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

Add missing convention-required Platform variables to AZFP #654

Merged
merged 1 commit into from
Apr 28, 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
22 changes: 21 additions & 1 deletion echopype/convert/set_groups_azfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,27 @@ def set_platform(self) -> xr.Dataset:
"platform_code_ICES": self.ui_param["platform_code_ICES"],
}
# Save
ds = xr.Dataset()
ds = xr.Dataset(
{
var: ([], np.nan, self._varattrs["platform_var_default"][var])
for var in [
"MRU_offset_x",
"MRU_offset_y",
"MRU_offset_z",
"MRU_rotation_x",
"MRU_rotation_y",
"MRU_rotation_z",
"position_offset_x",
"position_offset_y",
"position_offset_z",
"transducer_offset_x",
"transducer_offset_y",
"transducer_offset_z",
"vertical_offset",
"water_level",
]
}
)
ds = ds.assign_attrs(platform_dict)
return ds

Expand Down
33 changes: 33 additions & 0 deletions echopype/tests/convert/test_convert_azfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,27 @@
def azfp_path(test_path):
return test_path["AZFP"]

def check_platform_required_vars(echodata):
# check convention-required variables in the Platform group
for var in [
"MRU_offset_x",
"MRU_offset_y",
"MRU_offset_z",
"MRU_rotation_x",
"MRU_rotation_y",
"MRU_rotation_z",
"position_offset_x",
"position_offset_y",
"position_offset_z",
"transducer_offset_x",
"transducer_offset_y",
"transducer_offset_z",
"vertical_offset",
"water_level",
]:
assert var in echodata["Platform"]
assert np.isnan(echodata["Platform"][var])


def test_convert_azfp_01a_matlab_raw(azfp_path):
"""Compare parsed raw data with Matlab outputs."""
Expand Down Expand Up @@ -77,6 +98,9 @@ def test_convert_azfp_01a_matlab_raw(azfp_path):
echodata.vendor.battery_main,
)

# check convention-required variables in the Platform group
check_platform_required_vars(echodata)


def test_convert_azfp_01a_matlab_derived():
"""Compare variables derived from raw parsed data with Matlab outputs."""
Expand All @@ -85,6 +109,9 @@ def test_convert_azfp_01a_matlab_derived():
# - investigate why ds_beam.tilt_x/y are different from ds_matlab['Data']['Tx']/['Ty']
# - derived temperature

# # check convention-required variables in the Platform group
# check_platform_required_vars(echodata)

pass


Expand All @@ -111,6 +138,9 @@ def test_convert_azfp_01a_raw_echoview(azfp_path):
)
assert np.array_equal(test_power, echodata.beam.backscatter_r.isel(beam=0).drop('beam'))

# check convention-required variables in the Platform group
check_platform_required_vars(echodata)


def test_convert_azfp_01a_different_ranges(azfp_path):
"""Test converting files with different range settings across frequency."""
Expand All @@ -127,3 +157,6 @@ def test_convert_azfp_01a_different_ranges(azfp_path):
assert echodata.beam.backscatter_r.isel(frequency=3).dropna(
'range_sample'
).shape == (360, 135, 1)

# check convention-required variables in the Platform group
check_platform_required_vars(echodata)