oce
oce copied to clipboard
should have a trim function for all adp/adv types
I really like having ad2cpTrim()
and think we need it for lots of things. The main is binary files, because it's easy to use an editor to trim text-based files (like CNV files). So, the following checklist focusses on adp
and adv
types, the read
functions for which all start by calling C++ to find pointers to data chunks.
We already have ctdTrim()
, but it works on data objects, not on files. Therefore I think we need a new name. Suffix FileTrim()
seems OK, and renaming ad2cpTrim()
to ad2cpFileTrim()
should be no problem, since that is not on CRAN and has only been in the "develop" branch for a day.
- [ ]
xFileTrim()
for "adp/sontek" - [x]
adpRdiFileTrim()
for "adp/rdi" - [ ]
xFileTrim()
for "adp/nortek/aquadopp" - [ ]
xFileTrim()
for "adp/nortek/aquadoppPlusMagnetometer" - [ ]
xFileTrim()
for "adp/nortek/aquadoppProfiler" - [ ]
xFileTrim()
for "adp/nortek/aquadoppHR" - [x]
adpAd2cpFileTrim()
for "adp/nortek/ad2cp"
Below is the core of how ad2cpFileTrim()
works. Although I could make each of the other planned functions call do_ldc_*()
directly, as in the ignored block below, I think there is merit in making the various read.*()
functions respond to which="?"
so that is my plan.
r <- read.oce(infile, which="??")
nmax <- length(r$start)
if (FALSE) { # double check
nav <- do_ldc_ad2cp_in_file(infile, 1L, 1e9L, 1L,
0L, # do not ignore bad checksums
debug) # possibly debug
stopifnot(identical(nav$index-9L, r$start))
}
if (n >= nmax)
stop("maximum allowed 'n' for this file is ", nmax)
# add 1 to profile count; go back 1 char before that
last <- r$start[n+1L] - 1L
buf <- readBin(file, "raw", n=last)
writeBin(buf, outfile, useBytes=TRUE)
I'm going to go ahead and close this, because (1) I am the reporter and (2) there has not been much interest, or followup, by me or anyone else.
My idea is to reopen this if somebody needs it for a particular file type. That way, we will have somebody who can check if things work, being familiar with the data.