DownRToS2dv <- function(data_exp, data_obs) {
  library(abind)
  names(dim(data_exp$Data)) <- attr(data_exp$Data, 'dimensions')
  names(dim(data_obs$Data)) <- attr(data_obs$Data, 'dimensions')
  start_indices <- which(data_exp$Dates$start %in% gsub("11-01", "12-01", data_exp$InitializationDates))
  total_dates <- length(data_exp$Dates$start)
  ftime_amounts <- c(start_indices, total_dates + 1)[2:(length(start_indices) + 1)] - start_indices
  largest_ftime <- max(ftime_amounts)
  # Reordering data
  new_data_exp <- data_exp$Data
  new_data_obs <- data_obs$Data
  new_dates <- data_exp$Dates
  chunk_dims_exp <- dim(data_exp$Data)
  chunk_dims_obs <- dim(data_obs$Data)
  for (i in 1:length(ftime_amounts)) {
    ftime_amount <- ftime_amounts[i]
    if (ftime_amount < largest_ftime) {
      # Fill in exp array and dates
      step_new_data_exp <- NULL
      step_new_dates_s <- NULL
      step_new_dates_e <- NULL
      #if (largest_ftime * (i - 1) + ftime_amount > 0) {
      step_new_data_exp <- Subset(new_data_exp, 'time', 1:(largest_ftime * (i - 1) + ftime_amount))
      step_new_dates_s <- new_dates$start[1:(largest_ftime * (i - 1) + ftime_amount)]
      step_new_dates_e <- new_dates$end[1:(largest_ftime * (i - 1) + ftime_amount)]
      #}
      chunk_dims_exp['time'] <- largest_ftime - ftime_amount
      step_new_data_exp <- abind(step_new_data_exp, array(dim = chunk_dims_exp), along = which(names(chunk_dims_exp) == 'time'))
      names(dim(step_new_data_exp)) <- names(chunk_dims_exp)
      step_new_dates_s <- c(step_new_dates_s, rep(NA, chunk_dims_exp['time']))
      step_new_dates_e <- c(step_new_dates_e, rep(NA, chunk_dims_exp['time']))
      if (dim(new_data_exp)[which(names(chunk_dims_exp) == 'time')] > (largest_ftime * (i - 1) + ftime_amount)) {
        step_new_data_exp <- abind(step_new_data_exp, 
                               Subset(new_data_exp, 'time', (largest_ftime * (i - 1) + ftime_amount + 1):
                                                        (dim(new_data_exp)[which(names(chunk_dims_exp) == 'time')])),
                               along = which(names(chunk_dims_exp) == 'time'))
        names(dim(step_new_data_exp)) <- names(chunk_dims_exp)
        step_new_dates_s <- c(step_new_dates_s, 
                              new_dates$start[(largest_ftime * (i - 1) + ftime_amount + 1):
                                              (dim(new_data_exp)[which(names(chunk_dims_exp) == 'time')])]
                             )
        step_new_dates_e <- c(step_new_dates_e, 
                              new_dates$end[(largest_ftime * (i - 1) + ftime_amount + 1):
                                            (dim(new_data_exp)[which(names(chunk_dims_exp) == 'time')])]
                             )
      }
      new_dates <- list(start = step_new_dates_s,
                        end = step_new_dates_e)
      new_data_exp <- step_new_data_exp
      rm(step_new_data_exp)
      rm(step_new_dates_s)
      rm(step_new_dates_e)
      gc()
      # Fill in obs array
      step_new_data_exp <- NULL
      if (largest_ftime * (i - 1) + ftime_amount > 0) {
        step_new_data_exp <- Subset(new_data_obs, 'time', 1:(largest_ftime * (i - 1) + ftime_amount))
      }
      chunk_dims_obs['time'] <- largest_ftime - ftime_amount
      step_new_data_exp <- abind(step_new_data_exp, array(dim = chunk_dims_obs), along = which(names(chunk_dims_obs) == 'time'))
      names(dim(step_new_data_exp)) <- names(chunk_dims_obs)
      if (dim(new_data_obs)[which(names(chunk_dims_obs) == 'time')] > (largest_ftime * (i - 1) + ftime_amount)) {
        step_new_data_exp <- abind(step_new_data_exp, 
                               Subset(new_data_obs, 'time', (largest_ftime * (i - 1) + ftime_amount + 1):
                                                            (dim(new_data_obs)[which(names(chunk_dims_obs) == 'time')])),
                               along = which(names(chunk_dims_obs) == 'time'))
        names(dim(step_new_data_exp)) <- names(chunk_dims_obs)
      }
      new_data_obs <- step_new_data_exp
      rm(step_new_data_exp)
      gc()
  #    new_dates$start <- c(head(new_dates$start, largest_ftime * (i - 1) + ftime_amount),
  #                         rep(NA, largest_ftime - ftime_amount),
  #                         new_dates$start[(largest_ftime * (i - 1) + ftime_amount + 1):
  #                                         (dim(new_data_obs)[which(names(chunk_dims_obs) == 'time')])]
  #                         )
  #    new_dates$end <- c(head(new_dates$end, largest_ftime * (i - 1) + ftime_amount),
  #                       rep(NA, largest_ftime - ftime_amount),
  #                       new_dates$end[(largest_ftime * (i - 1) + ftime_amount + 1):
  #                                       (dim(new_data_obs)[which(names(chunk_dims_obs) == 'time')])]
  ##                       tail(new_dates$end, length(new_dates$end) - (largest_ftime * (i - 1) + ftime_amount))
  #                       )
    }
  }
  # Defining exp new dims
  new_dims <- dim(data_exp$Data)
  time_dim <- which(names(new_dims) == 'time')
  before_dims <- NULL
  if (time_dim > 1) {
    before_dims <- new_dims[1:(time_dim - 1)]
  }
  after_dims <- NULL
  if (time_dim < length(new_dims)) {
    after_dims <- new_dims[(time_dim + 1):length(new_dims)]
  }
  new_dims <- c(before_dims, largest_ftime, length(data_exp$InitializationDates), after_dims)
  names(new_dims)[time_dim:(time_dim + 1)] <- c('ftime', 'sdate')
  new_dims <- c(c(dataset = 1), new_dims)
  dim(new_data_exp) <- new_dims
  perm <- 1:length(new_dims)
  perm[c(time_dim, time_dim + 1) + 1] <- perm[c(time_dim + 1, time_dim) + 1]
  new_data_exp <- aperm(new_data_exp, perm)
  # Defining obs new dims
  new_dims['member'] <- 1
  # Defining date new dims
  dim(new_dates$start) <- dim(new_data_exp)[c('ftime', 'sdate')]
  new_dates$start <- t(new_dates$start)
  names(dim(new_dates$start)) <- c('sdate', 'ftime')
  dim(new_dates$end) <- dim(new_data_exp)[c('ftime', 'sdate')]
  new_dates$end <- t(new_dates$end)
  names(dim(new_dates$end)) <- c('sdate', 'ftime')
  dim(new_data_obs) <- new_dims
  new_data_obs <- aperm(new_data_obs, perm)
  # Casting output
  data_exp_bk <- data_exp
  data_obs_bk <- data_obs
  data_exp <- list()
  data_exp$mod <- new_data_exp
  data_exp$obs <- new_data_obs
  data_exp$Dates <- new_dates
  data_exp$lon <- data_exp_bk$xyCoords$x
  data_exp$lat <- data_exp_bk$xyCoords$y
  data_exp$InitializationDates <- data_exp_bk$InitializationDates
  data_exp$Variable <- data_exp_bk$Variable
  data_exp$Members <- data_exp_bk$Members
  attributes(data_exp) <- c(attributes(data_exp), 
                        attributes(data_exp_bk)[-which(names(attributes(data_exp_bk)) %in% c('names', 'dataset'))])
  attributes(data_obs) <- c(attributes(data_obs), 
                            attributes(data_obs_bk)[-which(names(attributes(data_obs_bk)) %in% c('names', 'dataset'))])
  attr(data_exp$mod, 'dataset') <- attr(data_exp_bk, 'dataset')
  attr(data_exp$obs, 'dataset') <- attr(data_obs_bk, 'dataset')

  data_exp
}
