Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arbitrary dimension names returned by griddap #105

Closed
chrisdane opened this issue Feb 4, 2022 · 3 comments
Closed

arbitrary dimension names returned by griddap #105

chrisdane opened this issue Feb 4, 2022 · 3 comments

Comments

@chrisdane
Copy link

Hi

I am confused how griddap() handles dimension names.

info <- rerddap::info("ncdcOisst21Agg_LonPM180")
varname <- "sst" # sea surface temperature
strsplit(info$alldata[[varname]]$value[1], ", ")[[1]] # dimension names returned by the `info` object
#[1] "time"      "zlev"      "latitude"  "longitude"
data <- rerddap::griddap(info, 
                         time=c("last", "last"), 
                         zlev=c("last", "last"), 
                         latitude=c("last", "last"), 
                         longitude=c("last", "last"), 
                         fields=varname)

The returned dimension names from the netcdf object are the same as from the info object:

names(data$summary$dim)
#[1] "time"      "zlev"      "latitude"  "longitude"

but the returned dimension names of the data.frame object storing the actual dimension and data values are different:

names(data$data)
#[1] "time" "lat"  "lon"  "zlev" "sst"

Suddenly "longitude" is now "lon" and "latitude" is "lat".

How am I supposed to use griddap in an automated way if suddenly names change?

Thanks a lot and kind regards,
Chris

Session Info
R version 4.1.0 (2021-05-18)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server release 6.10 (Santiago)

Matrix products: default
BLAS/LAPACK: /sw/spack-rhel6/miniforge3-4.9.2-3-Linux-x86_64-pwdbqi/lib/libopenblasp-r0.3.12.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
 [1] microbenchmark_1.4.9 dplyr_1.0.7          rerddap_0.8.0       
 [4] oce_1.5-0            gsw_1.0-6            fields_13.3         
 [7] viridis_0.6.2        viridisLite_0.4.0    spam_2.8-0          
[10] ncdf4_1.19           colorout_1.2-2      

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.8        pillar_1.6.4      compiler_4.1.0    tools_4.1.0      
 [5] digest_0.6.29     dotCall64_1.0-1   jsonlite_1.7.3    lifecycle_1.0.1  
 [9] tibble_3.1.6      gtable_0.3.0      pkgconfig_2.0.3   rlang_0.4.12     
[13] cli_3.1.1         DBI_1.1.1         curl_4.3.2        crul_1.1.0       
[17] gridExtra_2.3     stringr_1.4.0     xml2_1.3.3        rappdirs_0.3.3   
[21] generics_0.1.1    vctrs_0.3.8       maps_3.4.0        triebeard_0.3.0  
[25] grid_4.1.0        tidyselect_1.1.1  data.table_1.14.2 httpcode_0.3.0   
[29] glue_1.6.0        R6_2.5.1          fansi_1.0.2       hoardr_0.5.2     
[33] ggplot2_3.3.5     purrr_0.3.4       magrittr_2.0.1    urltools_1.7.3   
[37] scales_1.1.1      ellipsis_0.3.2    assertthat_0.2.1  colorspace_2.0-2 
[41] utf8_1.2.2        stringi_1.7.6     munsell_0.5.0     crayon_1.4.2
@rmendels
Copy link
Collaborator

rmendels commented Feb 4, 2022

@chrisdane Good question and I don't have an answer offhand. I am going to have to get into the code and see what is going on.

@rmendels
Copy link
Collaborator

rmendels commented Feb 4, 2022

@chrisdane - I am learning the inners of the code as I go, and lo and behold the "lon" and "lat" are baked into the code. I am not certain why this is so. So it is consistent in what it returns, but it is not consistent with the dataset info which is not good. I am pretty certain I know the fix, but it may take me a couple of days to implement it and test it.

Thanks for catching this.

@rmendels
Copy link
Collaborator

rmendels commented Oct 7, 2022

@chrisdane - Sorry this took so long. In wanting to fix this I wanted to allow 'rerddap' to "melt" other grids besides lat-lon. All of this is in 'rerddap v1.0.0' which is available from CRAN. The names in the returned structure now match those in other sources.

@rmendels rmendels closed this as completed Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants