Skip to content

Commit

Permalink
987 seems ok to DK
Browse files Browse the repository at this point in the history
  • Loading branch information
dankelley committed Jun 21, 2016
1 parent 65e6d39 commit f3a430a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
24 changes: 11 additions & 13 deletions R/ctd.R
Original file line number Diff line number Diff line change
Expand Up @@ -1530,9 +1530,7 @@ ctdDecimate <- function(x, p=1, method="boxcar", e=1.5, debug=getOption("oceDebu
#' movingAverage <- function(x, n = 11, ...)
#' {
#' f <- rep(1/n, n)
#' ## Note the use of as.numeric(), to discard the "ts" class
#' ## of the result from stats::filter().
#' as.numeric(stats::filter(x, f, ...))
#' stats::filter(x, f, ...)
#' }
#' casts <- ctdFindProfiles(towyo, smoother=movingAverage)
#' }
Expand Down Expand Up @@ -1571,7 +1569,7 @@ ctdFindProfiles <- function(x, cutoff=0.5, minLength=10, minHeight=0.1*diff(rang
} else {
stop("direction must be either \"ascending\" or \"descending\"") # cannot reach here
}
if (debug>100) {
if (debug>100) { # HIDDEN feature, may be removed at any time
par(mar=c(3,3,1,1),mgp=c(2,0.7,0))
plot(pressure,type='l')
lines(ps,col=3, lty='dotted')
Expand Down Expand Up @@ -1610,27 +1608,27 @@ ctdFindProfiles <- function(x, cutoff=0.5, minLength=10, minHeight=0.1*diff(rang
oceDebug(debug, "end:", head(end[keep]), "... (using minHeight)\n")
indices <- data.frame(start=start[keep], end=end[keep])

if (debug>100) {
if (debug>100) { # HIDDEN feature, may be removed at any time
abline(v=start, col='green', lwd=2)
abline(v=end, col='red', lwd=2)
}

if (debug) print(head(indices))


if (is.logical(arr.ind) && arr.ind) {
oceDebug(debug, "} # ctdFindProfiles()\n", sep="", unindent=1)
return(indices)
} else {
ncasts <- length(indices$start)
casts <- vector("list", ncasts)
npts <- length(x@data$pressure)
for (i in 1:ncasts) {
oceDebug(debug, "profile #", i, "of", ncasts, "\n")
if (debug>100) {
message("indices$start: ", paste(head(indices$start), collapse=" "))
message("indices$end: ", paste(head(indices$end), collapse=" "))
}
cast <- ctdTrim(x, "index", parameters=c(indices$start[i], indices$end[i]))
oceDebug(debug, "indices$start: ", paste(head(indices$start), collapse=" "))
oceDebug(debug, "indices$end: ", paste(head(indices$end), collapse=" "))
## extend indices to catch turnaround spots
e <- 1
iStart <- max(1L, indices$start[i] - e)
iEnd <- min(npts, indices$end[i] + e)
cast <- ctdTrim(x, "index", parameters=c(iStart, iEnd))
cast@processingLog <- processingLogAppend(cast@processingLog,
paste(paste(deparse(match.call()), sep="", collapse=""),
" # profile ", i, " of ", ncasts))
Expand Down
4 changes: 1 addition & 3 deletions man/ctdFindProfiles.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f3a430a

Please sign in to comment.