Skip to content

Start(): load multiple variables from one file

Start() is supposed to load the files that have one "main" variable to load and the variable should be in the file name. For example, tas_200011.nc should have tas as the variable to load, and the file name should have tas. The following example loads the files that have more than one "main" variable ('mean_bias', 'enscorr', 'rpss', 'crpss', 'enssprerr') and the file name doesn't have $var$. It still works without returning errors. But the metadata is not 100% correct (it only loads the first variable under $common.) and the returning warnings imply that Start() doesn't expect to have this file structure.

It may be a good start to develop the feature that loads the files with multiple variables inside.

repos <- '/esarchive/scratch/nmilders/scorecards_data/input_data/cross_validation/ecmwfs5/$clim$/scorecards_ecmwfs5_era5_$clim$-skill_1993-2016_s$smonth$.nc'
repos2 <- '/esarchive/scratch/nmilders/scorecards_data/input_data/cross_validation/dwds2/$clim$/scorecards_dwds2_era5_$clim$-skill_1993-2016_s$smonth$.nc'

# Multiple datasets
data <- Start(dat = list(list(name = 'dwds2', path = repos2),
                         list(name = 'ecmwfs5', path = repos)),
              # outer dimensions
              var = c('mean_bias', 'enscorr', 'rpss', 'crpss', 'enssprerr'),
              smonth = c(paste0('0', 1:9), 10:12),
              clim = c('tas'),
              # inner dimensions
              time = 'all',
              latitude =  'all',
              longitude = 'all',
              return_vars = list(longitude = 'dat',
                                 latitude = 'dat',
                                 time = NULL
              ), 
              retrieve = TRUE)