Project

General

Profile

« Previous | Next » 

Revision cbd65694

Added by Benoit Parmentier over 11 years ago

adding gwr_CAI and kriging_CAI, modifications to raster prediction function

View differences:

climate/research/oregon/interpolation/GAM_fusion_analysis_raster_prediction_multisampling.R
195 195
    clim_yearlist<-list_tmp
196 196
  }
197 197
  
198
  #to be added gwr_CAI and kriging_CAI
199
  if (interpolation_method=="gam_CAI"){
198
  if (interpolation_method %in% c("gam_CAI","kriging_CAI", "gwr_CAI")){
200 199
    list_param_runClim_KGCAI<-list(j,s_raster,covar_names,lst_avg,list_models,dst,var,y_var_name, out_prefix,out_path)
201 200
    names(list_param_runClim_KGCAI)<-c("list_index","covar_rast","covar_names","lst_avg","list_models","dst","var","y_var_name","out_prefix","out_path")
202 201
    clim_method_mod_obj<-mclapply(1:12, list_param=list_param_runClim_KGCAI, runClim_KGCAI,mc.preschedule=FALSE,mc.cores = 6) #This is the end bracket from mclapply(...) statement
......
229 228
  
230 229
  #TODO : Same call for all functions!!! Replace by one "if" for all multi time scale methods...
231 230
  #The methods could be defined earlier as constant??
232
  if (interpolation_method %in% c("gam_CAI","gam_fusion","kriging_fusion","gwr_fusion")){
231
  if (interpolation_method %in% c("gam_CAI","kriging_CAI","gwr_CAI","gam_fusion","kriging_fusion","gwr_fusion")){
233 232
    #input a list:note that ghcn.subsets is not sampling_obj$data_day_ghcn
234 233
    i<-1
235 234
    list_param_run_prediction_daily_deviation <-list(i,clim_yearlist,sampling_obj,dst,var,y_var_name, interpolation_method,out_prefix,out_path)
......
337 336
  ################### PREPARE RETURN OBJECT ###############
338 337
  #Will add more information to be returned
339 338
  
340
  if (interpolation_method %in% c("gam_CAI","gam_fusion","kriging_fusion","gwr_fusion")){
339
  if (interpolation_method %in% c("gam_CAI","kriging_CAI","gwr_CAI","gam_fusion","kriging_fusion","gwr_fusion")){
341 340
    raster_prediction_obj<-list(clim_method_mod_obj,method_mod_obj,validation_mod_obj,tb_diagnostic_v,
342 341
                                summary_metrics_v,summary_month_metrics_v)
343 342
    names(raster_prediction_obj)<-c("clim_method_mod_obj","method_mod_obj","validation_mod_obj","tb_diagnostic_v",
climate/research/oregon/interpolation/GAM_fusion_function_multisampling.R
8 8
# 5)runGAMFusion <- function(i,list_param) : daily step for fusion method, perform daily prediction
9 9
#
10 10
#AUTHOR: Benoit Parmentier                                                                       
11
#DATE: 07/29/2013                                                                                 
11
#DATE: 07/30/2013                                                                                 
12 12
#PROJECT: NCEAS INPLANT: Environment and Organisms --TASK#363--   
13 13

  
14 14
##Comments and TODO:
......
97 97
  out_path<-list_param$out_path
98 98
  
99 99
  #Model and response variable can be changed without affecting the script
100
  prop_month<-0 #proportion retained for validation
101
  run_samp<-1
100
  prop_month<-0 #proportion retained for validation...
101
  run_samp<-1 #sample number, can be introduced later...
102 102
  
103 103
  #### STEP 2: PREPARE DATA
104 104
    
......
106 106
  LST_name<-lst_avg[j] # name of LST month to be matched
107 107
  data_month$LST<-data_month[[LST_name]]
108 108
  
109
  #TMax to model...
109
  #TMax to model..., add precip later
110 110
  if (var=="TMAX"){   
111 111
    data_month$y_var<-data_month$TMax #Adding TMax as the variable modeled
112 112
  }
......
120 120
  
121 121
  #mod_list<-fit_models(list_formulas,data_month) #only gam at this stage
122 122
  #cname<-paste("mod",1:length(mod_list),sep="") #change to more meaningful name?
123
  names(mod_list)<-cname
123
  
124 124
  #Adding layer LST to the raster stack  
125 125
  
126 126
  pos<-match("LST",names(s_raster)) #Find the position of the layer with name "LST", if not present pos=NA
......
130 130
  s_raster<-addLayer(s_raster,LST)            #Adding current month
131 131
  
132 132
  #Now generate file names for the predictions...
133
  list_out_filename<-vector("list",length(mod_list))
133
  list_out_filename<-vector("list",length(list_formulas))
134 134
  names(list_out_filename)<-cname  
135 135
  
136 136
  for (k in 1:length(list_out_filename)){

Also available in: Unified diff