Issue when loading regions in different files with StartR
I have an issue when loading different files with StartR.
My experiments are totally messy, I had several issues when producing them.
The results is that for instance for a42y
, I produced the diagnostic outputs (computed with Earthdiagnostic
) at different times depending on when the outputs were produced. And lately, because I had some issues running Earthdiagnostic
on Nord3_v1
, I modified some diagnostics, in particular those computing spatial mean. Because of that, I don't have anymore the same number of regions in the different netcdf files.
My issue here is that when I'm loading the files with StartR, because it will look in the first file for the correct index for the corresponding region, it will keep this index for all the other files but the index for that specific region can change depending on the file.
Is there another way I can load the files to be sure it's the correct region (and not the corresponding index of the first file)?
Here is my script:
# arguments - sorry for that
vari <- 'tosmean'
membs_num <- c(seq(24,28)) # c(seq(21,25))
membs <- paste0('r', membs_num, 'i1p1f1', sep="")
reg <- 'Nino3.4'
startdates <- as.character(c(seq(2000,2015)))
init_month <- 5
length_forecast <- 4
forecast_month <- c(seq(init_month,(init_month+length_forecast-1)))
# load
path_SR <- paste0('/esarchive/exp/ecearth/a42y/diags/DCPP/EC-Earth-Consortium/EC-Earth3/dcppA-hindcast/$memb$/Omon/$var$/gn/v*/$var$_Omon_EC-Earth3_dcppA-hindcast_s$sdate$-$memb$_gn_$chunk$.nc')
data_exp_call <- startR::Start(dat = path_SR,
var = vari,
memb = membs,
region = reg,
region_var = 'region',
sdate = startdates,
time = c(1:length(forecast_month)),
chunk = 'all',
chunk_depends = 'sdate',
time_across = 'chunk',
merge_across_dims = TRUE,
return_vars = list(time=c('sdate','chunk'), region=NULL),
retrieve = T)
And for instance, when loading for these specific members, you can see that for the last members, it's not the correct region that is loaded:
print(data_exp_call[1,1,,1,1,])
A matrix: 5 × 4 of type dbl
26.872463 26.537910 25.68533 24.98377
26.873310 26.595207 26.07232 25.37357
7.453971 9.324999 11.99820 13.20359
7.439529 9.103257 11.39058 12.82224
7.435360 9.284738 11.71200 13.01144)
Thanks!
FYI @pabretonniere