dankelley / oce

R package for oceanographic processing
http://dankelley.github.io/oce/
GNU General Public License v3.0
143 stars 42 forks source link

Error when opening odf file. #1311

Closed atcogswell closed 7 years ago

atcogswell commented 7 years ago

Short summary of problem

I receive this error when I try to plot a ctd profile using oce:

Error in plot.window(...) : need finite 'ylim' values
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf

Details (optional)

I can see the data and metadata for the ODF file after it is saved as a variable but the error results on plot. many other ODF files plotted fine in a loop I had created before I encountered this problem.

What you did

library(oce)
test<-read.odf("CTD_HUD2011004_017_01_DN.ODF")
plot(test)

Associated File

CTD_HUD2011004_017_01_DN.zip

What you expected to happen

normal four panel plot.

What happened

This funky plot was produced:

weirdplot

How urgent is this?

I can skip the files for now but I'd like to know why they won't plot so I can eventually adjust my code, so not urgent.

Output from sessionInfo()

R version 3.2.5 (2016-04-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_Canada.1252  LC_CTYPE=English_Canada.1252    LC_MONETARY=English_Canada.1252
[4] LC_NUMERIC=C                    LC_TIME=English_Canada.1252    

attached base packages:
[1] tools     stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] lubridate_1.6.0    htmlwidgets_0.8    htmltools_0.3.5    dplyr_0.5.0        mapview_1.2.0     
 [6] leaflet_1.1.0.9000 rgeos_0.3-21       maptools_0.9-1     dismo_1.1-4        raster_2.5-8      
[11] rgdal_1.2-5        ocedata_0.1.3      sp_1.2-3           oce_0.9-22         testthat_1.0.2    
[16] gsw_1.0-3         

loaded via a namespace (and not attached):
 [1] lattice_0.20-33     colorspace_1.3-1    stats4_3.2.5        viridisLite_0.1.3  
 [5] yaml_2.1.14         R.oo_1.21.0         foreign_0.8-66      DBI_0.5-1          
 [9] R.utils_2.5.0       RColorBrewer_1.1-2  foreach_1.4.3       plyr_1.8.4         
[13] stringr_1.1.0       munsell_0.4.3       gtable_0.2.0        R.methodsS3_1.7.1  
[17] codetools_0.2-14    latticeExtra_0.6-28 httpuv_1.3.3        crosstalk_1.0.0    
[21] gdalUtils_2.0.1.7   markdown_0.8        Rcpp_0.12.8         xtable_1.8-2       
[25] scales_0.4.1        satellite_0.2.0     jsonlite_1.2        webshot_0.4.0      
[29] mime_0.5            ggplot2_2.2.0       png_0.1-7           digest_0.6.10      
[33] stringi_1.1.2       shiny_1.0.0         grid_3.2.5          magrittr_1.5       
[37] lazyeval_0.2.0      tibble_1.2          crayon_1.3.2        assertthat_0.1     
[41] iterators_1.0.8     R6_2.2.0           
dankelley commented 7 years ago

Does it work if you do

plot(as.ctd(test))

?

dankelley commented 7 years ago

The problem is that it doesn't know that it's a CTD file. It just knows it has time and other stuff, so it tries a stack of timeseries plots.

I get as below when I convert with as.ctd():

screen shot 2017-10-18 at 2 47 53 pm
dankelley commented 7 years ago

The problem with ylim is that some of the data "columns" are all NA values. I will change the code to detect that. I learned of that problem by using summary(test), which showed (in part):

* Data

                               Min.    Mean     Max.    Dim. OriginalName
    scan                       748     6823.2   11211   153  CNTR_01     
    pressure [dbar]            3       79       155     153  PRES_01     
    temperature [°C, IPTS-68]  1.1863  2.6757   6.5404  153  TEMP_01     
    conductivity [S/m]         0.6325  0.67582  0.78447 153  CRAT_01     
    temperature2 [°C, IPTS-68] 1.2299  2.6764   6.5465  153  TEMP_02     
    conductivity2 [S/m]        0.66428 0.71131  0.7847  153  CRAT_02     
    altimeter [m]              NA      NA       NA      153  ALTB_01     
    fluorometer [μg/l]         NA      NA       NA      153  FLOR_01     
    oxygenVoltage [V]          2.2209  2.736    2.8973  153  OXYV_01     
atcogswell commented 7 years ago

OK as.ctd did the trick. I've done this before but it must have slipped my mind.

A

dankelley commented 7 years ago

I changed the arg in my updated plot method, so now a person can use either plot(odf, blanks=TRUE) or plot(odf, blanks=FALSE), and in neither case will an error result.

PS. I just noticed that read.oce() autodetects that this is a CTD file, so that might be why you were confused, @atcogswell. The idea is that read.oce() does its best to detect types, but that read.X() returns something of type X ... that's why read.odf() does not return a CTD type, in this case, but read.oce() does.