sunset_prov_calibration<-function(recipe,data,graph){

#Graph definitions
graph_main<-graph$main_graph
parentnodenames<-graph$main_graph$parentnodename
graph_fcst<-graph$graph_fcst
graph_hcst<-graph$graph_hcst
graph_obs<-graph$graph_obs

    ##Calibration method recorded: 

    #"BiasCorrection",
    #"NonParametricBiasCorrection",
    #"LinearScaling",
    #"NPQuantileMapping",
    #"PQuantileMapping",
    #"ParametricBiasCorrection",
    #"VarianceInflation",
    #"ProbabilityScaling",
    #"EnsembleRecalibration"

TrainingGraph<- metaclipR.Dataset( Dataset.name = "TrainingGraph",
  #DataProvider = archive_system$institution,
  # DataProvider.URL = url,
  Dataset.subclass = "ObservationalDataset",  # Right?
  #Project = "metaclipR test" # ?
  #ModellingCenter = "ECMWF"
)

#Forecast calibration provenance
if(!is.null(graph_fcst)){
graph_fcst<-metaclipR.BiasCorrection(package = "Calibration", version = "1.0",
                                     fun = "modules/Calibration/Calibration.R", arg.list=list("Loaded Data"=data), graph=graph_fcst, TrainingGraph, ReferenceGraph=graph_obs,
                                     BC.method=recipe$Analysis$Workflow$Calibration$method,disable.command = TRUE)
}

#Hindcast calibration provenance
graph_hcst<-metaclipR.BiasCorrection(package = "Calibration", version = "1.0",
                                     fun = "modules/Calibration/Calibration.R", arg.list=list("Loaded Data"=data), graph=graph_hcst, TrainingGraph, ReferenceGraph=graph_obs,
                                     BC.method=recipe$Analysis$Workflow$Calibration$method,disable.command = TRUE)

#Union graph+ union parentnodename
if(!is.null(graph_fcst)) {
    graph<-my_union_graph(graph_fcst$graph,graph_hcst$graph,graph_obs$graph, graph_main$graph)
    parentnodename<-list(graph_fcst$parentnodename,graph_hcst$parentnodename)

}else{
    graph<-my_union_graph(graph_hcst$graph, graph_obs$graph, graph_main$graph)
    parentnodename<-list(graph_hcst$parentnodename)
}

#Command command call
graph <- metaclip.graph.Command(graph, "Calibration", "2.0.0", "/modules/Calibration/Calibration.R", arg.list=list("Recipe"=recipe$Run$output_dir, "Loaded_Data"),parentnodename)

graph=list("graph"=graph, "parentnodename"=parentnodename)

if(!is.null(graph_fcst)){
return(list("main_graph"=graph,"graph_fcst"=graph_fcst, "graph_hcst"=graph_hcst, "graph_obs"=graph_obs))
}else {
return(list("main_graph"=graph,"graph_hcst"=graph_hcst, "graph_obs"=graph_obs))
}

}


