sunset_prov_indices<-function(recipe,data,graph){
graph_main<-graph$main_graph
parentnodenames<-graph$main_graph$parentnodename
graph_hcst<-graph$graph_hcst
graph_obs<-graph$graph_obs

browser()
#Hindcast aggragation
hcst_agg<- metaclipR.Aggregation(package = "Indices",
  version = "2.0", graph_hcst,
  fun = "/modules/Indices/Indices.R", arg.list = NULL, use.arg.list = FALSE,
  disable.command = TRUE, dc.description = NULL)

obs_agg<- metaclipR.Aggregation(package = "Indices",
  version = "2.0", graph_obs,
  fun = "/modules/Indices/Indices.R", arg.list = NULL, use.arg.list = FALSE,
  disable.command = TRUE, dc.description = NULL)
  #Should addd a description explaining how the aggregation takes place in SUNSET particularly!!!!

#Hindcast and Observation Aggragation(MANUALLY DONE)
 #aggr.nodename <- paste("Aggregation", randomName(), sep = ".")
 #graph <- add_vertices(graph_main$graph,
                         #     nv = 1,
                         #     name = aggr.nodename,
                        #      label = "Aggregation",
                        #      className = "ds:Aggregation"
                        #      #,dc.description=""
                       #       )  
 #orig.node<- graph_hcst$parentnodename
 #graph <- add_edges(graph, 
             #          c(getNodeIndexbyName(graph, orig.node),
             #            getNodeIndexbyName(graph, aggr.nodename)),
            #           label = "ds:hadAggregation")
 #orig.node<- graph_obs$parentnodename
 #graph <- add_edges(graph, 
            #           c(getNodeIndexbyName(graph, orig.node),
##                         getNodeIndexbyName(graph, aggr.nodename)),
#                       label = "ds:hadAggregation")

#climate4R_object_hcst<- s2dv_cube2Climate4R(data$hcst, time_dim = "time", sdate_dim = "syear", 
                             #  lat_dim = "latitude", lon_dim = "longitude",
                             #  memb_dim = "ensemble", copy_data = FALSE )

#indi_hcst<- metaclipR.ClimateIndex(graph_hcst, package = "indices",
  #version = "2.0" , index.code=names(recipe$Analysis$Workflow$Indices),
  #fun = "modules/Indices/Indices.R", disable.command = TRUE)

#climate4R_object_obs<- s2dv_cube2Climate4R(data$obs, time_dim = "time", sdate_dim = "syear", 
                              # lat_dim = "latitude", lon_dim = "longitude",
                              # memb_dim = "ensemble", copy_data = FALSE )

#indi_obs<- metaclipR.ClimateIndex(graph_obs, package = "indices",
  #version = "2.0" , index.code=names(recipe$Analysis$Workflow$Indices),
  #fun = "modules/Indices/Indices.R", disable.command = TRUE)

#graph<-my_union_graph(graph_main$graph, indi_hcst$graph, indi_obs$graph)
#parentnodename<-list(indi_hcst$parentnodename, indi_obs$parentnodename)

index_name<-names(recipe$Analysis$Workflow$Indices)
#graph=list("graph"=graph, "parentnodename"=aggr.nodename)

#if (names==c("Nino1+2","Nino3","Nino3.4","Nino4")){

#}
indi_hcst<- metaclipR.ClimateIndex(hcst_agg, package = "indices",
  version = "2.0" , index.code= index_name,
  fun = "modules/Indices/Indices.R", disable.command = TRUE)

indi_obs<-metaclipR.ClimateIndex(obs_agg, package = "indices",
  version = "2.0" , index.code= index_name,
  fun = "modules/Indices/Indices.R", disable.command = TRUE)

graph<-my_union_graph(graph_main$graph, indi_hcst$graph, indi_obs$graph)

#}

parentnodename<-list(indi_hcst$parentnodename, indi_obs$parentnodename, hcst_agg$parentnodename, obs_agg$parentnodename)

graph <- metaclip.graph.Command(graph, "Indices", "2.0.0", "/modules/Indices/Indices.R", arg.list=list("Recipe"=recipe$Run$output_dir, "Calibrated_Data"),parentnodename)

graph<-list("graph"=graph, "parentnodename"=list(graph_fcst$parentnodename,graph_hcst$parentnodename, graph_obs$parentnodename,parentnodename))

return(list("main_graph"=graph, "graph_fcst"=graph_fcst, "graph_hcst"=graph_hcst, "graph_obs"=graph_obs))
}

