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

Correct or add missing SONAR-netCDF4 variable attributes for AZFP #1023

Merged
merged 2 commits into from
Apr 6, 2023
Merged
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
57 changes: 50 additions & 7 deletions echopype/convert/set_groups_azfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ def set_env(self) -> xr.Dataset:
"temperature": (
["time1"],
self.parser_obj.unpacked_data["temperature"],
{
"long_name": "Water temperature",
"standard_name": "sea_water_temperature",
"units": "deg_C",
},
)
},
coords={
Expand All @@ -105,7 +110,6 @@ def set_env(self) -> xr.Dataset:
},
)
},
attrs={"long_name": "Water temperature", "units": "C"},
)

return set_time_encodings(ds)
Expand All @@ -125,6 +129,7 @@ def set_sonar(self) -> xr.Dataset:
"sonar_model": self.sonar_model,
"sonar_serial_number": int(self.parser_obj.unpacked_data["serial_number"]),
"sonar_software_name": "AZFP",
# TODO: software version is hardwired. Read it from the XML file's AZFP_Version node
"sonar_software_version": "1.4",
"sonar_type": "echosounder",
}
Expand All @@ -144,8 +149,22 @@ def set_platform(self) -> xr.Dataset:

ds = xr.Dataset(
{
"tilt_x": (["time2"], unpacked_data["tilt_x"]),
"tilt_y": (["time2"], unpacked_data["tilt_y"]),
"tilt_x": (
["time2"],
unpacked_data["tilt_x"],
{
"long_name": "Tilt X",
"units": "degree",
},
),
"tilt_y": (
["time2"],
unpacked_data["tilt_y"],
{
"long_name": "Tilt Y",
"units": "degree",
},
),
**{
var: ([], np.nan, self._varattrs["platform_var_default"][var])
for var in [
Expand Down Expand Up @@ -239,10 +258,34 @@ def set_beam(self) -> List[xr.Dataset]:
"standard_name": "sound_frequency",
},
),
"backscatter_r": (["channel", "ping_time", "range_sample"], N),
"equivalent_beam_angle": (["channel"], parameters["BP"][self.freq_ind_sorted]),
"gain_correction": (["channel"], unpacked_data["gain"][self.freq_ind_sorted]),
"sample_interval": (["channel"], sample_int, {"units": "s"}),
"backscatter_r": (
["channel", "ping_time", "range_sample"],
N,
{"long_name": "Backscatter power", "units": "dB"},
),
"equivalent_beam_angle": (
["channel"],
parameters["BP"][self.freq_ind_sorted],
{
"long_name": "Equivalent beam angle",
"units": "sr",
"valid_range": (0.0, 4 * np.pi),
},
),
"gain_correction": (
["channel"],
unpacked_data["gain"][self.freq_ind_sorted],
{"long_name": "Gain correction", "units": "dB"},
),
"sample_interval": (
["channel"],
sample_int,
{
"long_name": "Interval between recorded raw data samples",
"units": "s",
"valid_min": 0.0,
},
),
"transmit_duration_nominal": (
["channel"],
tdn,
Expand Down