Skip to content

CST_QuantileMapping() not preserving the "datetime" dimension

Hi @nperez

 I am using CST_QuantileMapping() on several start dates and I am saving the outputs to files with CST_SaveExp(), one file for each start date.  

The output files seem to have an issue in the "date-time" dimension: If you explore the file i.e. with cdo sinfov, you will see that the date-time information is wrong, with any file having the same start date. The date in the filename is correct, however.

I reported below an example to reproduce the data with the date-time issue.

Thanks a lot! Best, Silvia

exp <- list(name = 'experiment', path = infile)
obs <- list(name = 'observation',path = reffile)

exp %<-% CST_Load('prlr', exp=list(exp), obs=NULL, sdates =startDates, nmember = nens, storefreq = "daily", sampleperiod = 1, latmin =latn, latmax = latx, lonmin = lonn, lonmax = lonx, output = 'lonlat',nprocs=6)
obs %<-% CST_Load('prlr', exp=list(obs), obs=NULL, sdates =startDates, nmember = 1, storefreq = "daily", sampleperiod = 1, latmin =latn, latmax = latx, lonmin = lonn, lonmax = lonx, output = 'lonlat',nprocs=6)
dim(exp$data)
dim(obs$data)

# SplitDim 
print("Splitting ftime by month ...")
expm   <- CST_SplitDim(exp, split_dim = c('ftime'))
obsm   <- CST_SplitDim(obs, split_dim = c('ftime'))
dim(expm$data)
dim(obsm$data)

exp.qm  <- CST_QuantileMapping(expm,obsm, method = "QUANT", wet.day=F,sample_dims = c('member', 'sdate', 'ftime'))
dim(exp.qm$data)

# MergeDims
print("Restoring original dimensions ...")
exp.qmm <- CST_MergeDims(exp.qm, merge_dims=c("ftime", "monthly"), na.rm=TRUE)

print (paste("Save Bias-Adjusted data to", outdir))
CST_SaveExp(exp.qmm, outpath)