# RPS version for climatology 
RPS_clim <- function(obs, indices_for_clim = NULL, prob_thresholds = c(1/3, 2/3)) { 
  
  if (is.null(indices_for_clim)){
    indices_for_clim <- 1:length(obs)
  }
  
  obs_probs <- .GetProbs(data = obs, indices_for_quantiles = indices_for_clim, ## temporarily removed s2dv:::
                                 prob_thresholds = prob_thresholds, weights = NULL, cross.val = T) ## here!
  # clim_probs: [bin, sdate]
  clim_probs <- c(prob_thresholds[1], diff(prob_thresholds), 1 - prob_thresholds[length(prob_thresholds)])
  clim_probs <- array(clim_probs, dim = dim(obs_probs))
  
  # Calculate RPS for each time step
  probs_clim_cumsum <- apply(clim_probs, 2, cumsum)
  probs_obs_cumsum <- apply(obs_probs, 2, cumsum)
  rps_ref <- apply((probs_clim_cumsum - probs_obs_cumsum)^2, 2, sum)

  return(mean(rps_ref)) 
}
