Skip to content

Commit

Permalink
Merge branch 'develop' into rename
Browse files Browse the repository at this point in the history
  • Loading branch information
dankelley committed Nov 7, 2024
2 parents 2be8254 + 0bbabfe commit 0de4e22
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
13 changes: 9 additions & 4 deletions R/oce.R
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,13 @@ oce.plot.ts <- function(
# Handle 'simplify' argument
nx <- length(x)
if (type == "l" && is.numeric(simplify) && nx > (5L * simplify)) {
# simplification works by replacing all the points in each sub-interval
# with just two points: one for the minimum y value there, and the other
# for the maximum y value there. (NA is used if all the data in the
# interval are missing.) This way, the graph displays the data quite
# faithfully in most cases. By contrast, if we instead used, say, the
# mean y in each interval, the curve could get smoothed enough to
# be unrepresentative.
warning("simplifying a large dataset; set simplify=NA to see raw data\n")
xgrid <- seq(min(x, na.rm = TRUE), max(x, na.rm = TRUE), length.out = simplify)
df <- data.frame(x, y)
Expand All @@ -1286,6 +1293,8 @@ oce.plot.ts <- function(
tz <- attr(x, "tzone") # cause gridded x to inherit timezone from original x
x <- rep(unname(sapply(dfSplit, function(DF) if (length(DF$x) > 2) mean(DF$x, na.rm = TRUE) else NA)), each = 2)
x <- numberAsPOSIXct(x, tz = tz)
# FIXME: I think thhis might be faster if another 'apply' function were
# used, to return 2 values, but I (DEK) can't recall what that function is.
ymin <- unname(sapply(
dfSplit,
function(DF) {
Expand All @@ -1299,10 +1308,6 @@ oce.plot.ts <- function(
}
))
y <- as.vector(rbind(ymin, ymax))
# Remove any segments for which min and max could not be computed
bad <- !is.finite(y)
x <- x[!bad]
y <- y[!bad]
}
xrange <- range(x, na.rm = TRUE)
yrange <- range(y, finite = TRUE)
Expand Down
4 changes: 2 additions & 2 deletions R/sealevel.R
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,8 @@ setMethod(
xx@data[[i]] <- x@data[[i]][look]
}
if (any(is.finite(xx@data$elevation))) {
xlim <- if (xlimGiven) xlim else (range(x@data$time, na.rm = TRUE))
ylim <- if (ylimGiven) ylim else (range(x@data$elevation, na.rm = TRUE))
xlim <- if (xlimGiven) xlim else (range(xx@data$time, na.rm = TRUE))
ylim <- if (ylimGiven) ylim else (range(xx@data$elevation, na.rm = TRUE))
atWeek <- seq(from = from, to = to, by = "week")
atDay <- seq(from = from, to = to, by = "day")
plot(xx@data$time, xx@data$elevation,
Expand Down
7 changes: 1 addition & 6 deletions R/tides.R
Original file line number Diff line number Diff line change
Expand Up @@ -1579,17 +1579,12 @@ tidem <- function(
icBad <- NULL
sdCriterion <- 1e-2
oceDebug(debug, vectorShow(sdCriterion))
# 20230122 danS <- danC <- NULL
for (i in 1:nc) {
# 20230122 oceDebug(debug+1, "setting ", i, "-th coefficient (name=", name[i], " period=", 1/freq[i], " h)", "\n", sep="")
ft <- freq[i] * hour2pi
C <- cos(ft)
S <- sin(ft)
sdS <- sd(S)
sdC <- sd(C)
# 20230122 danS <- c(danS, sdS) # FIXME: remove
# 20230122 danC <- c(danC, sdC) # FIXME: remove
# 20230122 oceDebug(debug+1, sprintf(" sdC %.4g; sdS %.4g\n", sdC, sdS))
# Find whether anything is uncomputable. We ignore Z0 because that is handled later.
if (name[i] != "Z0" && (sdS < sdCriterion || sdC < sdCriterion)) {
oceDebug(debug, " ** uncomputable at ", name[i], " (period ", 1 / freq[i], "h) **\n")
Expand Down Expand Up @@ -2086,7 +2081,7 @@ webtide <- function(
plot = TRUE, tformat, debug = getOption("oceDebug"), ...) {
debug <- max(0, min(floor(debug), 2))
oceDebug(debug, "webtide(action=\"", action, "\", ...)\n",
sep = "", unindent = 1
sep = "", unindent = 1
)
rpd <- atan2(1, 1) / 45 # radians per degree
action <- match.arg(action)
Expand Down

0 comments on commit 0de4e22

Please sign in to comment.