###############################################################################
## Author: V. Agudetse
## Description: Example script for seasonal downscaling.
###############################################################################

# Load modules
source("modules/Loading/Loading.R")
source("modules/Units/Units.R")
source("modules/Downscaling/Downscaling.R")
source("modules/Skill/Skill.R")
source("modules/Saving/Saving.R")
source("modules/Visualization/Visualization.R")

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

# Load datasets
data <- Loading(recipe)
# Change units
data <- Units(recipe, data)
# Downscale datasets
data <- Downscaling(recipe, data)
# Compute skill metrics 
skill_metrics <- Skill(recipe, data)
# Compute percentiles and probability bins
probabilities <- Probabilities(recipe, data)
# Plot data
Visualization(recipe, data, skill_metrics, probabilities, significance = T)
