Revision d5311185
Added by Benoit Parmentier over 8 years ago
climate/research/oregon/interpolation/global_run_scalingup_mosaicing.R | ||
---|---|---|
5 | 5 |
#Analyses, figures, tables and data are also produced in the script. |
6 | 6 |
#AUTHOR: Benoit Parmentier |
7 | 7 |
#CREATED ON: 04/14/2015 |
8 |
#MODIFIED ON: 05/31/2016
|
|
8 |
#MODIFIED ON: 06/08/2016
|
|
9 | 9 |
#Version: 6 |
10 | 10 |
#PROJECT: Environmental Layers project |
11 | 11 |
#COMMENTS: analyses run for reg4 1991 for test of mosaicing using 1500x4500km and other tiles |
... | ... | |
224 | 224 |
data_day_v <- read.table(data_day_v_name,sep=",") #daily training stations by dates and tiles |
225 | 225 |
df_tile_processed <- read.table(df_tile_processed_name,sep=",") |
226 | 226 |
|
227 |
##Read additional data from table assessment, add later |
|
228 |
#pred_data_day_info_1999_reg4_1999.txt |
|
229 |
#pred_data_day_info_name <- df_assessment_files$files[11] |
|
230 |
|
|
227 | 231 |
#this part needs to be improve make this a function and use multicore to loop through files... |
228 | 232 |
#give a range of dates to run... |
229 | 233 |
#browser() |
... | ... | |
323 | 327 |
|
324 | 328 |
#### Add option for ac training here |
325 | 329 |
|
326 |
|
|
330 |
if(layers_option=="ac_training"){ |
|
331 |
#this takes about 1 minute and 35 seconds for 3 days and 28 tiles... |
|
332 |
#add options to clean up file after use!! |
|
333 |
#tb <- list_param$tb #fitting or validation table with all days |
|
334 |
#metric_name <- "rmse" #RMSE, MAE etc. |
|
335 |
#pred_mod_name <- "mod1" |
|
336 |
#y_var_name |
|
337 |
#interpolation_method #c("gam_CAI") #PARAM3 |
|
338 |
days_to_process <- day_to_mosaic |
|
339 |
#NA_flag_val <- list_param$NA_flag_val |
|
340 |
#file_format <- list_param$file_format |
|
341 |
out_dir_str <- out_dir |
|
342 |
out_suffix_str <- out_suffix |
|
343 |
lf <- lf_mosaic |
|
344 |
|
|
345 |
#Improved by adding multicores option |
|
346 |
num_cores_tmp <- num_cores |
|
347 |
#use tb_s (training) instead of tb |
|
348 |
list_param_accuracy_metric_raster <- list(lf,tb_s,metric_name,pred_mod_name,y_var_name,interpolation_method, |
|
349 |
days_to_process,num_cores_tmp,NA_flag_val,file_format,out_dir_str,out_suffix_str) |
|
350 |
names(list_param_accuracy_metric_raster) <- c("lf","tb","metric_name","pred_mod_name","y_var_name","interpolation_method", |
|
351 |
"days_to_process","num_cores","NA_flag_val","file_format","out_dir_str","out_suffix_str") |
|
352 |
list_raster_created_obj <- lapply(1:length(day_to_mosaic),FUN=create_accuracy_metric_raster, |
|
353 |
list_param=list_param_accuracy_metric_raster) |
|
354 |
|
|
355 |
#debug(create_accuracy_metric_raster) |
|
356 |
#list_raster_created_obj <- lapply(1:1,FUN=create_accuracy_metric_raster, |
|
357 |
# list_param=list_param_accuracy_metric_raster) |
|
358 |
#raster_created_obj <- create_accuracy_metric_raster(1, list_param_accuracy_metric_raster) |
|
359 |
|
|
360 |
#Extract list of files for rmse and date 1 (19920101), there should be 28 raster images |
|
361 |
lf_accuracy_training_raster <- lapply(1:length(list_raster_created_obj),FUN=function(i){unlist(list_raster_created_obj[[i]]$list_raster_name)}) |
|
362 |
|
|
363 |
#Plot as quick check |
|
364 |
#r1 <- raster(lf_mosaic[[1]][1]) |
|
365 |
#plot(r1) |
|
366 |
#browser() |
|
367 |
|
|
368 |
} |
|
369 |
|
|
327 | 370 |
#################################### |
328 | 371 |
###Depending on value of layers_option, create accuracy surfaces based on testing residuals... |
329 | 372 |
#browser() |
... | ... | |
506 | 549 |
## Now accuracy based on center of centroids |
507 | 550 |
mosaic_method <- "use_edge_weights" #this is distance from edge |
508 | 551 |
#Adding metric name in the name... |
509 |
out_suffix_tmp <- paste(interpolation_method,metric_name,day_to_mosaic[i],out_suffix,sep="_") |
|
552 |
#out_suffix_tmp <- paste(interpolation_method,metric_name,day_to_mosaic[i],out_suffix,sep="_") |
|
553 |
out_suffix_tmp <- paste(interpolation_method,metric_name,layers_option,day_to_mosaic[i],out_suffix,sep="_") |
|
510 | 554 |
|
511 | 555 |
#Can modify here....add creation of data for the specific date here rather than beforehand!!!! |
512 | 556 |
|
... | ... | |
532 | 576 |
data_type=data_type, |
533 | 577 |
scaling=scaling, |
534 | 578 |
values_range=values_range) |
535 |
##Took 29 minutes for 28 tiles and one date...!!!
|
|
579 |
##Took 12-13 minutes for 28 tiles and one date...!!!
|
|
536 | 580 |
list_mosaic_obj[[i]] <- mosaic_obj |
537 | 581 |
} |
538 | 582 |
|
... | ... | |
540 | 584 |
## Now accuracy based on center of centroids |
541 | 585 |
mosaic_method <- "use_edge_weights" #this is distance from edge |
542 | 586 |
#Adding metric name in the name... |
543 |
out_suffix_tmp <- paste(interpolation_method,metric_name,day_to_mosaic[i],out_suffix,sep="_") |
|
544 |
|
|
587 |
out_suffix_tmp <- paste(interpolation_method,metric_name,layers_option,day_to_mosaic[i],out_suffix,sep="_") |
|
588 |
#out_suffix_tmp <- paste(interpolation_method,"kriged_residuals","data_day_v",day_to_mosaic[i],out_suffix,sep="_") |
|
589 |
|
|
545 | 590 |
#Can modify here....add creation of data for the specific date here rather than beforehand!!!! |
546 | 591 |
|
547 | 592 |
## To be inserted... |
Also available in: Unified diff
adding mosaicing of accuracy layers derived from training