library(CSTools)
probs <- list(c(1, 0, 0), 
              c(0.36, 0.4, 0.24),
              c(0.36, 0.400001, 0.24))
for (i in 1 : length(probs)) {
  print(probs[[i]][1])
  print(probs[[i]][2])
  print(probs[[i]][3])
  map <- list(array(probs[[i]][1], dim = c(lat = 10, lon = 20)),
              array(probs[[i]][2], dim = c(lat = 10, lon = 20)),
              array(probs[[i]][3], dim = c(lat = 10, lon = 20)))
 x11()
  map <- lapply(map, FUN = function(x){ifelse(x == 0.4, 0.400001, x)})
  PlotMostLikelyQuantileMap(probs = map, lon = seq(0, 359.5, length = 20), lat= seq(-89.5, 89.5, length = 10),
                            toptitle = 'Most likely tercile map',
                            bar_titles = paste('% of belonging to', c('a', 'b', 'c')),
                            brks = 5, width = 10, height = 8)
}
