source("modules/Loading/Loading.R")
source("modules/Units/Units.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")
source("modules/Indices/Indices.R")
source("modules/Downscaling/Downscaling.R")
source("tools/s2dv_cube2Climate4R.R")
source("SUNSET_PROV/Dataset/R/Prov.Dataset.R")
source("SUNSET_PROV/Dataset/R/Prov.DatasetSubset.R")
source("SUNSET_PROV/Dataset/SunsetProv.Dataset.R")
source("SUNSET_PROV/Tools/getSpatialExtent.R")
source("SUNSET_PROV/Dataset/R/Prov.Reggriding.R")
source("SUNSET_PROV/Calibration/R/Prov.Calibration.R")
source("SUNSET_PROV/Calibration/SunsetProv.Calibration.R")
source("SUNSET_PROV/Anomalies/SunsetProv.Anomalies.R")
source("SUNSET_PROV/Anomalies/R/Prov.Anomalies.R")
source("SUNSET_PROV/Tools/SunsetProv.Command.R")
source("SUNSET_PROV/Downscaling/SunsetProv.Downscaling.R")
source("SUNSET_PROV/Tools/SkillScore-helpers.R")
source("SUNSET_PROV/Skill/SunsetProv.Skill.R")
source("SUNSET_PROV/Skill/R/Prov.Skill.R")
library(yaml)
library(metaclipR)
library(igraph)

#SUNSET loading module execution
recipe_file <- "recipes/atomic_recipes/recipe_system7c3s-tas.yml"

        #"recipes/examples/NAO_recipe.yml"
        #"recipes/atomic_recipes/recipe_seasonal_provenance.yml"
        #"recipes/atomic_recipes/recipe_system7c3s-tas.yml"

#Loading MODULE
recipe <- prepare_outputs(recipe_file)
data <- Loading(recipe)

#Units MODULE
data <- Units(recipe, data)
graph<-SunsetProv.Dataset(recipe,data)

#Calibration MODULE
data_calibrated<-Calibration(recipe,data)
graph<-SunsetProv.Calibration(recipe, data, graph)

#Anomalies MODULE
data<-Anomalies(recipe,data)
graph<-SunsetProv.Anomalies(recipe,data,graph)

#Downscaling MODULE
#data<-Downscaling(recipe,data)
graph<-SunsetProv.Downscaling(recipe,data,graph)

#Skill MODULE
graph<-SunsetProv.Skill(recipe,data,graph)

#JSON generation
graph2json(graph$graph, "/esarchive/scratch/apuiggro/sunset/graph333333.json")