###############################################################################
## Author: Núria Pérez-Zanón
## Description: Computes the Niño1+2, Niño3, Niño3.4 and Niño4 indices and some
##              some skill metrics for each index.
## Instructions: To run it, modify the recipe to set your own output directory.
###############################################################################

source("modules/Loading/Loading_decadal.R")
source("modules/Calibration/Calibration.R")
source("modules/Skill/Skill.R")
source("modules/Saving/Saving.R")
source("tools/prepare_outputs.R")
source("modules/Anomalies/Anomalies.R")

recipe_file <- "recipes/examples/recipe_Nino_decadal.yml"
recipe <- prepare_outputs(recipe_file)

#for (smonth in 1:12) {
  data <- load_datasets(recipe)
  gc()
  data <- compute_anomalies(recipe, data)
# data <- readRDS("../data_decadal_nao.RDS")
source("modules/Indices/Indices.R")
  nino_s2dv <- Indices(data = data, recipe = recipe)
source("modules/Skill/Skill.R")
  # todo parameter agg to get it from the nao_s2dv?
  skill_metrics <- compute_skill_metrics(recipe = recipe, data = nino_s2dv[[1]],
                                         agg = 'region')


