###############################################################################
## Author: Núria Pérez-Zanón
## Description: Computes the NAO index and some skill metrics for it, for a 
##              seasonal prediction system.
## Instructions: To run it, modify the recipe to set your own output directory.
###############################################################################

source("modules/Loading/Loading.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/NAO_recipe.yml"
recipe <- prepare_outputs(recipe_file)

#for (smonth in 1:12) {
  data <- load_datasets(recipe)
  gc()
  data <- compute_anomalies(recipe, data)
#  data <- readRDS("../Test_NAOmodule.RDS")
source("modules/Indices/Indices.R")
  nao_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 = nao_s2dv,
                                         agg = 'region')


