Skip to content

Compatibility break due to changes in s2dv_cube

Hi @all,

I open this issue for you to know that there will be a compatibility break due to the changes in the s2dv_cube object. It will affect all the CST_* prefix functions in the CSTools, CSIndicators and CSDownscale packages. The changes are currently under development in CSTools package develop-new_s2dv_cube branch. In CSIndicators the development will start soon in a new branch.

  • Approximate date when the changes will be in master: 01/03/2023
  • Approximate date of the release of CSIndicators v1.0.0 in CRAN and installation in BSC usual machines: 10/04/2023

With this calendar, the changes in the scripts can be done during March 2023.

New s2dv_cube object structure:

Example array of dimensions:
 dataset  member   sdate   ftime     lat     lon 
       1      15       6       3      22      53 

$data: [array with named dimensions]
$dims: [named vector with dimensions]
$coords
  # (same elements as dim(data))
  $dataset: [named indexes vector of dataset]
  $member: [named indexes vector of members]
  $sdate: [named vector of character string with sdates]
  $ftime: [named indexes vector of ftime]
  $lat: [named vector of latitudes]
  $lon: [named vector of longitudes]
$attrs
  $Variable 
    $variables [list of all the variables information]
    $varName [character string of the variable name from the input argument in Start(): var, vars]
  $Datasets [information of Datasets (name, initialization dates, ...)]
  $source_files [data path]
  $when [date when data has been loaded]
  $Dates: [array with named time dimensions with Dates of POSIXct class]
  $load_parameters: [input parameters of Load/Start function]

* In CST_* functions, if they need to use the values of lat/lon/Dates/etc., find the name in a pre-defined list. E.g., 
s2dv:::.KnownLonNames() has several possible options for longitude

** When `$Dates` is modified by functions SelectPeriodOnData/Dates() the original dates will be stored as attributes in element `$Dates`.

How to deal with the changes:

  1. How to create a new s2dv_cube with sample data to test:
dat <- 1 : (1 * 3 * 4 * 5 * 6 * 7)
dim(dat) <- c(dataset = 1, member = 3, sdate = 4, ftime = 5, lat = 6, lon = 7)
lon <- seq(0, 30, 5)
lat <- seq(0, 25, 5)
coords = list(lat = lat, lon = lon)
exp <- list(data = dat, coords = coords)
attr(exp, 'class') <- 's2dv_cube' 
  1. In CSIndicators, the only affectation in CST_ functions will be the change in the position of element $Dates: The difference will be that the old object has the Dates vector located in expL$Dates$start, whereas the new object has them in expL$attrs$Dates.
# Old s2dv_cube
time_exp <- exp$Dates$start
# New s2dv_cube
time_exp <- exp$attrs$Dates
  1. If you need further information of the changes you can test the new object by sourcing the functions to build the new object from CSTools package:
source("https://earth.bsc.es/gitlab/external/cstools/-/raw/develop-new_s2dv_cube/R/as.s2dv_cube.R")
source("https://earth.bsc.es/gitlab/external/cstools/-/raw/develop-new_s2dv_cube/R/zzz.R")

Sample data and examples

If you have doubts or suggestions you can leave a comment in this issue. Also, if you need some help with the scripts or revisions I am available at any time at the following mail address: eva.rifarovira@bsc.es.

Thank you and sorry for the inconvenience,
Eva

Edited by Eva Rifà