CDORemap: Wrong number of output latitudes when 'lats' are sorted in decreasing order
Hi @erifarov,
Summary
I'm opening this issue because I have found some strange behavior in CDORemap(). I wanted to regrid a global map to r360x181, but realized that the dimensions of the output were num [1:3, 1:179, 1:360]
instead of the expected num [1:3, 1:181, 1:360]
, with the latitudes going from -89 to 89 instead of -90 to 90.
After some investigation, I found that this only happens when the values in the lats parameters are sorted in decreasing order (positive to negative). The result is as expected when the latitudes are sorted in increasing order (negative to positive).
Example
library(s2dv)
## 1. Decreasing sort
dims <- 3*180*360
my_array <- rnorm(dims)
dim(my_array) <- c(time = 3, latitude = 180, longitude = 360)
lats <- seq(89.5, -89.5, -1)
lons <- seq(0.5, 359.5, 1)
my_remapped_array <- CDORemap(my_array, lats = lats, lons = lons, grid = 'r360x181', method = 'bil')
str(my_remapped_array)
# List of 3
# $ data_array: num [1:3, 1:179, 1:360] -0.00979 -0.53087 -0.06919 0.45521 0.11862 ...
# $ lons : num [1:360(1d)] 0 1 2 3 4 5 6 7 8 9 ...
# $ lats : num [1:179(1d)] -89 -88 -87 -86 -85 -84 -83 -82 -81 -80 ...
## 2. Increasing sort
lats <- seq(-89.5, 89.5, 1)
my_remapped_array <- CDORemap(my_array, lats = lats, lons = lons, grid = 'r360x181', method = 'bil')
str(my_remapped_array)
# List of 3
# $ data_array: num [1:3, 1:181, 1:360] 1.226 -0.306 0.158 0.417 0.544 ...
# $ lons : num [1:360(1d)] 0 1 2 3 4 5 6 7 8 9 ...
# $ lats : num [1:181(1d)] -90 -89 -88 -87 -86 -85 -84 -83 -82 -81 ...
Module and Package Version
- R/4.1.2
- CDO (I have tried with versions 1.6.3, 1.9.5, 1.9.7.1, 1.9.8 and 1.9.10)
- s2dv 2.0.0
Machines: WS and Nord3v2
Victòria