Skip to content

Commit 6a474e9

Browse files
jmcvey3ssolsonakeeste
authored
Short list of VMDAS updates (#405)
Discovered from a recent vessel survey that I misunderstood TDI's documentation on a couple of VMDAS parameters. The speed and direction parameters I thought it was pulling directly from the GPS it is calculating from the change in latitude/longitude over time. I renamed them and added the two variables that are actually directly from the GPS. Also discovered that VMDAS cannot take an RMC NMEA sentence, so the GPS timestamps are lacking a datestamp. Which is not helpful if your ADCP's clock is on local time and the GPS is always in UTC. So I added a code block that checks if the GPS UTC time rolled over from 23:59:59 to 00:00:00 and manually updated the day. --------- Co-authored-by: ssolson <[email protected]> Co-authored-by: akeeste <[email protected]>
1 parent 68fe393 commit 6a474e9

File tree

5 files changed

+28
-19
lines changed

5 files changed

+28
-19
lines changed
40 Bytes
Binary file not shown.
-42 Bytes
Binary file not shown.

mhkit/dolfyn/io/base.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,17 @@ def _remove_gps_duplicates(dat):
137137

138138
dat["data_vars"]["hdwtime_gps"] = dat["coords"]["time"]
139139

140+
# If the time jumps by nearly 24 hours at any given instance, we've skipped a day
141+
time_diff = np.diff(dat["coords"]["time_gps"])
142+
if any(np.array(list(set(time_diff))) < -(23.9 * 3600)):
143+
idx = np.where(time_diff == time_diff.min())[0]
144+
dat["coords"]["time_gps"][int(idx) + 1 :] += 24 * 3600
145+
140146
# Remove duplicate timestamp values, if applicable
141147
dat["coords"]["time_gps"], idx = np.unique(
142148
dat["coords"]["time_gps"], return_index=True
143149
)
150+
144151
# Remove nan values, if applicable
145152
nan = np.zeros(dat["coords"]["time"].shape, dtype=bool)
146153
if any(np.isnan(dat["coords"]["time_gps"])):

mhkit/dolfyn/io/rdi_defs.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,15 +235,15 @@
235235
"data_vars",
236236
"float32",
237237
"m s-1",
238-
"Platform Speed Made Good",
238+
"Platform Speed Made Good from Lat/Lon",
239239
"platform_speed_wrt_ground",
240240
),
241241
"dir_made_good_gps": (
242242
[],
243243
"data_vars",
244244
"float32",
245245
"degree",
246-
"Platform Direction Made Good",
246+
"Platform Direction Made Good from Lat/Lon",
247247
"platform_course",
248248
),
249249
"flags_gps": ([], "data_vars", "float32", "bits", "GPS Flags", ""),
@@ -970,8 +970,8 @@ def read_vmdas(rdr):
970970
"clock_offset_UTC_gps",
971971
"latitude_gps",
972972
"longitude_gps",
973-
"avg_speed_gps",
974-
"avg_dir_gps",
973+
"speed_over_grnd_gps",
974+
"dir_over_grnd_gps",
975975
"speed_made_good_gps",
976976
"dir_made_good_gps",
977977
"flags_gps",
@@ -993,14 +993,15 @@ def read_vmdas(rdr):
993993
longitude_first_gps = fd.read_i32(1) * rdr._cfac32
994994

995995
# Last lat/lon position prior to current ADCP ping
996-
utc_time_fix = tmlib.timedelta(milliseconds=(int(fd.read_ui32(1) * 0.1)))
997-
ens.time_gps[k] = tmlib.date2epoch(date_utc + utc_time_fix)[0]
996+
utc_time_last_fix = tmlib.timedelta(milliseconds=(int(fd.read_ui32(1) * 0.1)))
997+
ens.time_gps[k] = tmlib.date2epoch(date_utc + utc_time_last_fix)[0]
998998
ens.latitude_gps[k] = fd.read_i32(1) * rdr._cfac32
999999
ens.longitude_gps[k] = fd.read_i32(1) * rdr._cfac32
1000-
1001-
ens.avg_speed_gps[k] = fd.read_ui16(1) * 0.001
1002-
ens.avg_dir_gps[k] = fd.read_ui16(1) * rdr._cfac16 # avg true track
1000+
# From VTG
1001+
ens.speed_over_grnd_gps[k] = fd.read_ui16(1) * 0.001
1002+
ens.dir_over_grnd_gps[k] = fd.read_ui16(1) * rdr._cfac16 # avg true track
10031003
fd.seek(2, 1) # avg magnetic track
1004+
# Calculated from difference between latitude and longitude
10041005
ens.speed_made_good_gps[k] = fd.read_ui16(1) * 0.001
10051006
ens.dir_made_good_gps[k] = fd.read_ui16(1) * rdr._cfac16
10061007
fd.seek(2, 1) # reserved

mhkit/dolfyn/velocity.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -658,16 +658,17 @@ def bin_average(self, raw_ds, out_ds=None, names=None):
658658
).astype("float32")
659659
except: # variables not needing averaging
660660
pass
661-
# Add standard deviation
662-
std = self.standard_deviation(raw_ds.velds.U_mag.values)
663-
out_ds["U_std"] = xr.DataArray(
664-
std.astype("float32"),
665-
dims=raw_ds.vel.dims[1:],
666-
attrs={
667-
"units": "m s-1",
668-
"long_name": "Water Velocity Standard Deviation",
669-
},
670-
)
661+
662+
# Add standard deviation
663+
std = self.standard_deviation(raw_ds.velds.U_mag.values)
664+
out_ds["U_std"] = xr.DataArray(
665+
std.astype("float32"),
666+
dims=raw_ds.vel.dims[1:],
667+
attrs={
668+
"units": "m s-1",
669+
"long_name": "Water Velocity Standard Deviation",
670+
},
671+
)
671672

672673
return out_ds
673674

0 commit comments

Comments
 (0)