CDORegrid for 'native ocean curvilinear grid'
Hi @cdelgado
I was commenting with @aho on this code, so, I share it here.
library(startR)
library(s2dverification)
path <- '/esarchive/exp/CMIP6/dcppA-hindcast/cmcc-cm2-sr5/cmip6-dcppA-hindcast_i1p1/DCPP/CMCC/CMCC-CM2-SR5/dcppA-hindcast/$member$/Omon/$var$/gn/v20210312/$var$_*_s$sdate$-$member$_gn_$aux$.nc'
data <- startR::Start(dataset = path,
var = 'tos',
sdate = paste0(2000),
aux = 'all',
aux_depends = 'sdate',
j = 'all', #values(list(-90,90)),
i = 'all', #values(list(0,359.9)),
time = indices(1),
member = 'r1i1p1f1',
return_vars = list(j = NULL, i = NULL, latitude = NULL, longitude = NULL),
synonims = list(latitude = c('latitude'), longitude = 'longitude'),
num_procs = 1 , retrieve = T)
lons <- attributes(data)$Variables$common$longitude
lats <- attributes(data)$Variables$common$latitude
dim(lons)
dim(lats)
dim(data)
res <- CDORemap(data, lons, lats, grid = 'r100x50', method = 'bil', crop = FALSE)
This code works but the result needs to be corrected:
z <- res$data[1,1,1,1,,,1,1]
names(dim(z)) <- c('lon','lat')
image(seq(0,360, 360/50), seq(-88.2,88.2, (88.2*2)/100), z)
The result doesn't seem perfect either. In any case, some checks on the lon, lat dimension names are necessary at least.
I have found this site for more info on CDO usage: https://code.mpimet.mpg.de/boards/1/topics/741
@cdelgado, have you reviewed the result? Do you think this is the expected result? I am not familiar with 'r100x50' grid. Do you think it makes more sense to check this code with a different grid, like r360x180?
Cheers,
Núria