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("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")

library(yaml)
library(metaclipR)
library(igraph)

#SUNSET loading module execution
recipe_file <- "recipes/atomic_recipes/recipe_seasonal_provenance.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)

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