Revision 30443fec
Added by Benoit Parmentier about 11 years ago
climate/research/oregon/interpolation/GAM_fusion_analysis_raster_prediction_multisampling.R | ||
---|---|---|
112 | 112 |
|
113 | 113 |
#6 additional parameters for monthly climatology and more |
114 | 114 |
list_models<-list_param_raster_prediction$list_models |
115 |
list_models2<-list_param_raster_prediction$list_models2 |
|
115 | 116 |
lst_avg<-list_param_raster_prediction$lst_avg |
116 | 117 |
out_path<-list_param_raster_prediction$out_path |
117 | 118 |
script_path<-list_param_raster_prediction$script_path |
... | ... | |
270 | 271 |
if (interpolation_method %in% c("gam_CAI","kriging_CAI","gwr_CAI","gam_fusion","kriging_fusion","gwr_fusion")){ |
271 | 272 |
#input a list:note that ghcn.subsets is not sampling_obj$data_day_ghcn |
272 | 273 |
i<-1 |
273 |
list_param_run_prediction_daily_deviation <-list(i,clim_yearlist,daily_dev_sampling_dat,sampling_month_obj,sampling_obj,dst, |
|
274 |
use_clim_image,join_daily,var,y_var_name, interpolation_method,out_prefix,out_path) |
|
275 |
names(list_param_run_prediction_daily_deviation)<-c("list_index","clim_yearlist","daily_dev_sampling_dat","sampling_month_obj","sampling_obj","dst", |
|
276 |
"use_clim_image","join_daily","var","y_var_name","interpolation_method","out_prefix","out_path") |
|
274 |
list_param_run_prediction_daily_deviation <-list(i,clim_yearlist,daily_dev_sampling_dat,sampling_month_obj,sampling_obj,dst,list_models2,
|
|
275 |
s_raster,use_clim_image,join_daily,var,y_var_name, interpolation_method,out_prefix,out_path)
|
|
276 |
names(list_param_run_prediction_daily_deviation)<-c("list_index","clim_yearlist","daily_dev_sampling_dat","sampling_month_obj","sampling_obj","dst","list_models2",
|
|
277 |
"s_raster","use_clim_image","join_daily","var","y_var_name","interpolation_method","out_prefix","out_path")
|
|
277 | 278 |
#method_mod_obj<-mclapply(1:length(sampling_obj$ghcn_data),list_param=list_param_run_prediction_daily_deviation,run_prediction_daily_deviation,mc.preschedule=FALSE,mc.cores = 9) #This is the end bracket from mclapply(...) statement |
278 | 279 |
#debug(run_prediction_daily_deviation) |
279 | 280 |
#test <- run_prediction_daily_deviation(1,list_param=list_param_run_prediction_daily_deviation) #This is the end bracket from mclapply(...) statement |
280 |
#method_mod_obj<-mclapply(1:nrow(daily_dev_sampling_dat),list_param=list_param_run_prediction_daily_deviation,run_prediction_daily_deviation,mc.preschedule=FALSE,mc.cores = 9) #This is the end bracket from mclapply(...) statement
|
|
281 |
#test <- mclapply(1:9,list_param=list_param_run_prediction_daily_deviation,run_prediction_daily_deviation,mc.preschedule=FALSE,mc.cores = 9) #This is the end bracket from mclapply(...) statement
|
|
281 | 282 |
|
282 | 283 |
method_mod_obj<-mclapply(1:nrow(daily_dev_sampling_dat),list_param=list_param_run_prediction_daily_deviation,run_prediction_daily_deviation,mc.preschedule=FALSE,mc.cores = 9) #This is the end bracket from mclapply(...) statement |
283 | 284 |
save(method_mod_obj,file= file.path(out_path,paste("method_mod_obj_",interpolation_method,"_",y_var_name,out_prefix,".RData",sep=""))) |
285 |
|
|
284 | 286 |
} |
285 | 287 |
|
286 | 288 |
#TODO : Same call for all functions!!! Replace by one "if" for all daily single time scale methods... |
... | ... | |
397 | 399 |
save(validation_mod_month_obj,file= file.path(out_path,paste(interpolation_method,"_validation_mod_month_obj_",y_var_name,out_prefix,".RData",sep=""))) |
398 | 400 |
|
399 | 401 |
##Create data.frame with validation and fit metrics for a full year/full numbe of runs |
400 |
tb_month_diagnostic_v<-extract_from_list_obj(validation_mod_month_obj,"metrics_v")
|
|
402 |
tb_month_diagnostic_v <- extract_from_list_obj(validation_mod_month_obj,"metrics_v")
|
|
401 | 403 |
#tb_diagnostic_v contains accuracy metrics for models sample and proportion for every run...if full year then 365 rows maximum |
402 | 404 |
rownames(tb_month_diagnostic_v)<-NULL #remove row names |
403 | 405 |
tb_month_diagnostic_v$method_interp <- interpolation_method |
climate/research/oregon/interpolation/master_script_temp.R | ||
---|---|---|
10 | 10 |
#STAGE 5: Output analyses: assessment of results for specific dates... |
11 | 11 |
# |
12 | 12 |
#AUTHOR: Benoit Parmentier |
13 |
#DATE: 09/28/2013
|
|
13 |
#DATE: 09/29/2013
|
|
14 | 14 |
|
15 | 15 |
#PROJECT: NCEAS INPLANT: Environment and Organisms --TASK#363, TASK$568-- |
16 | 16 |
|
... | ... | |
80 | 80 |
#met_stations_outfiles_obj_file<-"met_stations_outfiles_obj_gam_CAI__365d_gam_CAI_lst_comb3_08252013.RData" |
81 | 81 |
|
82 | 82 |
var<-"TMAX" # variable being interpolated |
83 |
out_prefix<-"_365d_gwr_cai_lst_comb3_09282013" #User defined output prefix
|
|
84 |
out_suffix<-"_OR_09282013" #Regional suffix
|
|
83 |
out_prefix<-"_365d_gam_cai_lst_comb3_09292013" #User defined output prefix
|
|
84 |
out_suffix<-"_OR_09292013" #Regional suffix
|
|
85 | 85 |
out_suffix_modis <-"_05302013" #pattern to find tiles produced previously |
86 | 86 |
|
87 | 87 |
#interpolation_method<-c("gam_fusion","gam_CAI","gam_daily") #other otpions to be added later |
88 |
#interpolation_method<-c("gam_CAI") #other otpions to be added later
|
|
88 |
interpolation_method<-c("gam_CAI") #other otpions to be added later |
|
89 | 89 |
#interpolation_method<-c("gam_fusion") #other otpions to be added later |
90 | 90 |
#interpolation_method<-c("kriging_fusion") #other otpions to be added later |
91 | 91 |
#interpolation_method<-c("gwr_fusion") #other otpions to be added later |
92 |
interpolation_method<-c("gwr_CAI") #other otpions to be added later |
|
92 |
#interpolation_method<-c("gwr_CAI") #other otpions to be added later
|
|
93 | 93 |
#interpolation_method<-c("kriging_CAI") |
94 | 94 |
|
95 | 95 |
#interpolation_method<-c("gam_daily") #other otpions to be added later |
... | ... | |
254 | 254 |
nb_sample_month <-1 #number of time random sampling must be repeated for every hold out proportion |
255 | 255 |
step_month <-0.1 |
256 | 256 |
constant_month <- 0 #if value 1 then use the same samples as date one for the all set of dates |
257 |
prop_minmax_month <-c(0.4,0.7) #if prop_min=prop_max and step=0 then predictions are done for the number of dates...
|
|
257 |
prop_minmax_month <-c(0,0) #if prop_min=prop_max and step=0 then predictions are done for the number of dates...
|
|
258 | 258 |
|
259 | 259 |
#dates_selected<-c("20100101","20100102","20100103","20100901") # Note that the dates set must have a specific format: yyymmdd |
260 | 260 |
#dates_selected<-c("20100101","20100102","20100301","20100302","20100501","20100502","20100701","20100702","20100901","20100902","20101101","20101102") |
... | ... | |
278 | 278 |
# "y_var ~ s(lat,lon) + s(elev_s) + s(LST) + ti(LST,CANHGHT)") |
279 | 279 |
|
280 | 280 |
#Combination 4: for paper baseline=s(lat,lon) |
281 |
# list_models<-c("y_var ~ s(lat,lon)", |
|
282 |
# "y_var ~ s(lat,lon) + s(elev_s)", |
|
283 |
# "y_var ~ s(lat,lon) + s(N_w)", |
|
284 |
# "y_var ~ s(lat,lon) + s(E_w)", |
|
285 |
# "y_var ~ s(lat,lon) + s(LST)", |
|
286 |
# "y_var ~ s(lat,lon) + s(DISTOC)", |
|
287 |
# "y_var ~ s(lat,lon) + s(LC1)", |
|
288 |
# "y_var ~ s(lat,lon) + s(CANHGHT)", |
|
289 |
# "y_var ~ s(lat,lon) + s(LST) + ti(LST,LC1)", |
|
290 |
# "y_var ~ s(lat,lon) + s(LST) + ti(LST,CANHGHT)") |
|
281 |
list_models<-c("y_var ~ s(lat,lon)", |
|
282 |
"y_var ~ s(lat,lon) + s(elev_s)", |
|
283 |
"y_var ~ s(lat,lon) + s(N_w)", |
|
284 |
"y_var ~ s(lat,lon) + s(E_w)", |
|
285 |
"y_var ~ s(lat,lon) + s(LST)", |
|
286 |
"y_var ~ s(lat,lon) + s(DISTOC)", |
|
287 |
"y_var ~ s(lat,lon) + s(LC1)", |
|
288 |
"y_var ~ s(lat,lon) + s(CANHGHT)", |
|
289 |
"y_var ~ s(lat,lon) + s(LST) + ti(LST,LC1)", |
|
290 |
"y_var ~ s(lat,lon) + s(LST) + ti(LST,CANHGHT)") |
|
291 |
|
|
292 |
list_models2<-c("y_var ~ s(lat,lon)", |
|
293 |
"y_var ~ s(lat,lon) + s(elev_s)", |
|
294 |
"y_var ~ s(lat,lon) + s(N_w)", |
|
295 |
"y_var ~ s(lat,lon) + s(E_w)", |
|
296 |
"y_var ~ s(lat,lon) + s(LST)", |
|
297 |
"y_var ~ s(lat,lon) + s(DISTOC)", |
|
298 |
"y_var ~ s(lat,lon) + s(LC1)", |
|
299 |
"y_var ~ s(lat,lon) + s(CANHGHT)", |
|
300 |
"y_var ~ s(lat,lon) + s(LST) + ti(LST,LC1)", |
|
301 |
"y_var ~ s(lat,lon) + s(LST) + ti(LST,CANHGHT)") |
|
291 | 302 |
|
292 | 303 |
#list_models<-c("y_var ~ lat*lon + elev_s") |
293 | 304 |
|
294 | 305 |
#list_models<-c("y_var ~ s(lat,lon) + s(elev_s)") |
295 | 306 |
|
296 |
list_models<-c("y_var ~ lat*lon + elev_s", |
|
297 |
"y_var ~ lat*lon + elev_s + N_w", |
|
298 |
"y_var ~ lat*lon + elev_s + E_w", |
|
299 |
"y_var ~ lat*lon + elev_s + LST", |
|
300 |
"y_var ~ lat*lon + elev_s + DISTOC", |
|
301 |
"y_var ~ lat*lon + elev_s + LC1", |
|
302 |
"y_var ~ lat*lon + elev_s + CANHGHT", |
|
303 |
"y_var ~ lat*lon + elev_s + LST + I(LST*LC1)", |
|
304 |
"y_var ~ lat*lon + elev_s + LST + I(LST*CANHGHT)") |
|
307 |
#list_models<-c("y_var ~ lat*lon + elev_s",
|
|
308 |
# "y_var ~ lat*lon + elev_s + N_w",
|
|
309 |
# "y_var ~ lat*lon + elev_s + E_w",
|
|
310 |
# "y_var ~ lat*lon + elev_s + LST",
|
|
311 |
# "y_var ~ lat*lon + elev_s + DISTOC",
|
|
312 |
# "y_var ~ lat*lon + elev_s + LC1",
|
|
313 |
# "y_var ~ lat*lon + elev_s + CANHGHT",
|
|
314 |
# "y_var ~ lat*lon + elev_s + LST + I(LST*LC1)",
|
|
315 |
# "y_var ~ lat*lon + elev_s + LST + I(LST*CANHGHT)")
|
|
305 | 316 |
|
306 | 317 |
#Default name of LST avg to be matched |
307 | 318 |
lst_avg<-c("mm_01","mm_02","mm_03","mm_04","mm_05","mm_06","mm_07","mm_08","mm_09","mm_10","mm_11","mm_12") |
... | ... | |
310 | 321 |
list_param_raster_prediction<-list(list_param_data_prep,screen_data_training, |
311 | 322 |
seed_number,nb_sample,step,constant,prop_minmax,dates_selected, |
312 | 323 |
seed_number_month,nb_sample_month,step_month,constant_month,prop_minmax_month, |
313 |
list_models,lst_avg,out_path,script_path,use_clim_image,join_daily, |
|
324 |
list_models,list_models2,lst_avg,out_path,script_path,use_clim_image,join_daily,
|
|
314 | 325 |
interpolation_method) |
315 | 326 |
names(list_param_raster_prediction)<-c("list_param_data_prep","screen_data_training", |
316 | 327 |
"seed_number","nb_sample","step","constant","prop_minmax","dates_selected", |
317 | 328 |
"seed_number_month","nb_sample_month","step_month","constant_month","prop_minmax_month", |
318 |
"list_models","lst_avg","out_path","script_path","use_clim_image","join_daily", |
|
329 |
"list_models","list_models2","lst_avg","out_path","script_path","use_clim_image","join_daily",
|
|
319 | 330 |
"interpolation_method") |
320 | 331 |
|
321 | 332 |
#debug(raster_prediction_fun) |
333 |
debug(debug_fun_test) |
|
334 |
debug_fun_test(list_param_raster_prediction) |
|
335 |
|
|
322 | 336 |
raster_prediction_obj <-raster_prediction_fun(list_param_raster_prediction) |
323 | 337 |
|
324 | 338 |
############## STAGE 5: OUTPUT ANALYSES ################## |
Also available in: Unified diff
first modifications to add interpolation methods and covaratiates options for daily deviation surfaces