Project

General

Profile

« Previous | Next » 

Revision 1883c4c2

Added by Benoit Parmentier about 11 years ago

gam fusion function modifications to allow any variable (TMIN) and record results

View differences:

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: 03/29/2013                                                                                 
11
#DATE: 04/02/2013                                                                                 
12 12
#PROJECT: NCEAS INPLANT: Environment and Organisms --TASK#363--   
13 13

  
14 14
##Comments and TODO:
15 15
#This script is meant to be for general processing tile by tile or region by region.
16 16
# Note that the functions are called from GAM_fusion_analysis_raster_prediction_mutlisampling.R.
17 17
# This will be expanded to other methods.
18
# Change name of output tif to include the variable!!! (TMIN or TMAX)
19 18
##################################################################################################
20 19

  
21 20

  
......
179 178
  clim_obj<-list(rast_clim_list,data_month,mod_list,list_formulas)
180 179
  names(clim_obj)<-c("clim","data_month","mod","formulas")
181 180
  
182
  save(clim_obj,file= paste("clim_obj_month_",j,"_",out_prefix,".RData",sep=""))
181
  save(clim_obj,file= paste("clim_obj_month_",j,"_",var,"_",out_prefix,".RData",sep=""))
183 182
  
184 183
  return(clim_obj) 
185 184
}
......
278 277
  names(rast_clim_list)<-names(rast_bias_list)
279 278
  for (k in 1:nlayers(mod_rast)){
280 279
    clim_fus_rast<-LST-subset(mod_rast,k)
281
    data_name<-paste("clim_LST_month_",j,"_",names(rast_clim_list)[k],"_",prop_month,
280
    data_name<-paste(var,"_clim_LST_month_",j,"_",names(rast_clim_list)[k],"_",prop_month,
282 281
                     "_",run_samp,sep="")
283 282
    raster_name<-paste("fusion_",data_name,out_prefix,".tif", sep="")
284 283
    rast_clim_list[[k]]<-raster_name
......
295 294
   
296 295
  bias_rast<-interpolate(LST,fitbias) #interpolation using function from raster package
297 296
  #Saving kriged surface in raster images
298
  data_name<-paste("bias_LST_month_",j,"_",model_name,"_",prop_month,
297
  data_name<-paste(var,"_bias_LST_month_",j,"_",model_name,"_",prop_month,
299 298
                   "_",run_samp,sep="")
300 299
  raster_name_bias<-paste("fusion_",data_name,out_prefix,".tif", sep="")
301 300
  writeRaster(bias_rast, filename=raster_name_bias,overwrite=TRUE)  #Writing the data in a raster file format...(IDRISI)
302 301
  
303 302
  #now climatology layer
304 303
  clim_rast<-LST-bias_rast
305
  data_name<-paste("clim_LST_month_",j,"_",model_name,"_",prop_month,
304
  data_name<-paste(var,"_clim_LST_month_",j,"_",model_name,"_",prop_month,
306 305
                   "_",run_samp,sep="")
307 306
  raster_name_clim<-paste("fusion_",data_name,out_prefix,".tif", sep="")
308 307
  writeRaster(clim_rast, filename=raster_name_clim,overwrite=TRUE)  #Writing the data in a raster file format...(IDRISI)
......
317 316
  clim_obj<-list(rast_bias_list,rast_clim_list,data_month,mod_list,list_formulas)
318 317
  names(clim_obj)<-c("bias","clim","data_month","mod","formulas")
319 318
  
320
  save(clim_obj,file= paste("clim_obj_month_",j,"_",out_prefix,".RData",sep=""))
319
  save(clim_obj,file= paste("clim_obj_month_",j,"_",var,"_",out_prefix,".RData",sep=""))
321 320
  
322 321
  return(clim_obj)
323 322
}
......
471 470
  daily_delta_rast<-interpolate(rast_clim_month,fitdelta) #Interpolation of the bias surface...
472 471
  
473 472
  #Saving kriged surface in raster images
474
  data_name<-paste("daily_delta_",sampling_dat$date[i],"_",sampling_dat$prop[i],
473
  data_name<-paste("daily_delta_",y_var_name,"_",sampling_dat$date[i],"_",sampling_dat$prop[i],
475 474
                   "_",sampling_dat$run_samp[i],sep="")
476 475
  raster_name_delta<-paste("fusion_",var,"_",data_name,out_prefix,".tif", sep="")
477 476
  writeRaster(daily_delta_rast, filename=raster_name_delta,overwrite=TRUE)  #Writing the data in a raster file format...(IDRISI)
......
507 506
  
508 507
  obj_names<-c(y_var_name,"clim","delta","data_s","data_v",
509 508
               "sampling_dat",model_name)
510
  names(delta_obj)<-obj_names #add TMIN or TMAX name in saving obj
509
  names(delta_obj)<-obj_names 
511 510
  save(delta_obj,file= paste("delta_obj_",var,"_",sampling_dat$date[i],"_",sampling_dat$prop[i],
512 511
                                "_",sampling_dat$run_samp[i],out_prefix,".RData",sep=""))
513 512
  return(delta_obj)

Also available in: Unified diff