###############################################################################
## Author: An-Chi Ho
## Description: Script to test developments for decadal workflows. Please,
##              do not modify.
###############################################################################

source("modules/Loading/Loading_decadal.R")
source("modules/Calibration/Calibration.R")
source("modules/Skill/Skill.R")
source("modules/Saving/Saving.R")
source("modules/Visualization/Visualization.R")

recipe_file <- "recipes/atomic_recipes/recipe_decadal.yml"
recipe <- prepare_outputs(recipe_file)
# archive <- read_yaml(paste0(recipe$Run$code_dir, "conf/archive_decadal.yml"))$archive

# Load datasets
data <- load_datasets(recipe)

# Calibrate datasets
calibrated_data <- calibrate_datasets(recipe, data)

# Compute skill metrics
skill_metrics <- compute_skill_metrics(recipe, calibrated_data)

# Compute percentiles and probability bins
probabilities <- compute_probabilities(recipe, calibrated_data)

# Export all data to netCDF
save_data(recipe, calibrated_data, skill_metrics, probabilities)

# Plot data
plot_data(recipe, calibrated_data, skill_metrics, probabilities,
	  significance = T)

