Project

General

Profile

« Previous | Next » 

Revision e7efff8e

Added by Benoit Parmentier over 11 years ago

raster prediction, additional modifications following run for Oregon TMAX interpolation

View differences:

climate/research/oregon/interpolation/GAM_fusion_analysis_raster_prediction_multisampling.R
11 11
#5)GAM fusion: possibilty of running GAM+FUSION or GAM+CAI and other options added
12 12
#The interpolation is done first at the monthly time scale then delta surfaces are added.
13 13
#AUTHOR: Benoit Parmentier                                                                        
14
#DATE: 03/27/2013                                                                                 
14
#DATE: 04/05/2013                                                                                 
15 15
#PROJECT: NCEAS INPLANT: Environment and Organisms --TASK#568--     
16 16
#
17 17
# TO DO:
18
# 1) modidy to make it general for any method i.e. make call to method e.g. gam_fus, gam_cai etc.
18
# 1) modify to make it general for any method i.e. make call to method e.g. gam_fus, gam_cai etc.
19 19
# 2) simplify and bundle validation steps, make it general--method_mod_validation
20 20
# 3) solve issues with log file recordings
21 21
# 4) output location folder on the fly???
......
160 160
  
161 161
  s_raster<-brick(infile_covariates)                   #read in the data brck
162 162
  names(s_raster)<-covar_names               #Assigning names to the raster layers: making sure it is included in the extraction
163
  pos<-match("elev",names(s_raster))
164
  names(s_raster)[pos]<-"elev_1"
163
    
164
  #Reading monthly data
165
  dst<-readOGR(dsn=in_path,layer=sub(".shp","",basename(infile_monthly)))
165 166
  
167
  ### TO DO -important ###
168
  #SCREENING IN COVARIATE SCRIPT AND DATA PREP SCRIPT !!! Only perform predictions here
166 169
  #Screen for extreme values": this needs more thought, min and max val vary with regions
167 170
  #min_val<-(-15+273.16) #if values less than -15C then screen out (note the Kelvin units that will need to be changed later in all datasets)
168 171
  #r1[r1 < (min_val)]<-NA
169 172
  
170
  #Reading monthly data
171
  data3<-readOGR(dsn=in_path,layer=sub(".shp","",basename(infile_monthly)))
172
  dst_all<-data3
173
  dst<-data3
174
  
175
  ### TO DO -important ###
176
  #Cleaning/sceerniging functions for daily stations, monthly stations and covariates?? do this during the preparation stage!!!??
177
  ###
178
  
179 173
  ########### CREATE SAMPLING -TRAINING AND TESTING STATIONS ###########
180 174
  
181 175
  #Input for sampling function...
......
197 191
  t1<-proc.time()
198 192
  j=12
199 193
  #browser()
200
  #list_param_runClim_KGFusion<-list(j,s_raster,covar_names,lst_avg,list_models,dst,var,y_var_name, out_prefix)
194
  list_param_runClim_KGFusion<-list(j,s_raster,covar_names,lst_avg,list_models,dst,var,y_var_name, out_prefix)
201 195
  names(list_param_runClim_KGFusion)<-c("list_index","covar_rast","covar_names","lst_avg","list_models","dst","var","y_var_name","out_prefix")
202 196
  #source(file.path(script_path,"GAM_fusion_function_multisampling_03122013.R"))
203 197
  gamclim_fus_mod<-mclapply(1:12, list_param=list_param_runClim_KGFusion, runClim_KGFusion,mc.preschedule=FALSE,mc.cores = 6) #This is the end bracket from mclapply(...) statement
198
  #test<-runClim_KGFusion(1,list_param=list_param_runClim_KGFusion)
204 199
  #gamclim_fus_mod<-mclapply(1:6, list_param=list_param_runClim_KGFusion, runClim_KGFusion,mc.preschedule=FALSE,mc.cores = 6) #This is the end bracket from mclapply(...) statement
205 200
  
206 201
  #gamclim_fus_mod<-runClim_KGFusion(1,list_param=list_param_runClim_KGFusion) #This is the end bracket from mclapply(...) statement

Also available in: Unified diff