Skip to content

Commit

Permalink
compress sample ODF files
Browse files Browse the repository at this point in the history
  • Loading branch information
dankelley committed May 31, 2018
1 parent eeef6c4 commit d682d2c
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 1,946 deletions.
4 changes: 2 additions & 2 deletions R/odf.R
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ ODF2oce <- function(ODF, coerce=TRUE, debug=getOption("oceDebug"))
#' # so we must alter the unit before converting to a CTD object. Note that
#' # read.odf() on this data file produces a warning suggesting that the user
#' # repair the unit, using the method outlined here.
#' odf <- read.odf(system.file("extdata", "CTD_BCD2014666_008_1_DN.ODF", package="oce"))
#' odf <- read.odf(system.file("extdata", "CTD_BCD2014666_008_1_DN.ODF.gz", package="oce"))
#' ctd <- as.ctd(odf) ## so we can e.g. extract potential temperature
#' ctd[["conductivityUnit"]] <- list(unit=expression(), scale="")
#' #
Expand Down Expand Up @@ -1083,7 +1083,7 @@ read.odf <- function(file, columns=NULL, debug=getOption("oceDebug"))
res@metadata$header <- NULL

## catch erroneous units on CRAT, which should be in a ratio, and hence have no units.
## This is necessary for the sample file inst/extdata/CTD_BCD2014666_008_1_DN.ODF
## This is necessary for the sample file inst/extdata/CTD_BCD2014666_008_1_DN.ODF.gz
if (length(grep("CRAT", ODFnames))) {
which <- grep("CRAT", ODFnames)
for (w in which) {
Expand Down
2 changes: 1 addition & 1 deletion create_data/odf/create_odf.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
library(oce)
odf <- read.oce("../../inst/extdata/CTD_BCD2014666_008_1_DN.ODF")
odf <- read.oce("../../inst/extdata/CTD_BCD2014666_008_1_DN.ODF.gz")
save(odf, file="odf.rda")
tools::resaveRdaFiles("odf.rda")

Expand Down
969 changes: 0 additions & 969 deletions inst/extdata/CTD_BCD2014666_008_1_DN.ODF

This file was deleted.

Binary file added inst/extdata/CTD_BCD2014666_008_1_DN.ODF.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion man/read.odf.Rd

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

969 changes: 0 additions & 969 deletions tests/testthat/CTD_BCD2014666_008_1_DN_altered.ODF

This file was deleted.

Binary file not shown.
2 changes: 1 addition & 1 deletion tests/testthat/test_flags.R
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ test_that("ctd flag with subset() (issue 1410)", {
})

test_that("odf flag with subset() (issue 1410)", {
file <- system.file("extdata", "CTD_BCD2014666_008_1_DN.ODF", package="oce")
file <- system.file("extdata", "CTD_BCD2014666_008_1_DN.ODF.gz", package="oce")
odf <- expect_warning(read.odf(file), "should be unitless")
## # Find a region with interesting flags
## > which(odf[["sigmaThetaFlag"]]!=1)
Expand Down
37 changes: 34 additions & 3 deletions tests/testthat/test_odf.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ context("ODF")
## of distinct NULL_VALUE entries, one per data item, and by having the
## first few data entries modified. This tests the ability to handle
## a different code for each data type.
test_that("ODF file", {
expect_warning(d <- read.ctd.odf("CTD_BCD2014666_008_1_DN_altered.ODF"),
test_that("ODF CTD file", {
expect_warning(d <- read.ctd.odf("CTD_BCD2014666_008_1_DN_altered.ODF.gz"),
"\"CRAT_01\" should be unitless")
expect_equal(d[["temperatureUnit"]]$unit, expression(degree*C))
expect_equal(d[["temperatureUnit"]]$scale, "IPTS-68")
Expand Down Expand Up @@ -68,10 +68,41 @@ test_that("ODF file", {
expect_equal(17, which(is.na(d[["oxygenFlag"]])))
## Next will be NA for bad pressure, salinity, temperature, but NOT
## for the altered bad sigmaTheta. This is because oce *calculates*
## sigmaTheta.
## sigmaTheta for the CTD case ... but contrast this with the
## next test.
expect_equal(c(2, 4, 14), which(is.na(d[["sigmaTheta"]]))) # computed
expect_equal(18, which(is.na(d[["SIGP_01"]]))) # original data
expect_equal(19, which(is.na(d[["sigmaThetaFlag"]])))

})

test_that("ODF CTD file (not as CTD)", {
expect_warning(d <- read.odf("CTD_BCD2014666_008_1_DN_altered.ODF.gz"),
"\"CRAT_01\" should be unitless")
## First, check as in the previous test.
expect_equal( 1, which(is.na(d[["scan"]])))
expect_equal( 2, which(is.na(d[["pressure"]])))
expect_equal( 3, which(is.na(d[["pressureFlag"]])))
expect_equal( 4, which(is.na(d[["temperature"]])))
expect_equal( 5, which(is.na(d[["temperatureFlag"]])))
expect_equal( 6, which(is.na(d[["conductivity"]])))
expect_equal( 7, which(is.na(d[["conductivityFlag"]])))
expect_equal( 8, which(is.na(d[["oxygenVoltage"]])))
expect_equal( 9, which(is.na(d[["oxygenVoltageFlag"]])))
expect_equal(10, which(is.na(d[["fluorometer"]])))
expect_equal(11, which(is.na(d[["fluorometerFlag"]])))
expect_equal(12, which(is.na(d[["par"]])))
expect_equal(13, which(is.na(d[["parFlag"]])))
expect_equal(14, which(is.na(d[["salinity"]])))
expect_equal(15, which(is.na(d[["salinityFlag"]])))
expect_equal(16, which(is.na(d[["oxygen"]])))
expect_equal(17, which(is.na(d[["oxygenFlag"]])))
## Now, for the part that's different: in the present case,
## the sigmaTheta value will be AS READ IN, not calculated.
## That calculation only works when it knows it is a CTD. Therefore,
## the next tests are different from in the previous block.
expect_equal(18, which(is.na(d[["sigmaTheta"]]))) # computed
expect_equal(18, which(is.na(d[["SIGP_01"]]))) # original data
expect_equal(19, which(is.na(d[["sigmaThetaFlag"]])))

})

0 comments on commit d682d2c

Please sign in to comment.