###############################################################################
## Author: V. Agudetse
## Description: Script to test developments for seasonal workflows. Please,
##              do not modify.
###############################################################################

# Load modules
source("modules/Loading/Loading.R")
source("modules/Calibration/Calibration.R")
source("modules/Anomalies/Anomalies.R")
source("modules/Skill/Skill.R")
source("modules/Saving/Saving.R")
source("modules/Visualization/Visualization.R")

# Read recipe
recipe_file <- "recipes/atomic_recipes/recipe_test_multivar.yml"
recipe <- prepare_outputs(recipe_file)

# Load datasets
data <- load_datasets(recipe)
# Calibrate datasets
data <- calibrate_datasets(recipe, data)
# Compute anomalies
data <- compute_anomalies(recipe, data)
# Compute skill metrics 
skill_metrics <- compute_skill_metrics(recipe, data)
# Compute percentiles and probability bins
probabilities <- compute_probabilities(recipe, data)
# Export all data to netCDF
## TODO: Fix plotting
# save_data(recipe, data, skill_metrics, probabilities)
# Plot data
plot_data(recipe, data, skill_metrics, probabilities, significance = T)
