Revision e12834f4
Added by Benoit Parmentier over 9 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: 06/09/2015
|
|
8 |
#MODIFIED ON: 06/10/2015
|
|
9 | 9 |
#Version: 4 |
10 | 10 |
#PROJECT: Environmental Layers project |
11 |
#COMMENTS: analyses for run 10 global analyses,all regions 1500x4500km and other tiles
|
|
11 |
#COMMENTS: analyses run for reg5 for test of mosaicing using 1500x4500km and other tiles
|
|
12 | 12 |
#TODO: |
13 | 13 |
#1) Split functions and master script |
14 | 14 |
#2) Make this is a script/function callable from the shell/bash |
15 | 15 |
#3) Check image format for tif |
16 |
#4) generalize to run dates and region fast |
|
16 | 17 |
|
17 | 18 |
################################################################################################# |
18 | 19 |
|
... | ... | |
320 | 321 |
|
321 | 322 |
y_var_name <- "dailyTmax" #PARAM1 |
322 | 323 |
interpolation_method <- c("gam_CAI") #PARAM2 |
323 |
region_name <- "reg2" #PARAM 13 #reg1 is North America, Africa Region 5
|
|
324 |
region_name <- "reg5" #PARAM 13 #reg1 is North America, Africa Region 5
|
|
324 | 325 |
|
325 |
out_suffix <- paste(region_name,"_","mosaic_run10_1500x4500_global_analyses_06072015",sep="")
|
|
326 |
out_suffix <- paste(region_name,"_","mosaic_run10_1500x4500_global_analyses_06102015",sep="")
|
|
326 | 327 |
#PARAM3 |
327 | 328 |
out_dir <- in_dir #PARAM4 |
328 | 329 |
create_out_dir_param <- TRUE #PARAM 5 |
... | ... | |
480 | 481 |
r_ref <- raster(rast_ref) |
481 | 482 |
plot(r_ref) |
482 | 483 |
|
484 |
### First match weights from linear option |
|
485 |
lf_files <- unlist(list_linear_r_weights) |
|
486 |
|
|
487 |
list_param_raster_match <- list(lf_files,rast_ref,file_format,out_suffix,out_dir) |
|
488 |
names(list_param_raster_match) <- c("lf_files","rast_ref","file_format","out_suffix","out_dir_str") |
|
489 |
|
|
490 |
#debug(raster_match) |
|
491 |
#r_test <- raster(raster_match(1,list_param_raster_match)) |
|
492 |
|
|
493 |
list_linear_weights_m <- mclapply(1:length(lf_files),FUN=raster_match,list_param=list_param_raster_match,mc.preschedule=FALSE,mc.cores = num_cores) |
|
494 |
|
|
495 |
lf_files <- unlist(list_linear_r_weights_prod) |
|
496 |
list_param_raster_match <- list(lf_files,rast_ref,file_format,out_suffix,out_dir) |
|
497 |
names(list_param_raster_match) <- c("lf_files","rast_ref","file_format","out_suffix","out_dir_str") |
|
498 |
|
|
499 |
num_cores <-11 |
|
500 |
list_linear_weights_prod_m <- mclapply(1:length(lf_files),FUN=raster_match,list_param=list_param_raster_match,mc.preschedule=FALSE,mc.cores = num_cores) |
|
501 |
|
|
502 |
#### Second use use edge (dist) images |
|
503 |
|
|
504 |
lf_files <- unlist(list_edge_r_weights) |
|
505 |
|
|
506 |
list_param_raster_match <- list(lf_files,rast_ref,file_format,out_suffix,out_dir) |
|
507 |
names(list_param_raster_match) <- c("lf_files","rast_ref","file_format","out_suffix","out_dir_str") |
|
508 |
|
|
509 |
#debug(raster_match) |
|
510 |
#r_test <- raster(raster_match(1,list_param_raster_match)) |
|
511 |
|
|
512 |
list_edge_weights_m <- mclapply(1:length(lf_files),FUN=raster_match,list_param=list_param_raster_match,mc.preschedule=FALSE,mc.cores = num_cores) |
|
513 |
|
|
514 |
lf_files <- unlist(list_edge_r_weights_prod) |
|
515 |
list_param_raster_match <- list(lf_files,rast_ref,file_format,out_suffix,out_dir) |
|
516 |
names(list_param_raster_match) <- c("lf_files","rast_ref","file_format","out_suffix","out_dir_str") |
|
517 |
|
|
518 |
num_cores <-11 |
|
519 |
list_edge_weights_prod_m <- mclapply(1:length(lf_files),FUN=raster_match,list_param=list_param_raster_match,mc.preschedule=FALSE,mc.cores = num_cores) |
|
520 |
|
|
521 |
|
|
522 |
### third match wegihts from sine option |
|
523 |
|
|
524 |
lf_files <- unlist(list_sine_r_weights) |
|
525 |
|
|
526 |
list_param_raster_match <- list(lf_files,rast_ref,file_format,out_suffix,out_dir) |
|
527 |
names(list_param_raster_match) <- c("lf_files","rast_ref","file_format","out_suffix","out_dir_str") |
|
528 |
|
|
529 |
#debug(raster_match) |
|
530 |
#r_test <- raster(raster_match(1,list_param_raster_match)) |
|
531 |
|
|
532 |
list_sine_weights_m <- mclapply(1:length(lf_files),FUN=raster_match,list_param=list_param_raster_match,mc.preschedule=FALSE,mc.cores = num_cores) |
|
533 |
|
|
534 |
lf_files <- unlist(list_sine_r_weights_prod) |
|
535 |
list_param_raster_match <- list(lf_files,rast_ref,file_format,out_suffix,out_dir) |
|
536 |
names(list_param_raster_match) <- c("lf_files","rast_ref","file_format","out_suffix","out_dir_str") |
|
537 |
|
|
538 |
num_cores <-11 |
|
539 |
list_sine_weights_prod_m <- mclapply(1:length(lf_files),FUN=raster_match,list_param=list_param_raster_match,mc.preschedule=FALSE,mc.cores = num_cores) |
|
540 |
|
|
483 | 541 |
#### Fourth use original images |
484 | 542 |
#macth file to mosaic extent using the original predictions |
485 | 543 |
lf_files <- lf_mosaic |
... | ... | |
492 | 550 |
###### PART 4: compute the weighted mean with the mosaic function ##### |
493 | 551 |
|
494 | 552 |
##Make this a function later |
495 |
|
|
496 | 553 |
list_weights_m <- list(list_linear_weights_m,list_edge_weights_m,list_sine_weights_m) |
497 | 554 |
list_weights_prod_m <- list(list_linear_weights_prod_m,list_edge_weights_prod_m,list_sine_weights_prod_m) |
498 | 555 |
list_methods <- c("linear","edge","sine") |
Also available in: Unified diff
mosaicing test for Africa region (5) using all methods and distance ot edge