hypertidy / ncmeta

Tidy NetCDF metadata
https://hypertidy.github.io/ncmeta/
11 stars 5 forks source link

Handle NULL response from divine_XYZT. fixes #19 #20

Closed dblodgett-usgs closed 5 years ago

dblodgett-usgs commented 5 years ago

This is the quick and dirty fix. From here we could add a little inference to deal with the "unknown" column in the response.

> coord_vars
# A tibble: 8 x 6
  variable X     Y     Z     T     unkown
  <chr>    <chr> <chr> <chr> <chr> <chr> 
1 time     NA    NA    NA    time  NA    
2 zlev     NA    NA    NA    NA    zlev  
3 lat      NA    lat   NA    NA    NA    
4 lon      lon   NA    NA    NA    NA    
5 sst      lon   lat   NA    time  zlev  
6 anom     lon   lat   NA    time  zlev  
7 err      lon   lat   NA    time  zlev  
8 ice      lon   lat   NA    time  zlev  
mdsumner commented 5 years ago

I see another problem with a file I can't share, but can also reproduce the same error with some rasterwise files:

fs <- list.files("../rasterwise", pattern = "nc$", full.names = TRUE, recursive = TRUE)
for (i in seq_along(fs)) nc_coord_var(fs[i])
#fs[i]
#[1] "../rasterwise/extdata/high-dim/test-1.nc"
nc_coord_var(f)
 Error in if (grepl(lon_units, att_sub[["units"]], ignore.case = TRUE)) return("X") : 
  argument is of length zero 

Each of these files raises the error:

"../rasterwise/extdata/high-dim/test-1.nc"
"../rasterwise/extdata/oscar_gdr_5d1993.nc"            
"../rasterwise/extdata/rectilinear/CM2.1_regionmask.nc" 
"../rasterwise/extdata/swapped/3A-DAY.nc"              
"../rasterwise/extdata/timeseries.nc"  
mdsumner commented 5 years ago

Sorry, I should have made another issue with this ... let me know what you prefer