Skip to content

Commit

Permalink
Merge branch 'dk' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
dankelley committed Jun 4, 2018
2 parents 24d2014 + a512b90 commit 22b7855
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 13 deletions.
42 changes: 33 additions & 9 deletions R/section.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ setClass("section", contains="oce")
#' Multanovsky, undertaking a westward transect from the Mediterranean outflow
#' region across to North America, with a change of heading in the last few dozen
#' stations to run across the nominal Gulf Stream axis.
#' The data flags follow the WHP CTD convention, i.e. 1 for uncalibrated,
#' 2 for an acceptable measurement, 3 for a questionable measurement, 4
#' for a bad measurement, etc; see \url{https://www.nodc.noaa.gov/woce/woce_v3/wocedata_1/whp/exchange/exchange_format_desc.htm}
#' for further details.
#' The data flags follow the "WHP Bottle"convention, set by
#' \code{initializeFlagScheme(section, "WHP bottle")}; see
#' \url{https://www.nodc.noaa.gov/woce/woce_v3/wocedata_1/whp/exchange/exchange_format_desc.htm}
#' for more information on World Hydrographic Program flag conventions.
#'
#' @examples
#' \dontrun{
Expand Down Expand Up @@ -156,10 +156,12 @@ setMethod("initializeFlagScheme",
for (i in seq_along(object@data$station)) {
res@data$station[[i]] <- initializeFlagScheme(object@data$station[[i]], name, mapping, debug=debug-1)
}
res@processingLog <- processingLogAppend(res@processingLog,
paste("initializeFlagScheme(object",
", name=\"", name,
"\", mapping=", gsub(" ", "", paste(as.character(deparse(mapping))))))
res@processingLog <-
processingLogAppend(res@processingLog,
paste("initializeFlagScheme(object",
", name=\"", name,
"\", mapping=",
gsub("[ ]*", "", paste(as.character(deparse(mapping)))), ")", sep=""))
res
})

Expand Down Expand Up @@ -196,7 +198,7 @@ setMethod(f="summary",
if (numStations > 0) {
cat("Overview of stations\n```\n")
cat(sprintf("%5s %5s %8s %8s %7s %5s\n", "Index", "ID", "Lon", "Lat", "Levels", "Depth"))
for (i in 1:numStations) {
for (i in seq_len(numStations)) {
##stn <- object@data$station[[i]]
thisStn <- object@data$station[[i]]
id <- if (!is.null(thisStn@metadata$station) && "" != thisStn@metadata$station)
Expand All @@ -209,6 +211,28 @@ setMethod(f="summary",
length(thisStn@data$pressure), depth))
}
cat("```\n")
names <- names(object@data$station[[1]]@metadata$flags)
if (!is.null(names)) {
cat("* Data-quality flags\n")
width <- 1 + max(nchar(names))
## assume all stations have identical flags
for (name in names) {
padding <- rep(" ", width - nchar(name))
cat(" ", name, ":", padding, sep="")
flags <- NULL
for (i in seq_len(numStations)) {
flags <- c(flags, as.numeric(object[["station", i]][[paste(name, "Flag", sep="")]]))
}
flagTable <- table(flags)
flagTableLength <- length(flagTable)
if (flagTableLength) {
for (i in seq_len(flagTableLength)) {
cat("\"", names(flagTable)[i], "\"", " ", flagTable[i], "", sep="")
if (i != flagTableLength) cat(", ") else cat("\n")
}
}
}
}
} else {
cat("* No stations\n")
}
Expand Down
1 change: 1 addition & 0 deletions create_data/section/create_section.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ library(oce)
# download.file("https://cchdo.ucsd.edu/data/7872/a03_hy1.csv", "a03_hy1.csv")
section <- read.section("a03_hy1.csv", sectionId="a03", institute="SIO",
ship="R/V Professor Multanovskiy", scientist="Vladimir Tereschenkov")
section <- initializeFlagScheme(section, "WHP bottle")
save(section, file="section.rda")
tools::resaveRdaFiles("section.rda")
n <- length(section[['station',1]]@data)
Expand Down
Binary file modified data/section.rda
Binary file not shown.
8 changes: 4 additions & 4 deletions man/section.Rd

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

0 comments on commit 22b7855

Please sign in to comment.