Closed ouhssam closed 5 months ago
The idea of oce is to read data files and provide the results to the user, to be processed in a way that makes sense for a given application, guided by the scientific literature.
The first question is whether your Workhorse device was set up with the 'waves' package (see snapshot from a workhorse manual, at the end of this comment). And then, was the configuration set up to make those measurements, with what settings, etc.
If the dataset contains wave data, I think oce should be able to read them. If not, please email me part of the file so I can look at it ... "kelley AT dal DOT ca" and I can take a look. Do not post your data to this site because it is public, and I assume you want to work with your data alone, in hopes of publishing results.
@richardsc might have further comments, as someone with experience in these matters.
I agree with what @dankelley said -- oce is intended to help you read the data you have, but we are not experts in all the possible data analysis techniques so generally don't provide algorithms that are best left to the specific scientific application.
On the question of whether oce can read Workhorse 1200 data that has been upgraded to allow waves fields, I'm not 100% sure of the answer as I have never worked with such data. If I had to guess I'd say that oce probably doesn't read the relevant fields for a wave-measuring instrument (but we'd need to see an example file to know for sure).
I just did grep -i wave oce/R/adp.rdi.R
and there are no hits, so oce does not read wave data. Perhaps that could be added, if we had a sample file. But we would need documentation on the format...
I just looked in the "workhorse ... commands and output data format" of June 2018, and the word "wave" only shows up there for the commands to cause wave sampling to be done. Possibly I missed it, though. And possibly other Teledyne manuals cover this.
Without clear document and a sample file, we cannot make progress on this.
@ouhssam -- thanks for sending that file privately.
I see that read.adp.rdi()
does not decode the wave data in this file. I'm not surprised, actually, because code for that has not been written.
We are at an impasse here, because I have no documentation on this particular file format. (See above comments.)
A side note: the first two bytes of this file are not 0x7F
, which is the expected start for the file.
Below (click Details) I am pasting the output of a read.adp.rdi(...,debug=1)
call. (I have redacted your filename for privacy.) The comment
NOTE: bad ensemble-start encountered 87274 times
is important. That might be wave information.
We cannot proceed further unless we have documentation from Teledyne/RDI on the file format for wave data. I have 35 PDF documents from RDI about the instruments and file formats. Since they are PDF, they are difficult to search without opening them all. But I have checked the ones that I think are most relevant (used as a reference for the oce code) do not have anything about the waves format.
I may see @richardsc next week, and we might have time to discuss this matter then.
I did some web searching and found a 13 year-old document at https://www.comm-tec.com/Docs/Manuali/RDI/WavesMon%20Quick%20Start%20Guide.pdf called WavesMon v3.08 User’s Guide that has the following on page 59. But it's 13 years old, and I'm not sure it would make sense to start writing new code based on such an old document. (Coding such things is not trivial.)
@ouhssam it looks as though matlab has code to read waves files. You might want to check that out. See https://pubs.usgs.gov/of/2005/1211/
As an experiment, I tried running the following code on the data file, but the data disagree with the RDI documentation (at https://www.comm-tec.com/Docs/Manuali/RDI/WavesMon%20Quick%20Start%20Guide.pdf, called WavesMon v3.08 User’s Guide) on byte 9 in the file. Either the documentation is wrong or this is a new format, in addition to the approximately 10 formats listed in the documentation. I suspect the latter, given that the documentation is old.
> library(oce)
> f <- "(REDACTED)"
> buf <- readBin(f, "raw", n = 1e4)
> i <- 1
> if (buf[i] == 0x7f && buf[i + 1] == 0x79) {
+ cat("Got 0x7f 0x79 (for waves type) see wavemon manual section 4.5 table 16\n")
+ i <- i + 2
+ checksumOffset <- readBin(buf[i + 0:1], "integer", n = 1, size = 2)
+ cat(" ", vectorShow(checksumOffset))
+ i <- i + 2
+ spare <- buf[i]
+ cat(" ", vectorShow(spare))
+ i <- i + 1
+ numberOfDataTypes <- readBin(buf[i], "integer", n = 1, size = 1)
+ cat(" ", vectorShow(numberOfDataTypes))
+ i <- i + 1
+ offset <- readBin(buf[i + 0:1], "integer", n = 1, size = 2)
+ cat(" ", vectorShow(offset))
+ buf[offset+2]
+ i <- offset + 1 # or maybe i + 2
+ buf[15] # maybe nbins
+ # NEXT FAILS. is manual wrong, or am I reading it incorrectly?
+ if (buf[i] == 0x01 && buf[i + 1] == 0x03) {
+ cat("First Leader Type at index ", i, "\n")
+ } else {
+ cat(" ERROR: need 0x01 0x03 (first leader) but have 0x", buf[i], " 0x",
+ buf[i + 1], "\n",
+ sep = ""
+ )
+ }
+ }
Got 0x7f 0x79 (for waves type) see wavemon manual section 4.5 table 16
checksumOffset: 86
spare: 00
numberOfDataTypes: 1
offset: 8
ERROR: need 0x01 0x03 (first leader) but have 0x03 0x01
I've discussed this with co-developer @richardsc and the decision is not to attempt to alter oce to support this file type at this time.
We explored a similar file about a year ago (see sandbox/dk/rdi
in this repo) but concluded then that it is more practical for users to try using matlab code or RDI applications for this work.
There are a couple of issues involved here.
We may return to this if a local student needs help with a file. Being local means that we can work closely with the student, to check that whatever results we get in oce match results from matlab. Without such checks, it is quite difficult to support a new binary filetype, working from manuals that are often vague (e.g. they do not state the format used for the bytes in the file -- sometimes integer, sometimes unsigned integer, sometimes floating point). There can be a fair bit of guesswork involved in coding from vague manuals. And, of course, if manuals have errors (see the previous comment for what may be an example of a manual) then we will have a difficult time discovering how to work past those errors, without alternative software to use for comparisons.
@ouhssam in oce, we ask reporters to close issues. I recommend you read this -- and go through the emails that you sent to us privately -- and consider closing this issue.
Sorry we could not help. Dan.
I think it's not unlikely that the byte-order reversal in the above is a result of an assumption of endianness in the RDI documentation. Nevertheless, I conclude that handling this format would be an excessive amount of work.
Thanks a lot. I will have a look on the matlab code.
PS. yesterday, I asked Teledyn/RDInstruments some questions about the format, because the wavesmon document had quite a few missing elements. The reply indicated that they will not be clarifying the document, because the intension is that users employ the wavesmon software to get text-based files.
The matlab code deal with those text-based files and, since that code is quite old and presumably well-used, I hope you'll have good luck. At the moment, we do not plan to add similar code to oce, preferring instead to focus on common topics for which other solutions are lacking.
Thanks.
Is it possible to use OCE to calculate the wave height, peak period, direction from ADCP Teledyne workstation 1200khz. Thanks you for your help. Best, Mustapha