Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • startR startR
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 29
    • Issues 29
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 6
    • Merge requests 6
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Earth SciencesEarth Sciences
  • startRstartR
  • Issues
  • #68
Closed
Open
Issue created Aug 11, 2020 by aho@ahoMaintainer

Start(): return_vars of latitude and longitude is wrong when reordering

The problem happens when _reorder is used and return_vars = list(longitude = NULL, latitude = NULL). The metadata of lon and lat become only a vector and is global. When return_vars = list(longitude = 'dat', latitude = 'dat'), the metadata is complete and is regional. When _reorder is not used, the two ways have the same (as the second one, correct) metadata. The two methods should return the same metadata since there is only one data set. The only difference should be the structure. With NULL, the metadata is under $common; with 'dat', under $dat1.

path_exp <- '/esarchive/exp/ecmwf/system5_m1/daily_mean/$var$_f6h/$var$_$sdate$.nc'

lons.min <- 20
lons.max <- 30
lats.min <- 10
lats.max <- 20

# [reorder/NULL] WRONG
res <- Start(dat = list(list(path=path_exp)),
             var = 'psl',
             member = 'all',
             sdate = '19821201',
             time = indices(4),
             latitude = values(list(lats.min, lats.max)),
             latitude_reorder = Sort(decreasing = T),
             longitude_reorder = CircularSort(0, 360),
             longitude = values(list(lons.min, lons.max)),
             synonims = list(latitude=c('lat','latitude'),
                             longitude=c('lon','longitude'),
                             member=c('ensemble','realization')),
             return_vars = list(latitude = NULL,
                                longitude = NULL,
                                time = 'sdate'),
             retrieve = F)

> str(res)
...
  ..- attr(*, "Dimensions")= Named num [1:7] 1 1 25 1 1 35 37
  .. ..- attr(*, "names")= chr [1:7] "dat" "var" "member" "sdate" ...
  ..- attr(*, "Variables")=List of 2
  .. ..$ common:List of 3
  .. .. ..$ latitude : num [1:640] 89.8 89.5 89.2 88.9 88.7 ...
  .. .. ..$ longitude: num [1:1296] 0 0.278 0.556 0.833 1.111 ...
  .. .. ..$ time     : POSIXct[1:1], format: "1982-12-04 18:00:00"
  .. ..$ dat1  : NULL
  ..


# [reorder/dat] CORRECT
res <- Start(dat = list(list(path=path_exp)),
             var = 'psl',
             member = 'all',
             sdate = '19821201',
             time = indices(4),
             latitude = values(list(lats.min, lats.max)),
             latitude_reorder = Sort(decreasing = T),
             longitude_reorder = CircularSort(0, 360),
             longitude = values(list(lons.min, lons.max)),
             synonims = list(latitude=c('lat','latitude'),
                             longitude=c('lon','longitude'),
                             member=c('ensemble','realization')),
             return_vars = list(latitude = 'dat',
                                longitude = 'dat',
                                time = 'sdate'),
             retrieve = F)

> str(res)
...
  ..- attr(*, "Dimensions")= Named num [1:7] 1 1 25 1 1 35 37
  .. ..- attr(*, "names")= chr [1:7] "dat" "var" "member" "sdate" ...
  ..- attr(*, "Variables")=List of 2
  .. ..$ common:List of 1
  .. .. ..$ time: POSIXct[1:1], format: "1982-12-04 18:00:00"
  .. ..$ dat1  :List of 2
  .. .. ..$ latitude : num [1:35(1d)] 19.8 19.5 19.3 19 18.7 ...
  .. .. .. ..- attr(*, "variables")=List of 1
  .. .. .. .. ..$ latitude:List of 7
  .. .. .. .. .. ..$ ndims        : num 1
  .. .. .. .. .. ..$ size         : int 640
  .. .. .. .. .. ..$ units        : chr "degrees_north"
  .. .. .. .. .. ..$ dim          :List of 1
  .. .. .. .. .. .. ..$ :List of 10
  .. .. .. .. .. .. .. ..$ name         : chr "latitude"
  .. .. .. .. .. .. .. ..$ len          : int 640
  .. .. .. .. .. .. .. ..$ unlim        : logi FALSE
  .. .. .. .. .. .. .. ..$ group_index  : int 1
  .. .. .. .. .. .. .. ..$ group_id     : int 65536
  .. .. .. .. .. .. .. ..$ id           : int 0
  .. .. .. .. .. .. .. ..$ dimvarid     :List of 5
  .. .. .. .. .. .. .. .. ..$ id         : int 0
  .. .. .. .. .. .. .. .. ..$ group_index: int 1
  .. .. .. .. .. .. .. .. ..$ group_id   : int 65536
  .. .. .. .. .. .. .. .. ..$ list_index : num -1
  .. .. .. .. .. .. .. .. ..$ isdimvar   : logi TRUE
  .. .. .. .. .. .. .. .. ..- attr(*, "class")= chr "ncid4"
  .. .. .. .. .. .. .. ..$ units        : chr "degrees_north"
  .. .. .. .. .. .. .. ..$ vals         : num [1:640(1d)] 89.8 89.5 89.2 88.9 88.7 ...
  .. .. .. .. .. .. .. ..$ create_dimvar: logi TRUE
  .. .. .. .. .. .. .. ..- attr(*, "class")= chr "ncdim4"
  .. .. .. .. .. ..$ standard_name: chr "latitude"
  .. .. .. .. .. ..$ long_name    : chr "latitude"
  .. .. .. .. .. ..$ axis         : chr "Y"
  .. .. ..$ longitude: num [1:37(1d)] 20 20.3 20.6 20.8 21.1 ...
  .. .. .. ..- attr(*, "variables")=List of 1
  .. .. .. .. ..$ longitude:List of 7
  .. .. .. .. .. ..$ ndims        : num 1
  .. .. .. .. .. ..$ size         : int 1296
  .. .. .. .. .. ..$ units        : chr "degrees_east"
  .. .. .. .. .. ..$ dim          :List of 1
  .. .. .. .. .. .. ..$ :List of 10
  .. .. .. .. .. .. .. ..$ name         : chr "longitude"
  .. .. .. .. .. .. .. ..$ len          : int 1296
  .. .. .. .. .. .. .. ..$ unlim        : logi FALSE
  .. .. .. .. .. .. .. ..$ group_index  : int 1
  .. .. .. .. .. .. .. ..$ group_id     : int 65536
  .. .. .. .. .. .. .. ..$ id           : int 1
  .. .. .. .. .. .. .. ..$ dimvarid     :List of 5
  .. .. .. .. .. .. .. .. ..$ id         : int 1
  .. .. .. .. .. .. .. .. ..$ group_index: int 1
  .. .. .. .. .. .. .. .. ..$ group_id   : int 65536
  .. .. .. .. .. .. .. .. ..$ list_index : num -1
  .. .. .. .. .. .. .. .. ..$ isdimvar   : logi TRUE
  .. .. .. .. .. .. .. .. ..- attr(*, "class")= chr "ncid4"
  .. .. .. .. .. .. .. ..$ units        : chr "degrees_east"
  .. .. .. .. .. .. .. ..$ vals         : num [1:1296(1d)] 0 0.278 0.556 0.833 1.111 ...
  .. .. .. .. .. .. .. ..$ create_dimvar: logi TRUE
  .. .. .. .. .. .. .. ..- attr(*, "class")= chr "ncdim4"
  .. .. .. .. .. ..$ standard_name: chr "longitude"
  .. .. .. .. .. ..$ long_name    : chr "longitude"
  .. .. .. .. .. ..$ axis         : chr "X"
  ..

@nperez, could you confirm if my opinion makes sense or not? Thanks!

Cheers,
An-Chi

Ps., this issue is similar to #67 (closed). When reordering or transformation is applied, the metadata is modified.

Edited Aug 11, 2020 by aho
Assignee
Assign to
Time tracking