sunset_prov_downscale<-function(recipe, graph){
graph_main<-graph$main_graph
parentnodenames<-graph$main_graph$parentnodename
graph_fcst<-graph$anom_fcst
graph_hcst<-graph$anom_hcst
graph_obs<-graph$anom_obs

parentnodename_hcst<-graph_hcst$parentnodename
type<-recipe$Analysis$Workflow$Downscaling$type
    type <- switch(type,
                 "int" = "Interpolation",
                 "intbc"="Interpolation with Bias Correction",
                 "intlr"="Interpolation with Linear Regression",
                 "logreg"="Logistic Regression",
                 "analogs"="Analogs"
                 )
                 
graph<-make_empty_graph(0)
int<-recipe$Analysis$Workflow$Downscaling$int_method #At the time no additional provenance regarding "submethods" applied
origin.node.name <- paste0("Downscaling.", randomName())
graph <- add_vertices(graph,
                        nv = 1,
                        name = origin.node.name,
                        label=type,
                        className = "cal:ESD")

graph<-my_union_graph(graph, graph_hcst$graph)

graph <- add_edges(graph, 
                    c(getNodeIndexbyName(graph, parentnodename_hcst),
                       getNodeIndexbyName(graph, origin.node.name)),
                    label = "cal:CalibrationMethod")

graph<-my_union_graph(graph_main$graph, graph)

parentnodename<-list(origin.node.name)    

graph <- metaclip.graph.Command(graph, "Downscaling", "2.0.0", "/modules/Downscaling/Downscaling.R", arg.list=list("Recipe"=recipe$Run$output_dir, "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))
}

}

